Skip to content

Commit ce20450

Browse files
committed
Split passes.{h,td}
1 parent 1de885f commit ce20450

File tree

4 files changed

+89
-62
lines changed

4 files changed

+89
-62
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef MLIR_CONVERSION_POLYGEISTPASSES_H_
2+
#define MLIR_CONVERSION_POLYGEISTPASSES_H_
3+
4+
#include "mlir/Conversion/LLVMCommon/LoweringOptions.h"
5+
#include "mlir/Dialect/ControlFlow/IR/ControlFlow.h"
6+
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
7+
#include "mlir/Pass/Pass.h"
8+
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
9+
#include "polygeist/Dialect.h"
10+
#include <memory>
11+
12+
namespace mlir {
13+
class PatternRewriter;
14+
class RewritePatternSet;
15+
class DominanceInfo;
16+
namespace polygeist {
17+
std::unique_ptr<Pass> createConvertPolygeistToLLVMPass();
18+
std::unique_ptr<Pass>
19+
createConvertPolygeistToLLVMPass(const LowerToLLVMOptions &options,
20+
bool useCStyleMemRef, bool onlyGpuModules,
21+
std::string gpuTarget);
22+
}
23+
}
24+
25+
#endif // POLYGEISTPASSES_H_
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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

include/mlir/Dialect/Polygeist/Transforms/Passes.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ std::unique_ptr<Pass> createConvertCudaRTtoGPUPass();
4343
std::unique_ptr<Pass> createConvertCudaRTtoHipRTPass();
4444
std::unique_ptr<Pass> createFixGPUFuncPass();
4545
std::unique_ptr<Pass> createSCFParallelLoopUnrollPass(int unrollFactor = 2);
46-
std::unique_ptr<Pass>
47-
createConvertPolygeistToLLVMPass(const LowerToLLVMOptions &options,
48-
bool useCStyleMemRef, bool onlyGpuModules,
49-
std::string gpuTarget);
50-
std::unique_ptr<Pass> createConvertPolygeistToLLVMPass();
5146
std::unique_ptr<Pass> createForBreakToWhilePass();
5247
std::unique_ptr<Pass>
5348
createConvertParallelToGPUPass1(std::string arch = "sm_60");

include/mlir/Dialect/Polygeist/Transforms/Passes.td

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -225,61 +225,4 @@ def RemoveTrivialUse : Pass<"trivialuse"> {
225225
let constructor = "mlir::polygeist::createRemoveTrivialUsePass()";
226226
}
227227

228-
def ConvertPolygeistToLLVM : Pass<"convert-polygeist-to-llvm", "mlir::ModuleOp"> {
229-
let summary = "Convert scalar and vector operations from the Standard to the "
230-
"LLVM dialect";
231-
let description = [{
232-
Convert standard operations into the LLVM IR dialect operations.
233-
234-
#### Input invariant
235-
236-
- operations including: arithmetic on integers and floats, constants,
237-
direct calls, returns and branches;
238-
- no `tensor` types;
239-
- all `vector` are one-dimensional;
240-
- all blocks are reachable by following the successors of the first basic
241-
block;
242-
243-
If other operations are present and their results are required by the LLVM
244-
IR dialect operations, the pass will fail. Any LLVM IR operations or types
245-
already present in the IR will be kept as is.
246-
247-
#### Output IR
248-
249-
Functions converted to LLVM IR. Function arguments types are converted
250-
one-to-one. Function results are converted one-to-one and, in case more than
251-
1 value is returned, packed into an LLVM IR struct type. Function calls and
252-
returns are updated accordingly. Block argument types are updated to use
253-
LLVM IR types.
254-
}];
255-
let constructor = "mlir::polygeist::createConvertPolygeistToLLVMPass()";
256-
let dependentDialects = [
257-
"polygeist::PolygeistDialect",
258-
"func::FuncDialect",
259-
"LLVM::LLVMDialect",
260-
"memref::MemRefDialect",
261-
"gpu::GPUDialect",
262-
"arith::ArithDialect",
263-
"cf::ControlFlowDialect",
264-
"scf::SCFDialect",
265-
];
266-
let options = [
267-
Option<"useBarePtrCallConv", "use-bare-ptr-memref-call-conv", "bool",
268-
/*default=*/"false",
269-
"Replace FuncOp's MemRef arguments with bare pointers to the MemRef "
270-
"element types">,
271-
Option<"indexBitwidth", "index-bitwidth", "unsigned",
272-
/*default=kDeriveIndexBitwidthFromDataLayout*/"0",
273-
"Bitwidth of the index type, 0 to use size of machine word">,
274-
Option<"dataLayout", "data-layout", "std::string",
275-
/*default=*/"\"\"",
276-
"String description (LLVM format) of the data layout that is "
277-
"expected on the produced module">,
278-
Option<"useCStyleMemRef", "use-c-style-memref", "bool",
279-
/*default=*/"true",
280-
"Use C-style nested-array lowering of memref instead of "
281-
"the default MLIR descriptor structure">
282-
];
283-
}
284-
285228
#endif // POLYGEIST_PASSES

0 commit comments

Comments
 (0)