+
+ /// SetCurrentDebugLocation - Set location information used by debugging
+ /// information.
+ void SetCurrentDebugLocation(const DebugLoc &L) {
+ CurDbgLocation = L;
+ }
+
+ /// getCurrentDebugLocation - Get location information used by debugging
+ /// information.
+ const DebugLoc &getCurrentDebugLocation() const { return CurDbgLocation; }
+
+ /// SetInstDebugLocation - If this builder has a current debug location, set
+ /// it on the specified instruction.
+ void SetInstDebugLocation(Instruction *I) const {
+ if (!CurDbgLocation.isUnknown())
+ I->setDebugLoc(CurDbgLocation);
+ }
+
+ //===--------------------------------------------------------------------===//
+ // Miscellaneous creation methods.
+ //===--------------------------------------------------------------------===//
+
+ /// CreateGlobalString - Make a new global variable with an initializer that
+ /// has array of i8 type filled in with the nul terminated string value
+ /// specified. If Name is specified, it is the name of the global variable
+ /// created.
+ Value *CreateGlobalString(const char *Str = "", const Twine &Name = "");
+
+ //===--------------------------------------------------------------------===//
+ // Type creation methods
+ //===--------------------------------------------------------------------===//
+
+ /// getInt1Ty - Fetch the type representing a single bit
+ const Type *getInt1Ty() {
+ return Type::getInt1Ty(Context);
+ }
+
+ /// getInt8Ty - Fetch the type representing an 8-bit integer.
+ const Type *getInt8Ty() {
+ return Type::getInt8Ty(Context);
+ }
+
+ /// getInt16Ty - Fetch the type representing a 16-bit integer.
+ const Type *getInt16Ty() {
+ return Type::getInt16Ty(Context);
+ }
+
+ /// getInt32Ty - Fetch the type resepresenting a 32-bit integer.
+ const Type *getInt32Ty() {
+ return Type::getInt32Ty(Context);
+ }
+
+ /// getInt64Ty - Fetch the type representing a 64-bit integer.
+ const Type *getInt64Ty() {
+ return Type::getInt64Ty(Context);
+ }
+
+ /// getFloatTy - Fetch the type representing a 32-bit floating point value.
+ const Type *getFloatTy() {
+ return Type::getFloatTy(Context);
+ }
+
+ /// getDoubleTy - Fetch the type representing a 64-bit floating point value.
+ const Type *getDoubleTy() {
+ return Type::getDoubleTy(Context);
+ }
+
+ /// getVoidTy - Fetch the type representing void.
+ const Type *getVoidTy() {
+ return Type::getVoidTy(Context);
+ }
+
+ const Type *getInt8PtrTy() {
+ return Type::getInt8PtrTy(Context);
+ }
+
+ /// getCurrentFunctionReturnType - Get the return type of the current function
+ /// that we're emitting into.
+ const Type *getCurrentFunctionReturnType() const;
+};
+
+/// IRBuilder - This provides a uniform API for creating instructions and
+/// inserting them into a basic block: either at the end of a BasicBlock, or
+/// at a specific iterator location in a block.
+///
+/// Note that the builder does not expose the full generality of LLVM
+/// instructions. For access to extra instruction properties, use the mutators
+/// (e.g. setVolatile) on the instructions after they have been created.
+/// The first template argument handles whether or not to preserve names in the
+/// final instruction output. This defaults to on. The second template argument
+/// specifies a class to use for creating constants. This defaults to creating
+/// minimally folded constants. The fourth template argument allows clients to
+/// specify custom insertion hooks that are called on every newly created
+/// insertion.
+template<bool preserveNames = true, typename T = ConstantFolder,
+ typename Inserter = IRBuilderDefaultInserter<preserveNames> >
+class IRBuilder : public IRBuilderBase, public Inserter {
+ T Folder;
+public:
+ IRBuilder(LLVMContext &C, const T &F, const Inserter &I = Inserter())
+ : IRBuilderBase(C), Inserter(I), Folder(F) {
+ }
+
+ explicit IRBuilder(LLVMContext &C) : IRBuilderBase(C), Folder(C) {
+ }
+
+ explicit IRBuilder(BasicBlock *TheBB, const T &F)
+ : IRBuilderBase(TheBB->getContext()), Folder(F) {
+ SetInsertPoint(TheBB);
+ }
+
+ explicit IRBuilder(BasicBlock *TheBB)
+ : IRBuilderBase(TheBB->getContext()), Folder(Context) {
+ SetInsertPoint(TheBB);
+ }
+
+ IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F)
+ : IRBuilderBase(TheBB->getContext()), Folder(F) {
+ SetInsertPoint(TheBB, IP);
+ }
+
+ IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP)
+ : IRBuilderBase(TheBB->getContext()), Folder(Context) {
+ SetInsertPoint(TheBB, IP);
+ }