+ const PointerType *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);
+ }
+
+ /// getFolder - Get the constant folder being used.
+ const T &getFolder() { return Folder; }
+
+ /// isNamePreserving - Return true if this builder is configured to actually
+ /// add the requested names to IR created through it.
+ bool isNamePreserving() const { return preserveNames; }
+
+ /// Insert - Insert and return the specified instruction.
+ template<typename InstTy>
+ InstTy *Insert(InstTy *I, const Twine &Name = "") const {
+ this->InsertHelper(I, Name, BB, InsertPt);
+ if (!getCurrentDebugLocation().isUnknown())
+ this->SetInstDebugLocation(I);
+ return I;
+ }
+