Proteus
Programmable JIT compilation and optimization for C/C++ using LLVM
Loading...
Searching...
No Matches
Public Member Functions | List of all members
proteus::CodeBuilder Class Referenceabstract

#include <CodeBuilder.h>

Inheritance diagram for proteus::CodeBuilder:
Inheritance graph
[legend]

Public Member Functions

virtual ~CodeBuilder ()=default
 
virtual TargetModelType getTargetModel () const =0
 
virtual IRFunctionaddFunction (const std::string &Name, IRType RetTy, const std::vector< IRType > &ArgTys)=0
 
virtual void setFunctionName (IRFunction *F, const std::string &Name)=0
 Rename the function identified by F.
 
virtual IRValuegetArg (IRFunction *F, size_t Idx)=0
 Return the Nth argument of F as an IRValue.
 
virtual void beginFunction (IRFunction *F, const char *File, int Line)=0
 Set F as the active function and begin IR emission.
 
virtual void endFunction ()=0
 
virtual void setInsertPointAtEntry ()=0
 
virtual void clearInsertPoint ()=0
 
virtual void beginIf (IRValue *Cond, const char *File, int Line)=0
 
virtual void endIf ()=0
 
virtual void beginFor (IRValue *IterSlot, IRType IterTy, IRValue *InitVal, IRValue *UpperBoundVal, IRValue *IncVal, bool IsSigned, const char *File, int Line, LoopHints Hints={})=0
 
virtual void endFor ()=0
 
virtual void beginWhile (std::function< IRValue *()> CondFn, const char *File, int Line)=0
 
virtual void endWhile ()=0
 
virtual void createRetVoid ()=0
 
virtual void createRet (IRValue *V)=0
 
virtual IRValuecreateArith (ArithOp Op, IRValue *LHS, IRValue *RHS, IRType Ty)=0
 
virtual IRValuecreateAtomicAdd (IRValue *Addr, IRValue *Val)=0
 
virtual IRValuecreateAtomicSub (IRValue *Addr, IRValue *Val)=0
 
virtual IRValuecreateAtomicMax (IRValue *Addr, IRValue *Val)=0
 
virtual IRValuecreateAtomicMin (IRValue *Addr, IRValue *Val)=0
 
virtual IRValuecreateCmp (CmpOp Op, IRValue *LHS, IRValue *RHS, IRType Ty)=0
 
virtual IRValuecreateAnd (IRValue *LHS, IRValue *RHS)=0
 
virtual IRValuecreateOr (IRValue *LHS, IRValue *RHS)=0
 
virtual IRValuecreateXor (IRValue *LHS, IRValue *RHS)=0
 
virtual IRValuecreateNot (IRValue *Val)=0
 
virtual IRValuecreateLoad (IRType Ty, IRValue *Ptr, const std::string &Name="")=0
 
virtual void createStore (IRValue *Val, IRValue *Ptr)=0
 
virtual IRValuecreateCast (IRValue *V, IRType FromTy, IRType ToTy)=0
 
virtual IRValuecreateBitCast (IRValue *V, IRType DestTy)=0
 
virtual IRValuecreateZExt (IRValue *V, IRType DestTy)=0
 
virtual IRValuegetConstantInt (IRType Ty, uint64_t Val)=0
 
virtual IRValuegetConstantFP (IRType Ty, double Val)=0
 
virtual VarAlloc getElementPtr (IRValue *Base, IRType BaseTy, IRValue *Index, IRType ElemTy)=0
 
virtual VarAlloc getElementPtr (IRValue *Base, IRType BaseTy, size_t Index, IRType ElemTy)=0
 
virtual IRValuecreateCall (const std::string &FName, IRType RetTy, const std::vector< IRType > &ArgTys, const std::vector< IRValue * > &Args)=0
 
virtual IRValuecreateCall (const std::string &FName, IRType RetTy)=0
 
virtual IRValueloadScalar (IRValue *Slot, IRType ValueTy)=0
 Load the value stored directly in Slot (scalar alloca).
 
virtual void storeScalar (IRValue *Slot, IRValue *Val)=0
 Store Val directly into Slot (scalar alloca).
 
virtual IRValueloadAddress (IRValue *Slot, IRType AllocTy)=0
 Load the pointer stored in Slot (pointer alloca).
 
virtual void storeAddress (IRValue *Slot, IRValue *Addr)=0
 Store Addr into Slot (pointer alloca).
 
virtual IRValueloadFromPointee (IRValue *Slot, IRType AllocTy, IRType ValueTy)=0
 Dereference the pointer stored in Slot, then load the pointee.
 
