Skip to content

Commit

Permalink
Merged master:25ee851746df into amd-gfx:a35835192b4e
Browse files Browse the repository at this point in the history
Local branch amd-gfx a358351 Merged master:3e7403a1346f into amd-gfx:5f789c6d8d10
Remote branch master 25ee851 Revert "Separate the Registration from Loading dialects in the Context"
  • Loading branch information
Sw authored and Sw committed Aug 15, 2020
2 parents a358351 + 25ee851 commit 55d5ba9
Show file tree
Hide file tree
Showing 91 changed files with 214 additions and 691 deletions.
3 changes: 2 additions & 1 deletion flang/unittests/Lower/OpenMPLoweringTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
class OpenMPLoweringTest : public testing::Test {
protected:
void SetUp() override {
ctx.getOrLoadDialect<mlir::omp::OpenMPDialect>();
mlir::registerDialect<mlir::omp::OpenMPDialect>();
mlir::registerAllDialects(&ctx);
mlirOpBuilder.reset(new mlir::OpBuilder(&ctx));
}

Expand Down
2 changes: 1 addition & 1 deletion mlir/examples/standalone/standalone-opt/standalone-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int main(int argc, char **argv) {
if (showDialects) {
mlir::MLIRContext context;
llvm::outs() << "Registered Dialects:\n";
for (mlir::Dialect *dialect : context.getLoadedDialects()) {
for (mlir::Dialect *dialect : context.getRegisteredDialects()) {
llvm::outs() << dialect->getNamespace() << "\n";
}
return 0;
Expand Down
7 changes: 4 additions & 3 deletions mlir/examples/toy/Ch2/toyc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ std::unique_ptr<toy::ModuleAST> parseInputFile(llvm::StringRef filename) {
}

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

mlir::MLIRContext context;

// Handle '.toy' input to the compiler.
if (inputType != InputType::MLIR &&
Expand Down
6 changes: 3 additions & 3 deletions mlir/examples/toy/Ch3/toyc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
}

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

mlir::MLIRContext context;
mlir::OwningModuleRef module;
llvm::SourceMgr sourceMgr;
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);
Expand Down
6 changes: 3 additions & 3 deletions mlir/examples/toy/Ch4/toyc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
}

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

mlir::MLIRContext context;
mlir::OwningModuleRef module;
llvm::SourceMgr sourceMgr;
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);
Expand Down
4 changes: 0 additions & 4 deletions mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,6 @@ struct TransposeOpLowering : public ConversionPattern {
namespace {
struct ToyToAffineLoweringPass
: public PassWrapper<ToyToAffineLoweringPass, FunctionPass> {
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<AffineDialect>();
registry.insert<StandardOpsDialect>();
}
void runOnFunction() final;
};
} // end anonymous namespace.
Expand Down
6 changes: 3 additions & 3 deletions mlir/examples/toy/Ch5/toyc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
}

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

