LLVM 22.0.0git
Functions

A basic block represents a single entry single exit section of code. More...

Collaboration diagram for Basic Block:

Functions

LLVM_C_ABI LLVMValueRef LLVMBasicBlockAsValue (LLVMBasicBlockRef BB)
 Convert a basic block instance to a value type.
 
LLVM_C_ABI LLVMBool LLVMValueIsBasicBlock (LLVMValueRef Val)
 Determine whether an LLVMValueRef is itself a basic block.
 
LLVM_C_ABI LLVMBasicBlockRef LLVMValueAsBasicBlock (LLVMValueRef Val)
 Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
 
LLVM_C_ABI const charLLVMGetBasicBlockName (LLVMBasicBlockRef BB)
 Obtain the string name of a basic block.
 
LLVM_C_ABI LLVMValueRef LLVMGetBasicBlockParent (LLVMBasicBlockRef BB)
 Obtain the function to which a basic block belongs.
 
LLVM_C_ABI LLVMValueRef LLVMGetBasicBlockTerminator (LLVMBasicBlockRef BB)
 Obtain the terminator instruction for a basic block.
 
LLVM_C_ABI unsigned LLVMCountBasicBlocks (LLVMValueRef Fn)
 Obtain the number of basic blocks in a function.
 
LLVM_C_ABI void LLVMGetBasicBlocks (LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks)
 Obtain all of the basic blocks in a function.
 
LLVM_C_ABI LLVMBasicBlockRef LLVMGetFirstBasicBlock (LLVMValueRef Fn)
 Obtain the first basic block in a function.
 
LLVM_C_ABI LLVMBasicBlockRef LLVMGetLastBasicBlock (LLVMValueRef Fn)
 Obtain the last basic block in a function.
 
LLVM_C_ABI LLVMBasicBlockRef LLVMGetNextBasicBlock (LLVMBasicBlockRef BB)
 Advance a basic block iterator.
 
LLVM_C_ABI LLVMBasicBlockRef LLVMGetPreviousBasicBlock (LLVMBasicBlockRef BB)
 Go backwards in a basic block iterator.
 
LLVM_C_ABI LLVMBasicBlockRef LLVMGetEntryBasicBlock (LLVMValueRef Fn)
 Obtain the basic block that corresponds to the entry point of a function.
 
LLVM_C_ABI void LLVMInsertExistingBasicBlockAfterInsertBlock (LLVMBuilderRef Builder, LLVMBasicBlockRef BB)
 Insert the given basic block after the insertion point of the given builder.
 
LLVM_C_ABI void LLVMAppendExistingBasicBlock (LLVMValueRef Fn, LLVMBasicBlockRef BB)
 Append the given basic block to the basic block list of the given function.
 
LLVM_C_ABI LLVMBasicBlockRef LLVMCreateBasicBlockInContext (LLVMContextRef C, const char *Name)
 Create a new basic block without inserting it into a function.
 
LLVM_C_ABI LLVMBasicBlockRef LLVMAppendBasicBlockInContext (LLVMContextRef C, LLVMValueRef Fn, const char *Name)
 Append a basic block to the end of a function.
 
LLVM_C_ABI LLVMBasicBlockRef LLVMAppendBasicBlock (LLVMValueRef Fn, const char *Name)
 Append a basic block to the end of a function using the global context.
 
LLVM_C_ABI LLVMBasicBlockRef LLVMInsertBasicBlockInContext (LLVMContextRef C, LLVMBasicBlockRef BB, const char *Name)
 Insert a basic block in a function before another basic block.
 
LLVM_C_ABI LLVMBasicBlockRef LLVMInsertBasicBlock (LLVMBasicBlockRef InsertBeforeBB, const char *Name)
 Insert a basic block in a function using the global context.
 
LLVM_C_ABI void LLVMDeleteBasicBlock (LLVMBasicBlockRef BB)
 Remove a basic block from a function and delete it.
 
