llvm.org GIT mirror llvm / 083f0c8
[LLVM-C] Add bindings to insert basic blocks Summary: Now that we can create standalone basic blocks, it's useful to be able to append them. Add bindings to - Insert a basic block after the current insertion block - Append a basic block to the end of a function's list of basic blocks Reviewers: whitequark, deadalnix, harlanhaskins Reviewed By: whitequark, harlanhaskins Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59658 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357812 91177308-0d34-0410-b5e6-96231b3b80d8 Robert Widmann 4 months ago
2 changed file(s) with 32 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
29162916 LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
29172917
29182918 /**
2919 * Insert the given basic block after the insertion point of the given builder.
2920 *
2921 * The insertion point must be valid.
2922 *
2923 * @see llvm::Function::BasicBlockListType::insertAfter()
2924 */
2925 void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder,
2926 LLVMBasicBlockRef BB);
2927
2928 /**
2929 * Append the given basic block to the basic block list of the given function.
2930 *
2931 * @see llvm::Function::BasicBlockListType::push_back()
2932 */
2933 void LLVMAppendExistingBasicBlock(LLVMValueRef Fn,
2934 LLVMBasicBlockRef BB);
2935
2936 /**
29192937 * Create a new basic block without inserting it into a function.
29202938 *
29212939 * @see llvm::BasicBlock::Create()
26082608 return wrap(llvm::BasicBlock::Create(*unwrap(C), Name));
26092609 }
26102610
2611 void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder,
2612 LLVMBasicBlockRef BB) {
2613 BasicBlock *ToInsert = unwrap(BB);
2614 BasicBlock *CurBB = unwrap(Builder)->GetInsertBlock();
2615 assert(CurBB && "current insertion point is invalid!");
2616 CurBB->getParent()->getBasicBlockList().insertAfter(CurBB->getIterator(),
2617 ToInsert);
2618 }
2619
2620 void LLVMAppendExistingBasicBlock(LLVMValueRef Fn,
2621 LLVMBasicBlockRef BB) {
2622 unwrap(Fn)->getBasicBlockList().push_back(unwrap(BB));
2623 }
2624
26112625 LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
26122626 LLVMValueRef FnRef,
26132627 const char *Name) {