mlir::MLIRContext context;
mlir::OwningModuleRef module;
llvm::SourceMgr sourceMgr;
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);
Expand Down
4 changes: 0 additions & 4 deletions mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,6 @@ struct TransposeOpLowering : public ConversionPattern {
namespace {
struct ToyToAffineLoweringPass
: public PassWrapper<ToyToAffineLoweringPass, FunctionPass> {
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<AffineDialect>();
registry.insert<StandardOpsDialect>();
}
void runOnFunction() final;
};
} // end anonymous namespace.
Expand Down
4 changes: 0 additions & 4 deletions mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,6 @@ class PrintOpLowering : public ConversionPattern {
namespace {
struct ToyToLLVMLoweringPass
: public PassWrapper<ToyToLLVMLoweringPass, OperationPass<ModuleOp>> {
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<LLVM::LLVMDialect>();
registry.insert<scf::SCFDialect>();
}
void runOnOperation() final;
};
} // end anonymous namespace
Expand Down
6 changes: 3 additions & 3 deletions mlir/examples/toy/Ch6/toyc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ int main(int argc, char **argv) {

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

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

mlir::MLIRContext context;
mlir::OwningModuleRef module;
if (int error = loadAndProcessMLIR(context, module))
return error;
Expand Down
4 changes: 0 additions & 4 deletions mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,6 @@ struct TransposeOpLowering : public ConversionPattern {
namespace {
struct ToyToAffineLoweringPass
: public PassWrapper<ToyToAffineLoweringPass, FunctionPass> {
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<AffineDialect>();
registry.insert<StandardOpsDialect>();
}
void runOnFunction() final;
};
} // end anonymous namespace.
Expand Down
4 changes: 0 additions & 4 deletions mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,6 @@ class PrintOpLowering : public ConversionPattern {
namespace {
struct ToyToLLVMLoweringPass
: public PassWrapper<ToyToLLVMLoweringPass, OperationPass<ModuleOp>> {
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<LLVM::LLVMDialect>();
registry.insert<scf::SCFDialect>();
}
void runOnOperation() final;
};
} // end anonymous namespace
Expand Down
6 changes: 3 additions & 3 deletions mlir/examples/toy/Ch7/toyc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ int main(int argc, char **argv) {

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

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

mlir::MLIRContext context;
mlir::OwningModuleRef module;
if (int error = loadAndProcessMLIR(context, module))
return error;
Expand Down
6 changes: 0 additions & 6 deletions mlir/include/mlir-c/IR.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ MlirContext mlirContextCreate();
/** Takes an MLIR context owned by the caller and destroys it. */
void mlirContextDestroy(MlirContext context);

/** Load all the globally registered dialects in the provided context.
* TODO: remove the concept of globally registered dialect by exposing the
* DialectRegistry.
*/
void mlirContextLoadAllDialects(MlirContext context);

/*============================================================================*/
/* Location API. */
/*============================================================================*/
Expand Down
26 changes: 0 additions & 26 deletions mlir/include/mlir/Conversion/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ def ConvertAffineToStandard : Pass<"lower-affine"> {
`affine.apply`.
}];
let constructor = "mlir::createLowerAffinePass()";
let dependentDialects = [
"scf::SCFDialect",
"StandardOpsDialect",
"vector::VectorDialect"
];
}

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