LLVM_C_ABI void LLVMRemoveBasicBlockFromParent (LLVMBasicBlockRef BB)
 Remove a basic block from a function.
 
LLVM_C_ABI void LLVMMoveBasicBlockBefore (LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos)
 Move a basic block to before another one.
 
LLVM_C_ABI void LLVMMoveBasicBlockAfter (LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos)
 Move a basic block to after another one.
 
LLVM_C_ABI LLVMValueRef LLVMGetFirstInstruction (LLVMBasicBlockRef BB)
 Obtain the first instruction in a basic block.
 
LLVM_C_ABI LLVMValueRef LLVMGetLastInstruction (LLVMBasicBlockRef BB)
 Obtain the last instruction in a basic block.
 

Detailed Description

A basic block represents a single entry single exit section of code.

Basic blocks contain a list of instructions which form the body of the block.

Basic blocks belong to functions. They have the type of label.

Basic blocks are themselves values. However, the C API models them as LLVMBasicBlockRef.

See also
llvm::BasicBlock

Function Documentation

◆ LLVMAppendBasicBlock()

LLVM_C_ABI LLVMBasicBlockRef LLVMAppendBasicBlock ( LLVMValueRef  Fn,
const char Name 
)

Append a basic block to the end of a function using the global context.

See also
llvm::BasicBlock::Create()

Definition at line 2876 of file Core.cpp.

References LLVMAppendBasicBlockInContext(), LLVMGetGlobalContext(), and Name.

◆ LLVMAppendBasicBlockInContext()

LLVM_C_ABI LLVMBasicBlockRef LLVMAppendBasicBlockInContext ( LLVMContextRef  C,
LLVMValueRef  Fn,
const char Name 
)

Append a basic block to the end of a function.

See also
llvm::BasicBlock::Create()

Definition at line 2870 of file Core.cpp.

References llvm::CallingConv::C, llvm::BasicBlock::Create(), Name, unwrap(), and llvm::wrap().

Referenced by LLVMAppendBasicBlock().

◆ LLVMAppendExistingBasicBlock()

LLVM_C_ABI void LLVMAppendExistingBasicBlock ( LLVMValueRef  Fn,
LLVMBasicBlockRef  BB 
)

Append the given basic block to the basic block list of the given function.

See also
llvm::Function::BasicBlockListType::push_back()

Definition at line 2865 of file Core.cpp.

References unwrap().

◆ LLVMBasicBlockAsValue()

LLVM_C_ABI LLVMValueRef LLVMBasicBlockAsValue ( LLVMBasicBlockRef  BB)

Convert a basic block instance to a value type.

Definition at line 2782 of file Core.cpp.

References unwrap(), and llvm::wrap().

◆ LLVMCountBasicBlocks()

LLVM_C_ABI unsigned LLVMCountBasicBlocks ( LLVMValueRef  Fn)

Obtain the number of basic blocks in a function.

Parameters
FnFunction value to operate on.

Definition at line 2806 of file Core.cpp.

◆ LLVMCreateBasicBlockInContext()

LLVM_C_ABI LLVMBasicBlockRef LLVMCreateBasicBlockInContext ( LLVMContextRef  C,
const char Name 
)

Create a new basic block without inserting it into a function.

See also
llvm::BasicBlock::Create()

Definition at line 2852 of file Core.cpp.

References llvm::CallingConv::C, llvm::BasicBlock::Create(), Name, unwrap(), and llvm::wrap().

◆ LLVMDeleteBasicBlock()

LLVM_C_ABI void LLVMDeleteBasicBlock ( LLVMBasicBlockRef  BB)

Remove a basic block from a function and delete it.

This deletes the basic block from its containing function and deletes the basic block itself.

See also
llvm::BasicBlock::eraseFromParent()

Definition at line 2892 of file Core.cpp.

References llvm::BasicBlock::eraseFromParent(), and unwrap().

◆ LLVMGetBasicBlockName()

