|
Proteus
Programmable JIT compilation and optimization for C/C++ using LLVM
|
#include <LLVMCodeBuilder.h>


Classes | |
| struct | Impl |
Public Member Functions | |
| LLVMCodeBuilder (std::unique_ptr< llvm::LLVMContext > Ctx, std::unique_ptr< llvm::Module > Mod, TargetModelType TM=TargetModelType::HOST) | |
| Construct as owner of LLVMContext and Module. | |
| ~LLVMCodeBuilder () override | |
| TargetModelType | getTargetModel () const override |
| LLVMCodeBuilder (const LLVMCodeBuilder &)=delete | |
| LLVMCodeBuilder & | operator= (const LLVMCodeBuilder &)=delete |
| llvm::IRBuilderBase & | getIRBuilder () |
| Get the underlying IRBuilderBase (internal use only). | |
| llvm::Function & | getFunction () |
| llvm::Module & | getModule () |
| llvm::LLVMContext & | getContext () |
| std::unique_ptr< llvm::LLVMContext > | takeLLVMContext () |
| Transfer ownership of the LLVMContext (leaves internal pointer null). | |
| std::unique_ptr< llvm::Module > | takeModule () |
| Transfer ownership of the Module (leaves internal pointer null). | |
| std::tuple< llvm::BasicBlock *, llvm::BasicBlock * > | splitCurrentBlock () |
| llvm::BasicBlock * | createBasicBlock (const std::string &Name="", llvm::BasicBlock *InsertBefore=nullptr) |
| void | eraseTerminator (llvm::BasicBlock *BB) |
| llvm::BasicBlock * | getUniqueSuccessor (llvm::BasicBlock *BB) |
| void | pushScope (const char *File, int Line, ScopeKind Kind, llvm::BasicBlock *NextBlock) |
| void | createBr (llvm::BasicBlock *Dest) |
| void | createCondBr (IRValue *Cond, llvm::BasicBlock *True, llvm::BasicBlock *False) |
| llvm::Type * | getPointerType (llvm::Type *ElemTy, unsigned AS) |
| llvm::Type * | getPointerTypeUnqual (llvm::Type *ElemTy) |
| llvm::Type * | getInt16Ty () |
| llvm::Type * | getInt32Ty () |
| llvm::Type * | getInt64Ty () |
| llvm::Type * | getFloatTy () |
| unsigned | getAddressSpace (llvm::Type *Ty) |
| bool | isIntegerTy (llvm::Type *Ty) |
| bool | isFloatingPointTy (llvm::Type *Ty) |
| IRValue * | emitAlloca (llvm::Type *Ty, const std::string &Name, AddressSpace AS=AddressSpace::DEFAULT) |
| IRValue * | emitArrayCreate (llvm::Type *Ty, AddressSpace AT, const std::string &Name) |
| IRFunction * | addFunction (const std::string &Name, IRType RetTy, const std::vector< IRType > &ArgTys) override |
| void | setFunctionName (IRFunction *F, const std::string &Name) override |
Rename the function identified by F. | |
| IRValue * | getArg (IRFunction *F, size_t Idx) override |
Return the Nth argument of F as an IRValue. | |
| void | beginFunction (IRFunction *F, const char *File, int Line) override |
Set F as the active function and begin IR emission. | |
| void | endFunction () override |
| void | setInsertPointAtEntry () override |
| void | clearInsertPoint () override |
| void | beginIf (IRValue *Cond, const char *File, int Line) override |
| void | endIf () override |
| void | beginFor (IRValue *IterSlot, IRType IterTy, IRValue *InitVal, IRValue *UpperBoundVal, IRValue *IncVal, bool IsSigned, const char *File, int Line, LoopHints Hints={}) override |
| void | endFor () override |
| void | beginWhile (std::function< IRValue *()> CondFn, const char *File, int Line) override |
| void | endWhile () override |
| void | createRetVoid () override |
| void | createRet (IRValue *V) override |
| IRValue * | createArith (ArithOp Op, IRValue *LHS, IRValue *RHS, IRType Ty) override |
| IRValue * | createAtomicAdd (IRValue *Addr, IRValue *Val) override |
| IRValue * | createAtomicSub (IRValue *Addr, IRValue *Val) override |
| IRValue * | createAtomicMax (IRValue *Addr, IRValue *Val) override |
| IRValue * | createAtomicMin (IRValue *Addr, IRValue *Val) override |
| IRValue * | createCmp (CmpOp Op, IRValue *LHS, IRValue *RHS, IRType Ty) override |
| IRValue * | createAnd (IRValue *LHS, IRValue *RHS) override |
| IRValue * | createOr (IRValue *LHS, IRValue *RHS) override |
| IRValue * | createXor (IRValue *LHS, IRValue *RHS) override |
| IRValue * | createNot (IRValue *Val) override |
| IRValue * | createLoad (IRType Ty, IRValue *Ptr, const std::string &Name="") override |
| void | createStore (IRValue *Val, IRValue *Ptr) override |
| IRValue * | createCast (IRValue *V, IRType FromTy, IRType ToTy) override |
| IRValue * | createBitCast (IRValue *V, IRType DestTy) override |
| IRValue * | createZExt (IRValue *V, IRType DestTy) override |
| IRValue * | getConstantInt (IRType Ty, uint64_t Val) override |
| IRValue * | getConstantFP (IRType Ty, double Val) override |
| VarAlloc | getElementPtr (IRValue *Base, IRType BaseTy, IRValue *Index, IRType ElemTy) override |
| VarAlloc | getElementPtr (IRValue *Base, IRType BaseTy, size_t Index, IRType ElemTy) override |
| IRValue * | createCall (const std::string &FName, IRType RetTy, const std::vector< IRType > &ArgTys, const std::vector< IRValue * > &Args) override |
| IRValue * | createCall (const std::string &FName, IRType RetTy) override |
| IRValue * | loadScalar (IRValue *Slot, IRType ValueTy) override |
Load the value stored directly in Slot (scalar alloca). | |
| void | storeScalar (IRValue *Slot, IRValue *Val) override |
Store Val directly into Slot (scalar alloca). | |
| IRValue * | loadAddress (IRValue *Slot, IRType AllocTy) override |
Load the pointer stored in Slot (pointer alloca). | |
| void | storeAddress (IRValue *Slot, IRValue *Addr) override |
Store Addr into Slot (pointer alloca). | |
| IRValue * | loadFromPointee (IRValue *Slot, IRType AllocTy, IRType ValueTy) override |
Dereference the pointer stored in Slot, then load the pointee. | |
| void | storeToPointee (IRValue *Slot, IRType AllocTy, IRValue *Val) override |
Dereference the pointer stored in Slot, then store Val to it. | |
| VarAlloc | allocScalar (const std::string &Name, IRType ValueTy) override |
| VarAlloc | allocPointer (const std::string &Name, IRType ElemTy, unsigned AddrSpace=0) override |
| VarAlloc | allocArray (const std::string &Name, AddressSpace AS, IRType ElemTy, size_t NElem) override |
Public Member Functions inherited from proteus::CodeBuilder | |
| virtual | ~CodeBuilder ()=default |
LLVMCodeBuilder encapsulates LLVM IR generation using IRBuilder. It manages insertion points, scopes, and provides methods for creating LLVM IR instructions.
| proteus::LLVMCodeBuilder::LLVMCodeBuilder | ( | std::unique_ptr< llvm::LLVMContext > | Ctx, |
| std::unique_ptr< llvm::Module > | Mod, | ||
| TargetModelType | TM = TargetModelType::HOST |
||
| ) |
Construct as owner of LLVMContext and Module.
|
overridedefault |
|
delete |
|
overridevirtual |
Create a function with the given name and signature. Returns an opaque IRFunction handle owned by this builder.
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
|
overridevirtual |
IterSlot : alloca holding the loop iterator. IterTy : value type of the iterator (must be an integer type). InitVal : initial value to store into IterSlot. UpperBoundVal : exclusive upper bound for the loop condition. IncVal : increment added to the iterator on each iteration. IsSigned : true → ICmpSLT, false → ICmpULT.
Implements proteus::CodeBuilder.
|
overridevirtual |
Set F as the active function and begin IR emission.
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
|
overridevirtual |
CondFn : callable that emits the condition IR at the current insert point and returns the resulting i1 Value (true → continue loop).
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
| BasicBlock * proteus::LLVMCodeBuilder::createBasicBlock | ( | const std::string & | Name = "", |
| llvm::BasicBlock * | InsertBefore = nullptr |
||
| ) |
Implements proteus::CodeBuilder.
| void proteus::LLVMCodeBuilder::createBr | ( | llvm::BasicBlock * | Dest | ) |
|
overridevirtual |
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
| void proteus::LLVMCodeBuilder::createCondBr | ( | IRValue * | Cond, |
| llvm::BasicBlock * | True, | ||
| llvm::BasicBlock * | False | ||
| ) |
|
overridevirtual |
Implements proteus::CodeBuilder.
Implements proteus::CodeBuilder.
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
Implements proteus::CodeBuilder.
Implements proteus::CodeBuilder.
Implements proteus::CodeBuilder.
| IRValue * proteus::LLVMCodeBuilder::emitAlloca | ( | llvm::Type * | Ty, |
| const std::string & | Name, | ||
| AddressSpace | AS = AddressSpace::DEFAULT |
||
| ) |
| IRValue * proteus::LLVMCodeBuilder::emitArrayCreate | ( | llvm::Type * | Ty, |
| AddressSpace | AT, | ||
| const std::string & | Name | ||
| ) |
|
overridevirtual |
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
| void proteus::LLVMCodeBuilder::eraseTerminator | ( | llvm::BasicBlock * | BB | ) |
| unsigned proteus::LLVMCodeBuilder::getAddressSpace | ( | llvm::Type * | Ty | ) |
|
overridevirtual |
Return the Nth argument of F as an IRValue.
Implements proteus::CodeBuilder.
Implements proteus::CodeBuilder.
Implements proteus::CodeBuilder.
| LLVMContext & proteus::LLVMCodeBuilder::getContext | ( | ) |
|
overridevirtual |
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
| Type * proteus::LLVMCodeBuilder::getFloatTy | ( | ) |
| Function & proteus::LLVMCodeBuilder::getFunction | ( | ) |
| Type * proteus::LLVMCodeBuilder::getInt16Ty | ( | ) |
| Type * proteus::LLVMCodeBuilder::getInt32Ty | ( | ) |
| Type * proteus::LLVMCodeBuilder::getInt64Ty | ( | ) |
| IRBuilderBase & proteus::LLVMCodeBuilder::getIRBuilder | ( | ) |
Get the underlying IRBuilderBase (internal use only).
| Module & proteus::LLVMCodeBuilder::getModule | ( | ) |
| Type * proteus::LLVMCodeBuilder::getPointerType | ( | llvm::Type * | ElemTy, |
| unsigned | AS | ||
| ) |
| Type * proteus::LLVMCodeBuilder::getPointerTypeUnqual | ( | llvm::Type * | ElemTy | ) |
|
inlineoverridevirtual |
Implements proteus::CodeBuilder.
| BasicBlock * proteus::LLVMCodeBuilder::getUniqueSuccessor | ( | llvm::BasicBlock * | BB | ) |
| bool proteus::LLVMCodeBuilder::isFloatingPointTy | ( | llvm::Type * | Ty | ) |
| bool proteus::LLVMCodeBuilder::isIntegerTy | ( | llvm::Type * | Ty | ) |
Load the pointer stored in Slot (pointer alloca).
Implements proteus::CodeBuilder.
|
overridevirtual |
Dereference the pointer stored in Slot, then load the pointee.
Implements proteus::CodeBuilder.
Load the value stored directly in Slot (scalar alloca).
Implements proteus::CodeBuilder.
|
delete |
| void proteus::LLVMCodeBuilder::pushScope | ( | const char * | File, |
| int | Line, | ||
| ScopeKind | Kind, | ||
| llvm::BasicBlock * | NextBlock | ||
| ) |
|
overridevirtual |
Rename the function identified by F.
Implements proteus::CodeBuilder.
|
overridevirtual |
Implements proteus::CodeBuilder.
| std::tuple< BasicBlock *, BasicBlock * > proteus::LLVMCodeBuilder::splitCurrentBlock | ( | ) |
Store Addr into Slot (pointer alloca).
Implements proteus::CodeBuilder.
Store Val directly into Slot (scalar alloca).
Implements proteus::CodeBuilder.
|
overridevirtual |
Dereference the pointer stored in Slot, then store Val to it.
Implements proteus::CodeBuilder.
| std::unique_ptr< LLVMContext > proteus::LLVMCodeBuilder::takeLLVMContext | ( | ) |
Transfer ownership of the LLVMContext (leaves internal pointer null).
| std::unique_ptr< Module > proteus::LLVMCodeBuilder::takeModule | ( | ) |
Transfer ownership of the Module (leaves internal pointer null).