forked from OSchip/llvm-project
[LLVM-C] Allow For Creating a BasicBlock without a Parent Function
Summary: Add a utility function for creating a basic block without a parent function. A useful operation for compilers that need to synthesize and conditionally insert code without having to bother with appending and immediately unlinking a block. Reviewers: whitequark, deadalnix Reviewed By: whitequark Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D56279 llvm-svn: 350608
This commit is contained in:
parent
40dc48be0e
commit
616ed17221
|
@ -2806,6 +2806,15 @@ LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
|
|||
*/
|
||||
LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
|
||||
|
||||
/**
|
||||
* Create a new basic block without inserting it into a function.
|
||||
*
|
||||
* @see llvm::BasicBlock::Create()
|
||||
*/
|
||||
LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C,
|
||||
const char *Name,
|
||||
size_t NameLen);
|
||||
|
||||
/**
|
||||
* Append a basic block to the end of a function.
|
||||
*
|
||||
|
|
|
@ -2532,6 +2532,12 @@ LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB) {
|
|||
return wrap(&*--I);
|
||||
}
|
||||
|
||||
LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C,
|
||||
const char *Name,
|
||||
size_t NameLen) {
|
||||
return wrap(llvm::BasicBlock::Create(*unwrap(C), StringRef(Name, NameLen)));
|
||||
}
|
||||
|
||||
LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
|
||||
LLVMValueRef FnRef,
|
||||
const char *Name) {
|
||||
|
|
Loading…
Reference in New Issue