virtual void storeToPointee (IRValue *Slot, IRType AllocTy, IRValue *Val)=0
 Dereference the pointer stored in Slot, then store Val to it.
 
virtual VarAlloc allocScalar (const std::string &Name, IRType ValueTy)=0
 
virtual VarAlloc allocPointer (const std::string &Name, IRType ElemTy, unsigned AddrSpace=0)=0
 
virtual VarAlloc allocArray (const std::string &Name, AddressSpace AS, IRType ElemTy, size_t NElem)=0
 

Detailed Description

Abstract code-builder interface. The frontend (Var.h, Func.h, LoopNest.h) depends only on this class.

Constructor & Destructor Documentation

◆ ~CodeBuilder()

virtual proteus::CodeBuilder::~CodeBuilder ( )
virtualdefault

Member Function Documentation

◆ addFunction()

virtual IRFunction * proteus::CodeBuilder::addFunction ( const std::string &  Name,
IRType  RetTy,
const std::vector< IRType > &  ArgTys 
)
pure virtual

Create a function with the given name and signature. Returns an opaque IRFunction handle owned by this builder.

Implemented in proteus::LLVMCodeBuilder.

◆ allocArray()

virtual VarAlloc proteus::CodeBuilder::allocArray ( const std::string &  Name,
AddressSpace  AS,
IRType  ElemTy,
size_t  NElem 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ allocPointer()

virtual VarAlloc proteus::CodeBuilder::allocPointer ( const std::string &  Name,
IRType  ElemTy,
unsigned  AddrSpace = 0 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ allocScalar()

virtual VarAlloc proteus::CodeBuilder::allocScalar ( const std::string &  Name,
IRType  ValueTy 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ beginFor()

virtual void proteus::CodeBuilder::beginFor ( IRValue IterSlot,
IRType  IterTy,
IRValue InitVal,
IRValue UpperBoundVal,
IRValue IncVal,
bool  IsSigned,
const char *  File,
int  Line,
LoopHints  Hints = {} 
)
pure virtual

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.

Implemented in proteus::LLVMCodeBuilder.

◆ beginFunction()

virtual void proteus::CodeBuilder::beginFunction ( IRFunction F,
const char *  File,
int  Line 
)
pure virtual

Set F as the active function and begin IR emission.

Implemented in proteus::LLVMCodeBuilder.

◆ beginIf()

virtual void proteus::CodeBuilder::beginIf ( IRValue Cond,
const char *  File,
int  Line 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ beginWhile()

virtual void proteus::CodeBuilder::beginWhile ( std::function< IRValue *()>  CondFn,
const char *  File,
int  Line 
)
pure virtual

CondFn : callable that emits the condition IR at the current insert point and returns the resulting i1 Value (true → continue loop).

Implemented in proteus::LLVMCodeBuilder.

◆ clearInsertPoint()

virtual void proteus::CodeBuilder::clearInsertPoint ( )
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createAnd()

virtual IRValue * proteus::CodeBuilder::createAnd ( IRValue LHS,
IRValue RHS 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createArith()

virtual IRValue * proteus::CodeBuilder::createArith ( ArithOp  Op,
IRValue LHS,
IRValue RHS,
IRType  Ty 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createAtomicAdd()

virtual IRValue * proteus::CodeBuilder::createAtomicAdd ( IRValue Addr,
IRValue Val 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createAtomicMax()

virtual IRValue * proteus::CodeBuilder::createAtomicMax ( IRValue Addr,
IRValue Val 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createAtomicMin()

virtual IRValue * proteus::CodeBuilder::createAtomicMin ( IRValue Addr,
IRValue Val 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createAtomicSub()

virtual IRValue * proteus::CodeBuilder::createAtomicSub ( IRValue Addr,
IRValue Val 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createBitCast()

virtual IRValue * proteus::CodeBuilder::createBitCast ( IRValue V,
IRType  DestTy 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createCall() [1/2]

virtual IRValue * proteus::CodeBuilder::createCall ( const std::string &  FName,
IRType  RetTy 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createCall() [2/2]

virtual IRValue * proteus::CodeBuilder::createCall ( const std::string &  FName,
IRType  RetTy,
const std::vector< IRType > &  ArgTys,
const std::vector< IRValue * > &  Args 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createCast()

virtual IRValue * proteus::CodeBuilder::createCast ( IRValue V,
IRType  FromTy,
IRType  ToTy 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createCmp()

virtual IRValue * proteus::CodeBuilder::createCmp ( CmpOp  Op,
IRValue LHS,
IRValue RHS,
IRType  Ty 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createLoad()

virtual IRValue * proteus::CodeBuilder::createLoad ( IRType  Ty,
IRValue Ptr,
const std::string &  Name = "" 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createNot()

virtual IRValue * proteus::CodeBuilder::createNot ( IRValue Val)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createOr()

virtual IRValue * proteus::CodeBuilder::createOr ( IRValue LHS,
IRValue RHS 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createRet()

virtual void proteus::CodeBuilder::createRet ( IRValue V)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createRetVoid()

virtual void proteus::CodeBuilder::createRetVoid ( )
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createStore()

virtual void proteus::CodeBuilder::createStore ( IRValue Val,
IRValue Ptr 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createXor()

virtual IRValue * proteus::CodeBuilder::createXor ( IRValue LHS,
IRValue RHS 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ createZExt()

virtual IRValue * proteus::CodeBuilder::createZExt ( IRValue V,
IRType  DestTy 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ endFor()

virtual void proteus::CodeBuilder::endFor ( )
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ endFunction()

virtual void proteus::CodeBuilder::endFunction ( )
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ endIf()

virtual void proteus::CodeBuilder::endIf ( )
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ endWhile()

virtual void proteus::CodeBuilder::endWhile ( )
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ getArg()

virtual IRValue * proteus::CodeBuilder::getArg ( IRFunction F,
size_t  Idx 
)
pure virtual

Return the Nth argument of F as an IRValue.

Implemented in proteus::LLVMCodeBuilder.

◆ getConstantFP()

virtual IRValue * proteus::CodeBuilder::getConstantFP ( IRType  Ty,
double  Val 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ getConstantInt()

virtual IRValue * proteus::CodeBuilder::getConstantInt ( IRType  Ty,
uint64_t  Val 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ getElementPtr() [1/2]

virtual VarAlloc proteus::CodeBuilder::getElementPtr ( IRValue Base,
IRType  BaseTy,
IRValue Index,
IRType  ElemTy 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ getElementPtr() [2/2]

virtual VarAlloc proteus::CodeBuilder::getElementPtr ( IRValue Base,
IRType  BaseTy,
size_t  Index,
IRType  ElemTy 
)
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ getTargetModel()

virtual TargetModelType proteus::CodeBuilder::getTargetModel ( ) const
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ loadAddress()

virtual IRValue * proteus::CodeBuilder::loadAddress ( IRValue Slot,
IRType  AllocTy 
)
pure virtual

Load the pointer stored in Slot (pointer alloca).

Implemented in proteus::LLVMCodeBuilder.

◆ loadFromPointee()

virtual IRValue * proteus::CodeBuilder::loadFromPointee ( IRValue Slot,
IRType  AllocTy,
IRType  ValueTy 
)
pure virtual

Dereference the pointer stored in Slot, then load the pointee.

Implemented in proteus::LLVMCodeBuilder.

◆ loadScalar()

virtual IRValue * proteus::CodeBuilder::loadScalar ( IRValue Slot,
IRType  ValueTy 
)
pure virtual

Load the value stored directly in Slot (scalar alloca).

Implemented in proteus::LLVMCodeBuilder.

◆ setFunctionName()

virtual void proteus::CodeBuilder::setFunctionName ( IRFunction F,
const std::string &  Name 
)
pure virtual

Rename the function identified by F.

Implemented in proteus::LLVMCodeBuilder.

◆ setInsertPointAtEntry()

virtual void proteus::CodeBuilder::setInsertPointAtEntry ( )
pure virtual

Implemented in proteus::LLVMCodeBuilder.

◆ storeAddress()

virtual void proteus::CodeBuilder::storeAddress ( IRValue Slot,
IRValue Addr 
)
pure virtual

Store Addr into Slot (pointer alloca).

Implemented in proteus::LLVMCodeBuilder.

◆ storeScalar()

virtual void proteus::CodeBuilder::storeScalar ( IRValue Slot,
IRValue Val 
)
pure virtual

Store Val directly into Slot (scalar alloca).

Implemented in proteus::LLVMCodeBuilder.

◆ storeToPointee()

virtual void proteus::CodeBuilder::storeToPointee ( IRValue Slot,
IRType  AllocTy,
IRValue Val 
)
pure virtual

Dereference the pointer stored in Slot, then store Val to it.

Implemented in proteus::LLVMCodeBuilder.


The documentation for this class was generated from the following file: