1#ifndef PROTEUS_FRONTEND_MLIR_CODE_BUILDER_H
2#define PROTEUS_FRONTEND_MLIR_CODE_BUILDER_H
54 const std::vector<IRType> &ArgTys,
55 bool IsKernel =
false)
override;
73 void endIf()
override;
76 const char *File,
int Line,
LoopHints Hints = {})
override;
78 void beginWhile(std::function<IRValue *()> CondFn,
const char *File,
85 IRValue *
createCmp(
CmpOp Op, IRValue *LHS, IRValue *RHS, IRType Ty)
override;
86 IRValue *
createAnd(IRValue *LHS, IRValue *RHS)
override;
87 IRValue *
createOr(IRValue *LHS, IRValue *RHS)
override;
88 IRValue *
createXor(IRValue *LHS, IRValue *RHS)
override;
89 IRValue *
createNot(IRValue *Val)
override;
91 const std::string &Name =
"")
override;
92 void createStore(IRValue *Val, IRValue *Ptr)
override;
94 IRValue *
createZExt(IRValue *V, IRType DestTy)
override;
95 VarAlloc
getElementPtr(IRValue *Base, IRType BaseTy, IRValue *Index,
96 IRType ElemTy)
override;
97 VarAlloc
getElementPtr(IRValue *Base, IRType BaseTy,
size_t Index,
98 IRType ElemTy)
override;
99 IRValue *
createCall(
const std::string &FName, IRType RetTy,
100 const std::vector<IRType> &ArgTys,
101 const std::vector<IRValue *> &
Args)
override;
102 IRValue *
createCall(
const std::string &FName, IRType RetTy)
override;
103 IRValue *
emitIntrinsic(
const std::string &Name, IRType RetTy,
104 const std::vector<IRValue *> &
Args)
override;
105 IRValue *
emitBuiltin(
const std::string &Name, IRType RetTy,
106 const std::vector<IRValue *> &
Args)
override;
107 IRValue *
loadAddress(IRValue *Slot, IRType AllocTy)
override;
108 void storeAddress(IRValue *Slot, IRValue *Addr)
override;
110 IRType ValueTy)
override;
111 void storeToPointee(IRValue *Slot, IRType AllocTy, IRValue *Val)
override;
112 VarAlloc
allocPointer(
const std::string &Name, IRType ElemTy,
113 unsigned AddrSpace = 0)
override;
115 size_t NElem)
override;
117#if defined(PROTEUS_ENABLE_CUDA) || defined(PROTEUS_ENABLE_HIP)
119 int MinBlocksPerSM)
override;
123 void ensureLoweredToLLVM(
int OptLevel = 3,
124 const std::string &TargetTriple =
"",
125 const std::string &Features =
"");
128 std::unique_ptr<Impl> PImpl;
char int void ** Args
Definition CompilerInterfaceHost.cpp:23
Definition CodeBuilder.h:70
Definition IRFunction.h:9
Definition MLIRCodeBuilder.h:21
void setInsertPointAtEntry() override
Definition MLIRCodeBuilder.cpp:526
IRValue * createLoad(IRType Ty, IRValue *Ptr, const std::string &Name="") override
Definition MLIRCodeBuilder.cpp:961
std::unique_ptr< llvm::Module > takeModule()
Definition MLIRCodeBuilder.cpp:329
void printLLVMIR(llvm::raw_ostream &OS)
Definition MLIRCodeBuilder.cpp:299
void createRet(IRValue *V) override
Definition MLIRCodeBuilder.cpp:552
void storeScalar(IRValue *Slot, IRValue *Val) override
Store Val directly into Slot (scalar alloca).
Definition MLIRCodeBuilder.cpp:713
IRValue * createCall(const std::string &FName, IRType RetTy, const std::vector< IRType > &ArgTys, const std::vector< IRValue * > &Args) override
Definition MLIRCodeBuilder.cpp:1135
std::unique_ptr< llvm::LLVMContext > takeContext()
Definition MLIRCodeBuilder.cpp:324
void beginIf(IRValue *Cond, const char *File, int Line) override
Definition MLIRCodeBuilder.cpp:747
void beginFor(IRValue *IterSlot, IRType IterTy, IRValue *InitVal, IRValue *UpperBoundVal, IRValue *IncVal, bool IsSigned, const char *File, int Line, LoopHints Hints={}) override
Definition MLIRCodeBuilder.cpp:776
void storeToPointee(IRValue *Slot, IRType AllocTy, IRValue *Val) override
Dereference the pointer stored in Slot, then store Val to it.
Definition MLIRCodeBuilder.cpp:1676
IRValue * createAnd(IRValue *LHS, IRValue *RHS) override
Definition MLIRCodeBuilder.cpp:928
IRValue * getConstantInt(IRType Ty, uint64_t Val) override
Definition MLIRCodeBuilder.cpp:679
IRValue * getConstantFP(IRType Ty, double Val) override
Definition MLIRCodeBuilder.cpp:687
IRValue * createXor(IRValue *LHS, IRValue *RHS) override
Definition MLIRCodeBuilder.cpp:942
IRValue * createAtomicMax(IRValue *Addr, IRValue *Val) override
Definition MLIRCodeBuilder.cpp:1576
void setDeviceArch(const std::string &Arch)
Definition MLIRCodeBuilder.cpp:334
void endWhile() override
Definition MLIRCodeBuilder.cpp:857
IRValue * createArith(ArithOp Op, IRValue *LHS, IRValue *RHS, IRType Ty) override
Definition MLIRCodeBuilder.cpp:567
IRValue * emitIntrinsic(const std::string &Name, IRType RetTy, const std::vector< IRValue * > &Args) override
Lower a frontend intrinsic name to backend IR.
Definition MLIRCodeBuilder.cpp:1202
VarAlloc allocScalar(const std::string &Name, IRType ValueTy) override
Definition MLIRCodeBuilder.cpp:721
IRValue * createAtomicMin(IRValue *Addr, IRValue *Val) override
Definition MLIRCodeBuilder.cpp:1614
IRValue * loadScalar(IRValue *Slot, IRType ValueTy) override
Load the value stored directly in Slot (scalar alloca).
Definition MLIRCodeBuilder.cpp:704
IRValue * createOr(IRValue *LHS, IRValue *RHS) override
Definition MLIRCodeBuilder.cpp:935
~MLIRCodeBuilder() override
IRValue * createAtomicAdd(IRValue *Addr, IRValue *Val) override
Definition MLIRCodeBuilder.cpp:1506
void clearInsertPoint() override
Definition MLIRCodeBuilder.cpp:535
void print()
Dump the MLIR module to llvm::outs().
Definition MLIRCodeBuilder.cpp:297
MLIRCodeBuilder(const MLIRCodeBuilder &)=delete
void setFunctionName(IRFunction *F, const std::string &Name) override
Rename the function identified by F.
Definition MLIRCodeBuilder.cpp:450
void endIf() override
Definition MLIRCodeBuilder.cpp:765
CodeBuilderKind getBackendKind() const override
Definition MLIRCodeBuilder.h:30
void beginFunction(IRFunction *F, const char *File, int Line) override
Set F as the active function and begin IR emission.
Definition MLIRCodeBuilder.cpp:491
IRValue * createZExt(IRValue *V, IRType DestTy) override
Definition MLIRCodeBuilder.cpp:1064
VarAlloc getElementPtr(IRValue *Base, IRType BaseTy, IRValue *Index, IRType ElemTy) override
Definition MLIRCodeBuilder.cpp:1102
IRValue * createCast(IRValue *V, IRType FromTy, IRType ToTy) override
Definition MLIRCodeBuilder.cpp:627
IRValue * createBitCast(IRValue *V, IRType DestTy) override
Definition MLIRCodeBuilder.cpp:1042
IRFunction * addFunction(const std::string &Name, IRType RetTy, const std::vector< IRType > &ArgTys, bool IsKernel=false) override
Definition MLIRCodeBuilder.cpp:356
VarAlloc allocPointer(const std::string &Name, IRType ElemTy, unsigned AddrSpace=0) override
Definition MLIRCodeBuilder.cpp:1694
IRValue * emitBuiltin(const std::string &Name, IRType RetTy, const std::vector< IRValue * > &Args) override
Definition MLIRCodeBuilder.cpp:1284
void endFunction() override
Definition MLIRCodeBuilder.cpp:506
void createRetVoid() override
Definition MLIRCodeBuilder.cpp:544
IRValue * getArg(IRFunction *F, size_t Idx) override
Return the Nth argument of F as an IRValue.
Definition MLIRCodeBuilder.cpp:469
void createStore(IRValue *Val, IRValue *Ptr) override
Definition MLIRCodeBuilder.cpp:1004
VarAlloc allocArray(const std::string &Name, AddressSpace AS, IRType ElemTy, size_t NElem) override
Definition MLIRCodeBuilder.cpp:1710
void endFor() override
Definition MLIRCodeBuilder.cpp:816
IRValue * createAtomicSub(IRValue *Addr, IRValue *Val) override
Definition MLIRCodeBuilder.cpp:1541
IRValue * createCmp(CmpOp Op, IRValue *LHS, IRValue *RHS, IRType Ty) override
Definition MLIRCodeBuilder.cpp:867
MLIRCodeBuilder & operator=(const MLIRCodeBuilder &)=delete
IRValue * loadAddress(IRValue *Slot, IRType AllocTy) override
Load the pointer stored in Slot (pointer alloca).
Definition MLIRCodeBuilder.cpp:1444
void storeAddress(IRValue *Slot, IRValue *Addr) override
Store Addr into Slot (pointer alloca).
Definition MLIRCodeBuilder.cpp:1458
void beginWhile(std::function< IRValue *()> CondFn, const char *File, int Line) override
Definition MLIRCodeBuilder.cpp:826
IRValue * loadFromPointee(IRValue *Slot, IRType AllocTy, IRType ValueTy) override
Dereference the pointer stored in Slot, then load the pointee.
Definition MLIRCodeBuilder.cpp:1652
TargetModelType getTargetModel() const override
Definition MLIRCodeBuilder.h:29
IRValue * createNot(IRValue *Val) override
Definition MLIRCodeBuilder.cpp:949
Definition CompiledLibrary.h:7
Definition MemoryCache.h:27
AddressSpace
Definition AddressSpace.h:6
TargetModelType
Definition TargetModel.h:8
CodeBuilderKind
Definition CodeBuilder.h:66
ArithOp
Semantic arithmetic operation selector.
Definition CodeBuilder.h:43
CmpOp
Semantic comparison operation selector.
Definition CodeBuilder.h:46
void setLaunchBoundsForKernel(Function &F, int MaxThreadsPerSM, int MinBlocksPerSM=0)
Definition CoreLLVMCUDA.h:87
Definition CodeBuilder.h:21
Definition CodeBuilder.h:29