|
| 1 | +#ifndef MLIR_CONVERSION_POLYGEISTPASSES |
| 2 | +#define MLIR_CONVERSION_POLYGEISTPASSES |
| 3 | + |
| 4 | +include "mlir/Pass/PassBase.td" |
| 5 | +include "mlir/Rewrite/PassUtil.td" |
| 6 | + |
| 7 | +def ConvertPolygeistToLLVM : Pass<"convert-polygeist-to-llvm", "mlir::ModuleOp"> { |
| 8 | + let summary = "Convert scalar and vector operations from the Standard to the " |
| 9 | + "LLVM dialect"; |
| 10 | + let description = [{ |
| 11 | + Convert standard operations into the LLVM IR dialect operations. |
| 12 | + |
| 13 | + #### Input invariant |
| 14 | + |
| 15 | + - operations including: arithmetic on integers and floats, constants, |
| 16 | + direct calls, returns and branches; |
| 17 | + - no `tensor` types; |
| 18 | + - all `vector` are one-dimensional; |
| 19 | + - all blocks are reachable by following the successors of the first basic |
| 20 | + block; |
| 21 | + |
| 22 | + If other operations are present and their results are required by the LLVM |
| 23 | + IR dialect operations, the pass will fail. Any LLVM IR operations or types |
| 24 | + already present in the IR will be kept as is. |
| 25 | + |
| 26 | + #### Output IR |
| 27 | + |
| 28 | + Functions converted to LLVM IR. Function arguments types are converted |
| 29 | + one-to-one. Function results are converted one-to-one and, in case more than |
| 30 | + 1 value is returned, packed into an LLVM IR struct type. Function calls and |
| 31 | + returns are updated accordingly. Block argument types are updated to use |
| 32 | + LLVM IR types. |
| 33 | + }]; |
| 34 | + let constructor = "mlir::polygeist::createConvertPolygeistToLLVMPass()"; |
| 35 | + let dependentDialects = [ |
| 36 | + "polygeist::PolygeistDialect", |
| 37 | + "func::FuncDialect", |
| 38 | + "LLVM::LLVMDialect", |
| 39 | + "memref::MemRefDialect", |
| 40 | + "gpu::GPUDialect", |
| 41 | + "arith::ArithDialect", |
| 42 | + "cf::ControlFlowDialect", |
| 43 | + "scf::SCFDialect", |
| 44 | + ]; |
| 45 | + let options = [ |
| 46 | + Option<"useBarePtrCallConv", "use-bare-ptr-memref-call-conv", "bool", |
| 47 | + /*default=*/"false", |
| 48 | + "Replace FuncOp's MemRef arguments with bare pointers to the MemRef " |
| 49 | + "element types">, |
| 50 | + Option<"indexBitwidth", "index-bitwidth", "unsigned", |
| 51 | + /*default=kDeriveIndexBitwidthFromDataLayout*/"0", |
| 52 | + "Bitwidth of the index type, 0 to use size of machine word">, |
| 53 | + Option<"dataLayout", "data-layout", "std::string", |
| 54 | + /*default=*/"\"\"", |
| 55 | + "String description (LLVM format) of the data layout that is " |
| 56 | + "expected on the produced module">, |
| 57 | + Option<"useCStyleMemRef", "use-c-style-memref", "bool", |
| 58 | + /*default=*/"true", |
| 59 | + "Use C-style nested-array lowering of memref instead of " |
| 60 | + "the default MLIR descriptor structure"> |
| 61 | + ]; |
| 62 | +} |
| 63 | + |
| 64 | +#endif |
0 commit comments