//===----------------------------------------------------------------------===//
Expand All @@ -104,7 +98,6 @@ def GpuToLLVMConversionPass : Pass<"gpu-to-llvm", "ModuleOp"> {
def ConvertGpuOpsToNVVMOps : Pass<"convert-gpu-to-nvvm", "gpu::GPUModuleOp"> {
let summary = "Generate NVVM operations for gpu operations";
let constructor = "mlir::createLowerGpuOpsToNVVMOpsPass()";
let dependentDialects = ["NVVM::NVVMDialect"];
let options = [
Option<"indexBitwidth", "index-bitwidth", "unsigned",
/*default=kDeriveIndexBitwidthFromDataLayout*/"0",
Expand All @@ -119,7 +112,6 @@ def ConvertGpuOpsToNVVMOps : Pass<"convert-gpu-to-nvvm", "gpu::GPUModuleOp"> {
def ConvertGpuOpsToROCDLOps : Pass<"convert-gpu-to-rocdl", "gpu::GPUModuleOp"> {
let summary = "Generate ROCDL operations for gpu operations";
let constructor = "mlir::createLowerGpuOpsToROCDLOpsPass()";
let dependentDialects = ["ROCDL::ROCDLDialect"];
let options = [
Option<"indexBitwidth", "index-bitwidth", "unsigned",
/*default=kDeriveIndexBitwidthFromDataLayout*/"0",
Expand All @@ -134,7 +126,6 @@ def ConvertGpuOpsToROCDLOps : Pass<"convert-gpu-to-rocdl", "gpu::GPUModuleOp"> {
def ConvertGPUToSPIRV : Pass<"convert-gpu-to-spirv", "ModuleOp"> {
let summary = "Convert GPU dialect to SPIR-V dialect";
let constructor = "mlir::createConvertGPUToSPIRVPass()";
let dependentDialects = ["spirv::SPIRVDialect"];
}

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

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

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

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

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

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

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

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

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

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

//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -284,7 +264,6 @@ def ConvertStandardToLLVM : Pass<"convert-std-to-llvm", "ModuleOp"> {
LLVM IR types.
}];
let constructor = "mlir::createLowerToLLVMPass()";
let dependentDialects = ["LLVM::LLVMDialect"];
let options = [
Option<"useAlignedAlloc", "use-aligned-alloc", "bool", /*default=*/"false",
"Use aligned_alloc in place of malloc for heap allocations">,
Expand All @@ -308,13 +287,11 @@ def ConvertStandardToLLVM : Pass<"convert-std-to-llvm", "ModuleOp"> {
def LegalizeStandardForSPIRV : Pass<"legalize-std-for-spirv"> {
let summary = "Legalize standard ops for SPIR-V lowering";
let constructor = "mlir::createLegalizeStdOpsForSPIRVLoweringPass()";
let dependentDialects = ["spirv::SPIRVDialect"];
}

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

//===----------------------------------------------------------------------===//
Expand All @@ -325,7 +302,6 @@ def ConvertVectorToSCF : FunctionPass<"convert-vector-to-scf"> {
let summary = "Lower the operations from the vector dialect into the SCF "
"dialect";
let constructor = "mlir::createConvertVectorToSCFPass()";
let dependentDialects = ["AffineDialect", "scf::SCFDialect"];
let options = [
Option<"fullUnroll", "full-unroll", "bool", /*default=*/"false",
"Perform full unrolling when converting vector transfers to SCF">,
Expand All @@ -340,7 +316,6 @@ def ConvertVectorToLLVM : Pass<"convert-vector-to-llvm", "ModuleOp"> {
let summary = "Lower the operations from the vector dialect into the LLVM "
"dialect";
let constructor = "mlir::createConvertVectorToLLVMPass()";
let dependentDialects = ["LLVM::LLVMDialect"];
let options = [
Option<"reassociateFPReductions", "reassociate-fp-reductions",
"bool", /*default=*/"false",
Expand All @@ -356,7 +331,6 @@ def ConvertVectorToROCDL : Pass<"convert-vector-to-rocdl", "ModuleOp"> {
let summary = "Lower the operations from the vector dialect into the ROCDL "
"dialect";
let constructor = "mlir::createConvertVectorToROCDLPass()";
let dependentDialects = ["ROCDL::ROCDLDialect"];
}

#endif // MLIR_CONVERSION_PASSES
1 change: 0 additions & 1 deletion mlir/include/mlir/Dialect/Affine/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def AffineLoopUnrollAndJam : FunctionPass<"affine-loop-unroll-jam"> {
def AffineVectorize : FunctionPass<"affine-super-vectorize"> {
let summary = "Vectorize to a target independent n-D vector abstraction";
let constructor = "mlir::createSuperVectorizePass()";
let dependentDialects = ["vector::VectorDialect"];
let options = [
ListOption<"vectorSizes", "virtual-vector-size", "int64_t",
"Specify an n-D virtual vector size for vectorization",
Expand Down
1 change: 0 additions & 1 deletion mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#define MLIR_DIALECT_LLVMIR_LLVMDIALECT_H_

#include "mlir/Dialect/LLVMIR/LLVMTypes.h"
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/Function.h"
#include "mlir/IR/OpDefinition.h"
Expand Down
5 changes: 0 additions & 5 deletions mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ include "mlir/IR/OpBase.td"
def LLVM_Dialect : Dialect {
let name = "llvm";
let cppNamespace = "LLVM";

/// FIXME: at the moment this is a dependency of the translation to LLVM IR,
/// not really one of this dialect per-se.
let dependentDialects = [ "omp::OpenMPDialect" ];

let hasRegionArgAttrVerify = 1;
let extraClassDeclaration = [{
~LLVMDialect();
Expand Down
1 change: 0 additions & 1 deletion mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#ifndef MLIR_DIALECT_LLVMIR_NVVMDIALECT_H_
#define MLIR_DIALECT_LLVMIR_NVVMDIALECT_H_

#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
Expand Down
1 change: 0 additions & 1 deletion mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
def NVVM_Dialect : Dialect {
let name = "nvvm";
let cppNamespace = "NVVM";
let dependentDialects = [ "LLVM::LLVMDialect" ];
}

//===----------------------------------------------------------------------===//
Expand Down
Loading

0 comments on commit 55d5ba9

Please sign in to comment.