提交 565a9bf2 编写于 作者: B Björn Steinbrink

Provide lower level access to the LLVM IR builder

Currently, the helper functions in the "build" module can only append
at the end of a block. For certain things we'll want to be able to
insert code at arbitrary locations inside a block though. Although can
we do that by directly calling the LLVM functions, that is rather ugly
and means that somethings need to be implemented twice. Once in terms
of the helper functions and once in terms of low level LLVM functions.

Instead of doing that, we should provide a Builder type that provides
low level access to the builder, and which can be used by both, the
helper functions in the "build" module, as well larger units of
abstractions that combine several LLVM instructions.
上级 3cccdbd9
......@@ -41,6 +41,7 @@
use middle::trans::adt;
use middle::trans::base;
use middle::trans::build::*;
use middle::trans::builder::noname;
use middle::trans::callee;
use middle::trans::common::*;
use middle::trans::consts;
......
此差异已折叠。
此差异已折叠。
......@@ -19,6 +19,7 @@
use middle::resolve;
use middle::trans::adt;
use middle::trans::base;
use middle::trans::builder::Builder;
use middle::trans::debuginfo;
use middle::trans::type_use;
use middle::ty;
......@@ -227,6 +228,10 @@ pub fn new(sess: session::Session,
}
}
}
pub fn builder(@mut self) -> Builder {
Builder::new(self)
}
}
#[unsafe_destructor]
......
......@@ -188,7 +188,7 @@ pub fn create_local_var_metadata(bcx: block, local: @ast::local) -> DIVariable {
set_debug_location(cx, lexical_block_metadata(bcx), loc.line, loc.col.to_uint());
unsafe {
let instr = llvm::LLVMDIBuilderInsertDeclareAtEnd(DIB(cx), llptr, var_metadata, bcx.llbb);
llvm::LLVMSetInstDebugLocation(trans::build::B(bcx), instr);
llvm::LLVMSetInstDebugLocation(trans::build::B(bcx).llbuilder, instr);
}
return var_metadata;
......@@ -247,7 +247,7 @@ pub fn create_argument_metadata(bcx: block, arg: &ast::arg, span: span) -> Optio
unsafe {
let instr = llvm::LLVMDIBuilderInsertDeclareAtEnd(
DIB(cx), llptr, var_metadata, bcx.llbb);
llvm::LLVMSetInstDebugLocation(trans::build::B(bcx), instr);
llvm::LLVMSetInstDebugLocation(trans::build::B(bcx).llbuilder, instr);
}
return Some(var_metadata);
}
......
......@@ -22,6 +22,7 @@
pub mod consts;
pub mod type_of;
pub mod build;
pub mod builder;
pub mod base;
pub mod _match;
pub mod uniq;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册