LLVM_C_ABI const char * LLVMGetBasicBlockName ( LLVMBasicBlockRef  BB)

Obtain the string name of a basic block.

Definition at line 2794 of file Core.cpp.

References llvm::StringRef::data(), llvm::Value::getName(), and unwrap().

◆ LLVMGetBasicBlockParent()

LLVM_C_ABI LLVMValueRef LLVMGetBasicBlockParent ( LLVMBasicBlockRef  BB)

Obtain the function to which a basic block belongs.

See also
llvm::BasicBlock::getParent()

Definition at line 2798 of file Core.cpp.

References getParent(), unwrap(), and llvm::wrap().

◆ LLVMGetBasicBlocks()

LLVM_C_ABI void LLVMGetBasicBlocks ( LLVMValueRef  Fn,
LLVMBasicBlockRef BasicBlocks 
)

Obtain all of the basic blocks in a function.

This operates on a function value. The BasicBlocks parameter is a pointer to a pre-allocated array of LLVMBasicBlockRef of at least LLVMCountBasicBlocks() in length. This array is populated with LLVMBasicBlockRef instances.

Definition at line 2810 of file Core.cpp.

References llvm::wrap().

◆ LLVMGetBasicBlockTerminator()

LLVM_C_ABI LLVMValueRef LLVMGetBasicBlockTerminator ( LLVMBasicBlockRef  BB)

Obtain the terminator instruction for a basic block.

