LLVM  14.0.0git
Functions

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. More...

Collaboration diagram for Basic Block:

Functions

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

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()

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 2730 of file Core.cpp.

References LLVMAppendBasicBlockInContext(), and LLVMGetGlobalContext().

◆ LLVMAppendBasicBlockInContext()

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 2724 of file Core.cpp.

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

Referenced by LLVMAppendBasicBlock().

◆ LLVMAppendExistingBasicBlock()

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 2719 of file Core.cpp.

References BB, and llvm::unwrap().

◆ LLVMBasicBlockAsValue()

LLVMValueRef LLVMBasicBlockAsValue ( LLVMBasicBlockRef  BB)

Convert a basic block instance to a value type.

Definition at line 2635 of file Core.cpp.

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

◆ LLVMCountBasicBlocks()

unsigned LLVMCountBasicBlocks ( LLVMValueRef  Fn)

Obtain the number of basic blocks in a function.

Parameters
FnFunction value to operate on.

Definition at line 2659 of file Core.cpp.

◆ LLVMCreateBasicBlockInContext()

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 2705 of file Core.cpp.

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

◆ LLVMDeleteBasicBlock()

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 2746 of file Core.cpp.

References llvm::unwrap().

◆ LLVMGetBasicBlockName()

const char* LLVMGetBasicBlockName ( LLVMBasicBlockRef  BB)

Obtain the string name of a basic block.

Definition at line 2647 of file Core.cpp.

References BB, and llvm::unwrap().

◆ LLVMGetBasicBlockParent()

LLVMValueRef LLVMGetBasicBlockParent ( LLVMBasicBlockRef  BB)

Obtain the function to which a basic block belongs.

See also
llvm::BasicBlock::getParent()

Definition at line 2651 of file Core.cpp.

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

◆ LLVMGetBasicBlocks()

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 2663 of file Core.cpp.

References BB, and llvm::wrap().

◆ LLVMGetBasicBlockTerminator()

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 2655 of file Core.cpp.

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

◆ LLVMGetEntryBasicBlock()

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 2669 of file Core.cpp.

References llvm::wrap().

◆ LLVMGetFirstBasicBlock()

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 2673 of file Core.cpp.

References I, and llvm::wrap().

◆ LLVMGetFirstInstruction()

LLVMValueRef LLVMGetFirstInstruction ( LLVMBasicBlockRef  BB)

Obtain the first instruction in a basic block.

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

Definition at line 2768 of file Core.cpp.

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

◆ LLVMGetLastBasicBlock()

LLVMBasicBlockRef LLVMGetLastBasicBlock ( LLVMValueRef  Fn)

Obtain the last basic block in a function.

See also
llvm::Function::end()

Definition at line 2681 of file Core.cpp.

References I, and llvm::wrap().

◆ LLVMGetLastInstruction()

LLVMValueRef LLVMGetLastInstruction ( LLVMBasicBlockRef  BB)

Obtain the last instruction in a basic block.

The returned LLVMValueRef corresponds to an LLVM:Instruction.

Definition at line 2776 of file Core.cpp.

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

◆ LLVMGetNextBasicBlock()

LLVMBasicBlockRef LLVMGetNextBasicBlock ( LLVMBasicBlockRef  BB)

Advance a basic block iterator.

Definition at line 2689 of file Core.cpp.

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

◆ LLVMGetPreviousBasicBlock()

LLVMBasicBlockRef LLVMGetPreviousBasicBlock ( LLVMBasicBlockRef  BB)

Go backwards in a basic block iterator.

Definition at line 2697 of file Core.cpp.

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

◆ LLVMInsertBasicBlock()

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 2741 of file Core.cpp.

References LLVMGetGlobalContext(), and LLVMInsertBasicBlockInContext().

◆ LLVMInsertBasicBlockInContext()

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 2734 of file Core.cpp.

References BB, llvm::BasicBlock::Create(), llvm::unwrap(), and llvm::wrap().

Referenced by LLVMInsertBasicBlock().

◆ LLVMInsertExistingBasicBlockAfterInsertBlock()

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 2710 of file Core.cpp.

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

◆ LLVMMoveBasicBlockAfter()

void LLVMMoveBasicBlockAfter ( LLVMBasicBlockRef  BB,
LLVMBasicBlockRef  MovePos 
)

Move a basic block to after another one.

See also
llvm::BasicBlock::moveAfter()

Definition at line 2758 of file Core.cpp.

References BB, and llvm::unwrap().

◆ LLVMMoveBasicBlockBefore()

void LLVMMoveBasicBlockBefore ( LLVMBasicBlockRef  BB,
LLVMBasicBlockRef  MovePos 
)

Move a basic block to before another one.

See also
llvm::BasicBlock::moveBefore()

Definition at line 2754 of file Core.cpp.

References BB, and llvm::unwrap().

◆ LLVMRemoveBasicBlockFromParent()

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 2750 of file Core.cpp.

References llvm::unwrap().

◆ LLVMValueAsBasicBlock()

LLVMBasicBlockRef LLVMValueAsBasicBlock ( LLVMValueRef  Val)

Convert an LLVMValueRef to an LLVMBasicBlockRef instance.

Definition at line 2643 of file Core.cpp.

References llvm::wrap().

◆ LLVMValueIsBasicBlock()

LLVMBool LLVMValueIsBasicBlock ( LLVMValueRef  Val)

Determine whether an LLVMValueRef is itself a basic block.

Definition at line 2639 of file Core.cpp.

References llvm::unwrap().