Skip to content

Commit d14cf45

Browse files
committed
Separate the Registration from Loading dialects in the Context
This changes the behavior of constructing MLIRContext to no longer load globally registered dialects on construction. Instead Dialects are only loaded explicitly on demand: - the Parser is lazily loading Dialects in the context as it encounters them during parsing. This is the only purpose for registering dialects and not load them in the context. - Passes are expected to declare the dialects they will create entity from (Operations, Attributes, or Types), and the PassManager is loading Dialects into the Context when starting a pipeline. This changes simplifies the configuration of the registration: a compiler only need to load the dialect for the IR it will emit, and the optimizer is self-contained and load the required Dialects. For example in the Toy tutorial, the compiler only needs to load the Toy dialect in the Context, all the others (linalg, affine, std, LLVM, ...) are automatically loaded depending on the optimization pipeline enabled. To adjust to this change, stop using the existing dialect registration: the global registry will be removed soon. 1) For passes, you need to override the method: virtual void getDependentDialects(DialectRegistry &registry) const {} and registery on the provided registry any dialect that this pass can produce. Passes defined in TableGen can provide this list in the dependentDialects list field. 2) For dialects, on construction you can register dependent dialects using the provided MLIRContext: `context.getOrLoadDialect<DialectName>()` This is useful if a dialect may canonicalize or have interfaces involving another dialect. 3) For loading IR, dialect that can be in the input file must be explicitly registered with the context. `MlirOptMain()` is taking an explicit registry for this purpose. See how the standalone-opt.cpp example is setup: mlir::DialectRegistry registry; registry.insert<mlir::standalone::StandaloneDialect>(); registry.insert<mlir::StandardOpsDialect>(); Only operations from these two dialects can be in the input file. To include all of the dialects in MLIR Core, you can populate the registry this way: mlir::registerAllDialects(registry); 4) For `mlir-translate` callback, as well as frontend, Dialects can be loaded in the context before emitting the IR: context.getOrLoadDialect<ToyDialect>() Differential Revision: https://reviews.llvm.org/D85622
1 parent f6de530 commit d14cf45

File tree

95 files changed

+761
-239
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+761
-239
lines changed

mlir/examples/standalone/standalone-opt/standalone-opt.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,16 @@
2424
int main(int argc, char **argv) {
2525
mlir::registerAllDialects();
2626
mlir::registerAllPasses();
27-
28-
mlir::registerDialect<mlir::standalone::StandaloneDialect>();
2927
// TODO: Register standalone passes here.
3028

31-
return failed(mlir::MlirOptMain(argc, argv, "Standalone optimizer driver\n"));
29+
mlir::DialectRegistry registry;
30+
registry.insert<mlir::standalone::StandaloneDialect>();
31+
registry.insert<mlir::StandardOpsDialect>();
32+
// Add the following to include *all* MLIR Core dialects, or selectively
33+
// include what you need like above. You only need to register dialects that
34+
// will be *parsed* by the tool, not the one generated
35+
// registerAllDialects(registry);
36+
37+
return failed(
38+
mlir::MlirOptMain(argc, argv, "Standalone optimizer driver\n", registry));
3239
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// RUN: standalone-opt --show-dialects | FileCheck %s
2-
// CHECK: Registered Dialects:
2+
// CHECK: Available Dialects:
33
// CHECK: standalone

mlir/examples/toy/Ch2/toyc.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,9 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
6868
}
6969