If the basic block does not have a terminator (it is not well-formed if it doesn't), then NULL is returned.

The returned LLVMValueRef corresponds to an llvm::Instruction.

See also
llvm::BasicBlock::getTerminator()

Definition at line 2802 of file Core.cpp.

References unwrap(), and llvm::wrap().

◆ LLVMGetEntryBasicBlock()

LLVM_C_ABI LLVMBasicBlockRef LLVMGetEntryBasicBlock ( LLVMValueRef  Fn)

Obtain the basic block that corresponds to the entry point of a function.

See also
llvm::Function::getEntryBlock()

Definition at line 2816 of file Core.cpp.

References llvm::wrap().

◆ LLVMGetFirstBasicBlock()

LLVM_C_ABI LLVMBasicBlockRef LLVMGetFirstBasicBlock ( LLVMValueRef  Fn)

Obtain the first basic block in a function.

The returned basic block can be used as an iterator. You will likely eventually call into LLVMGetNextBasicBlock() with it.

See also
llvm::Function::begin()

Definition at line 2820 of file Core.cpp.

References I, and llvm::wrap().

◆ LLVMGetFirstInstruction()

LLVM_C_ABI LLVMValueRef LLVMGetFirstInstruction ( LLVMBasicBlockRef  BB)

Obtain the first instruction in a basic block.

The returned LLVMValueRef corresponds to a llvm::Instruction instance.

Definition at line 2914 of file Core.cpp.

References llvm::Block, I, unwrap(), and llvm::wrap().

◆ LLVMGetLastBasicBlock()

LLVM_C_ABI LLVMBasicBlockRef LLVMGetLastBasicBlock ( LLVMValueRef  Fn)

Obtain the last basic block in a function.

See also
llvm::Function::end()

Definition at line 2828 of file Core.cpp.

References I, and llvm::wrap().

◆ LLVMGetLastInstruction()

LLVM_C_ABI LLVMValueRef LLVMGetLastInstruction ( LLVMBasicBlockRef  BB)

Obtain the last instruction in a basic block.

The returned LLVMValueRef corresponds to an LLVM:Instruction.

Definition at line 2922 of file Core.cpp.

References llvm::Block, I, unwrap(), and llvm::wrap().

◆ LLVMGetNextBasicBlock()

LLVM_C_ABI LLVMBasicBlockRef LLVMGetNextBasicBlock ( LLVMBasicBlockRef  BB)

Advance a basic block iterator.

Definition at line 2836 of file Core.cpp.

References llvm::Block, I, unwrap(), and llvm::wrap().

◆ LLVMGetPreviousBasicBlock()

LLVM_C_ABI LLVMBasicBlockRef LLVMGetPreviousBasicBlock ( LLVMBasicBlockRef  BB)

Go backwards in a basic block iterator.

Definition at line 2844 of file Core.cpp.

References llvm::Block, I, unwrap(), and llvm::wrap().

◆ LLVMInsertBasicBlock()

LLVM_C_ABI LLVMBasicBlockRef LLVMInsertBasicBlock ( LLVMBasicBlockRef  InsertBeforeBB,
const char Name 
)

Insert a basic block in a function using the global context.

See also
llvm::BasicBlock::Create()

Definition at line 2887 of file Core.cpp.

References LLVMGetGlobalContext(), LLVMInsertBasicBlockInContext(), and Name.

◆ LLVMInsertBasicBlockInContext()

LLVM_C_ABI LLVMBasicBlockRef LLVMInsertBasicBlockInContext ( LLVMContextRef  C,
LLVMBasicBlockRef  BB,
const char Name 
)

Insert a basic block in a function before another basic block.

The function to add to is determined by the function of the passed basic block.

See also
llvm::BasicBlock::Create()

Definition at line 2880 of file Core.cpp.

References llvm::CallingConv::C, llvm::BasicBlock::Create(), llvm::BasicBlock::getParent(), Name, unwrap(), and llvm::wrap().

Referenced by LLVMInsertBasicBlock().

◆ LLVMInsertExistingBasicBlockAfterInsertBlock()

LLVM_C_ABI void LLVMInsertExistingBasicBlockAfterInsertBlock ( LLVMBuilderRef  Builder,
LLVMBasicBlockRef  BB 
)

Insert the given basic block after the insertion point of the given builder.

The insertion point must be valid.

See also
llvm::Function::BasicBlockListType::insertAfter()

Definition at line 2857 of file Core.cpp.

References assert(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::BasicBlock::getParent(), llvm::Function::insert(), and unwrap().

◆ LLVMMoveBasicBlockAfter()

LLVM_C_ABI void LLVMMoveBasicBlockAfter ( LLVMBasicBlockRef  BB,
LLVMBasicBlockRef  MovePos 
)

Move a basic block to after another one.

See also
llvm::BasicBlock::moveAfter()

Definition at line 2904 of file Core.cpp.

References llvm::BasicBlock::moveAfter(), and unwrap().

◆ LLVMMoveBasicBlockBefore()

LLVM_C_ABI void LLVMMoveBasicBlockBefore ( LLVMBasicBlockRef  BB,
LLVMBasicBlockRef  MovePos 
)

Move a basic block to before another one.

See also
llvm::BasicBlock::moveBefore()

Definition at line 2900 of file Core.cpp.

References llvm::BasicBlock::moveBefore(), and unwrap().

◆ LLVMRemoveBasicBlockFromParent()

LLVM_C_ABI void LLVMRemoveBasicBlockFromParent ( LLVMBasicBlockRef  BB)

Remove a basic block from a function.

This deletes the basic block from its containing function but keep the basic block alive.

See also
llvm::BasicBlock::removeFromParent()

Definition at line 2896 of file Core.cpp.

References llvm::BasicBlock::removeFromParent(), and unwrap().

◆ LLVMValueAsBasicBlock()

LLVM_C_ABI LLVMBasicBlockRef LLVMValueAsBasicBlock ( LLVMValueRef  Val)

Convert an LLVMValueRef to an LLVMBasicBlockRef instance.

Definition at line 2790 of file Core.cpp.

References llvm::wrap().

◆ LLVMValueIsBasicBlock()

LLVM_C_ABI LLVMBool LLVMValueIsBasicBlock ( LLVMValueRef  Val)

Determine whether an LLVMValueRef is itself a basic block.

Definition at line 2786 of file Core.cpp.

References unwrap().