7070
int dumpMLIR() {
71-
// Register our Dialect with MLIR.
72-
mlir::registerDialect<mlir::toy::ToyDialect>();
73-
74-
mlir::MLIRContext context;
71+
mlir::MLIRContext context(/*loadAllDialects=*/false);
72+
// Load our Dialect in this MLIR Context.
73+
context.getOrLoadDialect<mlir::toy::ToyDialect>();
7574

7675
// Handle '.toy' input to the compiler.
7776
if (inputType != InputType::MLIR &&

mlir/examples/toy/Ch3/toyc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
102102
}
103103

104104
int dumpMLIR() {
105-
// Register our Dialect with MLIR.
106-
mlir::registerDialect<mlir::toy::ToyDialect>();
105+
mlir::MLIRContext context(/*loadAllDialects=*/false);
106+
// Load our Dialect in this MLIR Context.
107+
context.getOrLoadDialect<mlir::toy::ToyDialect>();
107108

108-
mlir::MLIRContext context;
109109
mlir::OwningModuleRef module;
110110
llvm::SourceMgr sourceMgr;
111111
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);

mlir/examples/toy/Ch4/toyc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
103103
}
104104

105105
int dumpMLIR() {
106-
// Register our Dialect with MLIR.
107-
mlir::registerDialect<mlir::toy::ToyDialect>();
106+
mlir::MLIRContext context(/*loadAllDialects=*/false);
107+
// Load our Dialect in this MLIR Context.
108+
context.getOrLoadDialect<mlir::toy::ToyDialect>();
108109

109-
mlir::MLIRContext context;
110110
mlir::OwningModuleRef module;
111111
llvm::SourceMgr sourceMgr;
112112
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);

mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ struct TransposeOpLowering : public ConversionPattern {
256256
namespace {
257257
struct ToyToAffineLoweringPass
258258
: public PassWrapper<ToyToAffineLoweringPass, FunctionPass> {
259+
void getDependentDialects(DialectRegistry &registry) const override {
260+
registry.insert<AffineDialect, StandardOpsDialect>();
261+
}
259262
void runOnFunction() final;
260263
};
261264
} // end anonymous namespace.

mlir/examples/toy/Ch5/toyc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
106106
}
107107

108108
int dumpMLIR() {
109-
// Register our Dialect with MLIR.
110-
mlir::registerDialect<mlir::toy::ToyDialect>();
109+
mlir::MLIRContext context(/*loadAllDialects=*/false);
110+
// Load our Dialect in this MLIR Context.
111+
context.getOrLoadDialect<mlir::toy::ToyDialect>();
111112

112-
mlir::MLIRContext context;
113113
mlir::OwningModuleRef module;
114114
llvm::SourceMgr sourceMgr;
115115
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);

mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ struct TransposeOpLowering : public ConversionPattern {
255255
namespace {
256256
struct ToyToAffineLoweringPass
257257
: public PassWrapper<ToyToAffineLoweringPass, FunctionPass> {
258+
void getDependentDialects(DialectRegistry &registry) const override {
259+
registry.insert<AffineDialect, StandardOpsDialect>();
260+
}
258261
void runOnFunction() final;
259262
};
260263
} // end anonymous namespace.

mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ class PrintOpLowering : public ConversionPattern {
159159
namespace {
160160
struct ToyToLLVMLoweringPass
161161
: public PassWrapper<ToyToLLVMLoweringPass, OperationPass<ModuleOp>> {
162+
void getDependentDialects(DialectRegistry &registry) const override {
163+
registry.insert<LLVM::LLVMDialect, scf::SCFDialect>();
164+
}
162165
void runOnOperation() final;
163166
};
164167
} // end anonymous namespace

mlir/examples/toy/Ch6/toyc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,10 @@ int main(int argc, char **argv) {
255255

256256
// If we aren't dumping the AST, then we are compiling with/to MLIR.
257257

258-
// Register our Dialect with MLIR.
259-
mlir::registerDialect<mlir::toy::ToyDialect>();
258+
mlir::MLIRContext context(/*loadAllDialects=*/false);
259+
// Load our Dialect in this MLIR Context.
260+
context.getOrLoadDialect<mlir::toy::ToyDialect>();
260261

261-
mlir::MLIRContext context;
262262
mlir::OwningModuleRef module;
263263
if (int error = loadAndProcessMLIR(context, module))
264264
return error;

mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ struct TransposeOpLowering : public ConversionPattern {
256256
namespace {
257257
struct ToyToAffineLoweringPass
258258
: public PassWrapper<ToyToAffineLoweringPass, FunctionPass> {
259+
void getDependentDialects(DialectRegistry &registry) const override {
260+
registry.insert<AffineDialect, StandardOpsDialect>();
261+
}
259262
void runOnFunction() final;
260263
};
261264
} // end anonymous namespace.

mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ class PrintOpLowering : public ConversionPattern {
159159
namespace {
160160
struct ToyToLLVMLoweringPass
161161
: public PassWrapper<ToyToLLVMLoweringPass, OperationPass<ModuleOp>> {
162+
void getDependentDialects(DialectRegistry &registry) const override {
163+
registry.insert<LLVM::LLVMDialect, scf::SCFDialect>();
164+
}
162165
void runOnOperation() final;
163166
};
164167
} // end anonymous namespace

mlir/examples/toy/Ch7/toyc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,10 @@ int main(int argc, char **argv) {
256256

257257
// If we aren't dumping the AST, then we are compiling with/to MLIR.
258258

259-
// Register our Dialect with MLIR.
260-
mlir::registerDialect<mlir::toy::ToyDialect>();
259+
mlir::MLIRContext context(/*loadAllDialects=*/false);
260+
// Load our Dialect in this MLIR Context.
261+
context.getOrLoadDialect<mlir::toy::ToyDialect>();
261262

262-
mlir::MLIRContext context;
263263
mlir::OwningModuleRef module;
264264
if (int error = loadAndProcessMLIR(context, module))
265265
return error;

mlir/include/mlir-c/Registration.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010
#ifndef MLIR_C_REGISTRATION_H
1111
#define MLIR_C_REGISTRATION_H
1212

13+
#include "mlir-c/IR.h"
14+
1315
#ifdef __cplusplus
1416
extern "C" {
1517
#endif
1618

17-
/** Registers all dialects known to core MLIR with the system. This must be
18-
* called before creating an MlirContext if it needs access to the registered
19-
* dialects. */
20-
void mlirRegisterAllDialects();
19+
/** Registers all dialects known to core MLIR with the provided Context.
20+
* This is needed before creating IR for these Dialects.
21+
*/
22+
void mlirRegisterAllDialects(MlirContext context);
2123

2224
#ifdef __cplusplus
2325
}

mlir/include/mlir/Conversion/Passes.td

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ def ConvertAffineToStandard : Pass<"lower-affine"> {
6666
`affine.apply`.
6767
}];
6868
let constructor = "mlir::createLowerAffinePass()";
69+
let dependentDialects = [
70+
"scf::SCFDialect",
71+
"StandardOpsDialect",
72+
"vector::VectorDialect"
73+
];
6974
}
7075

7176
//===----------------------------------------------------------------------===//
@@ -76,6 +81,7 @@ def ConvertAVX512ToLLVM : Pass<"convert-avx512-to-llvm", "ModuleOp"> {
7681
let summary = "Convert the operations from the avx512 dialect into the LLVM "
7782
"dialect";
7883
let constructor = "mlir::createConvertAVX512ToLLVMPass()";
84+
let dependentDialects = ["LLVM::LLVMDialect", "LLVM::LLVMAVX512Dialect"];
7985
}
8086

8187
//===----------------------------------------------------------------------===//
@@ -98,6 +104,7 @@ def GpuToLLVMConversionPass : Pass<"gpu-to-llvm", "ModuleOp"> {
98104
def ConvertGpuOpsToNVVMOps : Pass<"convert-gpu-to-nvvm", "gpu::GPUModuleOp"> {
99105
let summary = "Generate NVVM operations for gpu operations";
100106
let constructor = "mlir::createLowerGpuOpsToNVVMOpsPass()";
107+
let dependentDialects = ["NVVM::NVVMDialect"];
101108
let options = [
102109
Option<"indexBitwidth", "index-bitwidth", "unsigned",
103110
/*default=kDeriveIndexBitwidthFromDataLayout*/"0",
@@ -112,6 +119,7 @@ def ConvertGpuOpsToNVVMOps : Pass<"convert-gpu-to-nvvm", "gpu::GPUModuleOp"> {
112119
def ConvertGpuOpsToROCDLOps : Pass<"convert-gpu-to-rocdl", "gpu::GPUModuleOp"> {
113120
let summary = "Generate ROCDL operations for gpu operations";
114121
let constructor = "mlir::createLowerGpuOpsToROCDLOpsPass()";
122+
let dependentDialects = ["ROCDL::ROCDLDialect"];
115123
let options = [
116124
Option<"indexBitwidth", "index-bitwidth", "unsigned",
117125
/*default=kDeriveIndexBitwidthFromDataLayout*/"0",
@@ -126,6 +134,7 @@ def ConvertGpuOpsToROCDLOps : Pass<"convert-gpu-to-rocdl", "gpu::GPUModuleOp"> {
126134
def ConvertGPUToSPIRV : Pass<"convert-gpu-to-spirv", "ModuleOp"> {
127135
let summary = "Convert GPU dialect to SPIR-V dialect";
128136
let constructor = "mlir::createConvertGPUToSPIRVPass()";
137+
let dependentDialects = ["spirv::SPIRVDialect"];
129138
}
130139

131140
//===----------------------------------------------------------------------===//
@@ -136,13 +145,15 @@ def ConvertGpuLaunchFuncToVulkanLaunchFunc
136145
: Pass<"convert-gpu-launch-to-vulkan-launch", "ModuleOp"> {
137146
let summary = "Convert gpu.launch_func to vulkanLaunch external call";
138147
let constructor = "mlir::createConvertGpuLaunchFuncToVulkanLaunchFuncPass()";
148+
let dependentDialects = ["spirv::SPIRVDialect"];
139149
}
140150

141151
def ConvertVulkanLaunchFuncToVulkanCalls
142152
: Pass<"launch-func-to-vulkan", "ModuleOp"> {
143153
let summary = "Convert vulkanLaunch external call to Vulkan runtime external "
144154
"calls";
145155
let constructor = "mlir::createConvertVulkanLaunchFuncToVulkanCallsPass()";
156+
let dependentDialects = ["LLVM::LLVMDialect"];
146157
}
147158

148159
//===----------------------------------------------------------------------===//
@@ -153,6 +164,7 @@ def ConvertLinalgToLLVM : Pass<"convert-linalg-to-llvm", "ModuleOp"> {
153164
let summary = "Convert the operations from the linalg dialect into the LLVM "
154165
"dialect";
155166
let constructor = "mlir::createConvertLinalgToLLVMPass()";
167+
let dependentDialects = ["scf::SCFDialect", "LLVM::LLVMDialect"];
156168
}
157169

158170
//===----------------------------------------------------------------------===//
@@ -163,6 +175,7 @@ def ConvertLinalgToStandard : Pass<"convert-linalg-to-std", "ModuleOp"> {
163175
let summary = "Convert the operations from the linalg dialect into the "
164176
"Standard dialect";
165177
let constructor = "mlir::createConvertLinalgToStandardPass()";
178+
let dependentDialects = ["StandardOpsDialect"];
166179
}
167180

168181
//===----------------------------------------------------------------------===//
@@ -172,6 +185,7 @@ def ConvertLinalgToStandard : Pass<"convert-linalg-to-std", "ModuleOp"> {
172185
def ConvertLinalgToSPIRV : Pass<"convert-linalg-to-spirv", "ModuleOp"> {
173186
let summary = "Convert Linalg ops to SPIR-V ops";
174187
let constructor = "mlir::createLinalgToSPIRVPass()";
188+
let dependentDialects = ["spirv::SPIRVDialect"];
175189
}
176190

177191
//===----------------------------------------------------------------------===//
@@ -182,6 +196,7 @@ def SCFToStandard : Pass<"convert-scf-to-std"> {
182196
let summary = "Convert SCF dialect to Standard dialect, replacing structured"
183197
" control flow with a CFG";
184198
let constructor = "mlir::createLowerToCFGPass()";
199+
let dependentDialects = ["StandardOpsDialect"];
185200
}
186201

187202
//===----------------------------------------------------------------------===//
@@ -191,6 +206,7 @@ def SCFToStandard : Pass<"convert-scf-to-std"> {
191206
def ConvertAffineForToGPU : FunctionPass<"convert-affine-for-to-gpu"> {
192207
let summary = "Convert top-level AffineFor Ops to GPU kernels";
193208
let constructor = "mlir::createAffineForToGPUPass()";
209+
let dependentDialects = ["gpu::GPUDialect"];
194210
let options = [
195211
Option<"numBlockDims", "gpu-block-dims", "unsigned", /*default=*/"1u",
196212
"Number of GPU block dimensions for mapping">,
@@ -202,6 +218,7 @@ def ConvertAffineForToGPU : FunctionPass<"convert-affine-for-to-gpu"> {
202218
def ConvertParallelLoopToGpu : Pass<"convert-parallel-loops-to-gpu"> {
203219
let summary = "Convert mapped scf.parallel ops to gpu launch operations";
204220
let constructor = "mlir::createParallelLoopToGpuPass()";
221+
let dependentDialects = ["AffineDialect", "gpu::GPUDialect"];
205222
}
206223

207224
//===----------------------------------------------------------------------===//
@@ -212,6 +229,7 @@ def ConvertShapeToStandard : Pass<"convert-shape-to-std", "ModuleOp"> {
212229
let summary = "Convert operations from the shape dialect into the standard "
213230
"dialect";
214231
let constructor = "mlir::createConvertShapeToStandardPass()";
232+
let dependentDialects = ["StandardOpsDialect"];
215233
}
216234

217235
//===----------------------------------------------------------------------===//
@@ -221,6 +239,7 @@ def ConvertShapeToStandard : Pass<"convert-shape-to-std", "ModuleOp"> {
221239
def ConvertShapeToSCF : FunctionPass<"convert-shape-to-scf"> {
222240
let summary = "Convert operations from the shape dialect to the SCF dialect";
223241
let constructor = "mlir::createConvertShapeToSCFPass()";
242+
let dependentDialects = ["scf::SCFDialect"];
224243
}
225244

226245
//===----------------------------------------------------------------------===//
@@ -230,6 +249,7 @@ def ConvertShapeToSCF : FunctionPass<"convert-shape-to-scf"> {
230249
def ConvertSPIRVToLLVM : Pass<"convert-spirv-to-llvm", "ModuleOp"> {
231250
let summary = "Convert SPIR-V dialect to LLVM dialect";
232251
let constructor = "mlir::createConvertSPIRVToLLVMPass()";
252+
let dependentDialects = ["LLVM::LLVMDialect"];
233253
}
234254

235255
//===----------------------------------------------------------------------===//
@@ -264,6 +284,7 @@ def ConvertStandardToLLVM : Pass<"convert-std-to-llvm", "ModuleOp"> {
264284
LLVM IR types.
265285
}];
266286
let constructor = "mlir::createLowerToLLVMPass()";
287+
let dependentDialects = ["LLVM::LLVMDialect"];
267288
let options = [
268289
Option<"useAlignedAlloc", "use-aligned-alloc", "bool", /*default=*/"false",
269290
"Use aligned_alloc in place of malloc for heap allocations">,
@@ -291,11 +312,13 @@ def ConvertStandardToLLVM : Pass<"convert-std-to-llvm", "ModuleOp"> {
291312
def LegalizeStandardForSPIRV : Pass<"legalize-std-for-spirv"> {
292313
let summary = "Legalize standard ops for SPIR-V lowering";
293314
let constructor = "mlir::createLegalizeStdOpsForSPIRVLoweringPass()";
315+
let dependentDialects = ["spirv::SPIRVDialect"];
294316
}
295317

296318
def ConvertStandardToSPIRV : Pass<"convert-std-to-spirv", "ModuleOp"> {
297319
let summary = "Convert Standard Ops to SPIR-V dialect";
298320
let constructor = "mlir::createConvertStandardToSPIRVPass()";
321+
let dependentDialects = ["spirv::SPIRVDialect"];
299322
}
300323

301324
//===----------------------------------------------------------------------===//
@@ -306,6 +329,7 @@ def ConvertVectorToSCF : FunctionPass<"convert-vector-to-scf"> {
306329
let summary = "Lower the operations from the vector dialect into the SCF "
307330
"dialect";
308331
let constructor = "mlir::createConvertVectorToSCFPass()";
332+
let dependentDialects = ["AffineDialect", "scf::SCFDialect"];
309333
let options = [
310334
Option<"fullUnroll", "full-unroll", "bool", /*default=*/"false",
311335
"Perform full unrolling when converting vector transfers to SCF">,
@@ -320,6 +344,7 @@ def ConvertVectorToLLVM : Pass<"convert-vector-to-llvm", "ModuleOp"> {
320344
let summary = "Lower the operations from the vector dialect into the LLVM "
321345
"dialect";
322346
let constructor = "mlir::createConvertVectorToLLVMPass()";
347+
let dependentDialects = ["LLVM::LLVMDialect"];
323348
let options = [
324349
Option<"reassociateFPReductions", "reassociate-fp-reductions",
325350
"bool", /*default=*/"false",
@@ -335,6 +360,7 @@ def ConvertVectorToROCDL : Pass<"convert-vector-to-rocdl", "ModuleOp"> {
335360
let summary = "Lower the operations from the vector dialect into the ROCDL "
336361
"dialect";
337362
let constructor = "mlir::createConvertVectorToROCDLPass()";
363+
let dependentDialects = ["ROCDL::ROCDLDialect"];
338364
}
339365

340366
#endif // MLIR_CONVERSION_PASSES

mlir/include/mlir/Dialect/Affine/Passes.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def AffineLoopUnrollAndJam : FunctionPass<"affine-loop-unroll-jam"> {
9494
def AffineVectorize : FunctionPass<"affine-super-vectorize"> {
9595
let summary = "Vectorize to a target independent n-D vector abstraction";
9696
let constructor = "mlir::createSuperVectorizePass()";
97+
let dependentDialects = ["vector::VectorDialect"];
9798
let options = [
9899
ListOption<"vectorSizes", "virtual-vector-size", "int64_t",
99100
"Specify an n-D virtual vector size for vectorization",

mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define MLIR_DIALECT_LLVMIR_LLVMDIALECT_H_
1616

1717
#include "mlir/Dialect/LLVMIR/LLVMTypes.h"
18+
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
1819
#include "mlir/IR/Dialect.h"
1920
#include "mlir/IR/Function.h"
2021
#include "mlir/IR/OpDefinition.h"

mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ include "mlir/IR/OpBase.td"
1919
def LLVM_Dialect : Dialect {
2020
let name = "llvm";
2121
let cppNamespace = "LLVM";
22+
23+
/// FIXME: at the moment this is a dependency of the translation to LLVM IR,
24+
/// not really one of this dialect per-se.
25+
let dependentDialects = ["omp::OpenMPDialect"];
26+
2227
let hasRegionArgAttrVerify = 1;
2328
let hasOperationAttrVerify = 1;
2429
let extraClassDeclaration = [{

mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifndef MLIR_DIALECT_LLVMIR_NVVMDIALECT_H_
1515
#define MLIR_DIALECT_LLVMIR_NVVMDIALECT_H_
1616

17+
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
1718
#include "mlir/IR/Dialect.h"
1819
#include "mlir/IR/OpDefinition.h"
1920
#include "mlir/Interfaces/SideEffectInterfaces.h"

0 commit comments

Comments
 (0)