This addresses a TODO in BuiltinOps.h.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D118574
namespace mlir {
class MLIRContext;
-class OwningModuleRef;
+template <typename OpTy>
+class OwningOpRef;
+class ModuleOp;
} // namespace mlir
namespace toy {
/// Emit IR for the given Toy moduleAST, returns a newly created MLIR module
/// or nullptr on failure.
-mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, ModuleAST &moduleAST);
+mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
+ ModuleAST &moduleAST);
} // namespace toy
#endif // TOY_MLIRGEN_H
namespace toy {
// The public API for codegen.
-mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context,
- ModuleAST &moduleAST) {
+mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
+ ModuleAST &moduleAST) {
return MLIRGenImpl(context).mlirGen(moduleAST);
}
auto moduleAST = parseInputFile(inputFilename);
if (!moduleAST)
return 6;
- mlir::OwningModuleRef module = mlirGen(context, *moduleAST);
+ mlir::OwningOpRef<mlir::ModuleOp> module = mlirGen(context, *moduleAST);
if (!module)
return 1;
// Parse the input mlir.
llvm::SourceMgr sourceMgr;
sourceMgr.AddNewSourceBuffer(std::move(*fileOrErr), llvm::SMLoc());
- mlir::OwningModuleRef module = mlir::parseSourceFile(sourceMgr, &context);
+ mlir::OwningOpRef<mlir::ModuleOp> module =
+ mlir::parseSourceFile(sourceMgr, &context);
if (!module) {
llvm::errs() << "Error can't load file " << inputFilename << "\n";
return 3;
namespace mlir {
class MLIRContext;
-class OwningModuleRef;
+template <typename OpTy>
+class OwningOpRef;
+class ModuleOp;
} // namespace mlir
namespace toy {
/// Emit IR for the given Toy moduleAST, returns a newly created MLIR module
/// or nullptr on failure.
-mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, ModuleAST &moduleAST);
+mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
+ ModuleAST &moduleAST);
} // namespace toy
#endif // TOY_MLIRGEN_H
namespace toy {
// The public API for codegen.
-mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context,
- ModuleAST &moduleAST) {
+mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
+ ModuleAST &moduleAST) {
return MLIRGenImpl(context).mlirGen(moduleAST);
}
}
int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
- mlir::OwningModuleRef &module) {
+ mlir::OwningOpRef<mlir::ModuleOp> &module) {
// Handle '.toy' input to the compiler.
if (inputType != InputType::MLIR &&
!llvm::StringRef(inputFilename).endswith(".mlir")) {
// Load our Dialect in this MLIR Context.
context.getOrLoadDialect<mlir::toy::ToyDialect>();
- mlir::OwningModuleRef module;
+ mlir::OwningOpRef<mlir::ModuleOp> module;
llvm::SourceMgr sourceMgr;
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);
if (int error = loadMLIR(sourceMgr, context, module))
namespace mlir {
class MLIRContext;
-class OwningModuleRef;
+template <typename OpTy>
+class OwningOpRef;
+class ModuleOp;
} // namespace mlir
namespace toy {
/// Emit IR for the given Toy moduleAST, returns a newly created MLIR module
/// or nullptr on failure.
-mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, ModuleAST &moduleAST);
+mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
+ ModuleAST &moduleAST);
} // namespace toy
#endif // TOY_MLIRGEN_H
namespace toy {
// The public API for codegen.
-mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context,
- ModuleAST &moduleAST) {
+mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
+ ModuleAST &moduleAST) {
return MLIRGenImpl(context).mlirGen(moduleAST);
}
}
int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
- mlir::OwningModuleRef &module) {
+ mlir::OwningOpRef<mlir::ModuleOp> &module) {
// Handle '.toy' input to the compiler.
if (inputType != InputType::MLIR &&
!llvm::StringRef(inputFilename).endswith(".mlir")) {
// Load our Dialect in this MLIR Context.
context.getOrLoadDialect<mlir::toy::ToyDialect>();
- mlir::OwningModuleRef module;
+ mlir::OwningOpRef<mlir::ModuleOp> module;
llvm::SourceMgr sourceMgr;
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);
if (int error = loadMLIR(sourceMgr, context, module))
namespace mlir {
class MLIRContext;
-class OwningModuleRef;
+template <typename OpTy>
+class OwningOpRef;
+class ModuleOp;
} // namespace mlir
namespace toy {
/// Emit IR for the given Toy moduleAST, returns a newly created MLIR module
/// or nullptr on failure.
-mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, ModuleAST &moduleAST);
+mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
+ ModuleAST &moduleAST);
} // namespace toy
#endif // TOY_MLIRGEN_H
namespace toy {
// The public API for codegen.
-mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context,
- ModuleAST &moduleAST) {
+mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
+ ModuleAST &moduleAST) {
return MLIRGenImpl(context).mlirGen(moduleAST);
}
}
int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
- mlir::OwningModuleRef &module) {
+ mlir::OwningOpRef<mlir::ModuleOp> &module) {
// Handle '.toy' input to the compiler.
if (inputType != InputType::MLIR &&
!llvm::StringRef(inputFilename).endswith(".mlir")) {
// Load our Dialect in this MLIR Context.
context.getOrLoadDialect<mlir::toy::ToyDialect>();
- mlir::OwningModuleRef module;
+ mlir::OwningOpRef<mlir::ModuleOp> module;
llvm::SourceMgr sourceMgr;
mlir::SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);
if (int error = loadMLIR(sourceMgr, context, module))
namespace mlir {
class MLIRContext;
-class OwningModuleRef;
+template <typename OpTy>
+class OwningOpRef;
+class ModuleOp;
} // namespace mlir
namespace toy {
/// Emit IR for the given Toy moduleAST, returns a newly created MLIR module
/// or nullptr on failure.
-mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, ModuleAST &moduleAST);
+mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
+ ModuleAST &moduleAST);
} // namespace toy
#endif // TOY_MLIRGEN_H
namespace toy {
// The public API for codegen.
-mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context,
- ModuleAST &moduleAST) {
+mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
+ ModuleAST &moduleAST) {
return MLIRGenImpl(context).mlirGen(moduleAST);
}
return parser.parseModule();
}
-int loadMLIR(mlir::MLIRContext &context, mlir::OwningModuleRef &module) {
+int loadMLIR(mlir::MLIRContext &context,
+ mlir::OwningOpRef<mlir::ModuleOp> &module) {
// Handle '.toy' input to the compiler.
if (inputType != InputType::MLIR &&
!llvm::StringRef(inputFilename).endswith(".mlir")) {
}
int loadAndProcessMLIR(mlir::MLIRContext &context,
- mlir::OwningModuleRef &module) {
+ mlir::OwningOpRef<mlir::ModuleOp> &module) {
if (int error = loadMLIR(context, module))
return error;
// Load our Dialect in this MLIR Context.
context.getOrLoadDialect<mlir::toy::ToyDialect>();
- mlir::OwningModuleRef module;
+ mlir::OwningOpRef<mlir::ModuleOp> module;
if (int error = loadAndProcessMLIR(context, module))
return error;
namespace mlir {
class MLIRContext;
-class OwningModuleRef;
+template <typename OpTy>
+class OwningOpRef;
+class ModuleOp;
} // namespace mlir
namespace toy {
/// Emit IR for the given Toy moduleAST, returns a newly created MLIR module
/// or nullptr on failure.
-mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context, ModuleAST &moduleAST);
+mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
+ ModuleAST &moduleAST);
} // namespace toy
#endif // TOY_MLIRGEN_H
namespace toy {
// The public API for codegen.
-mlir::OwningModuleRef mlirGen(mlir::MLIRContext &context,
- ModuleAST &moduleAST) {
+mlir::OwningOpRef<mlir::ModuleOp> mlirGen(mlir::MLIRContext &context,
+ ModuleAST &moduleAST) {
return MLIRGenImpl(context).mlirGen(moduleAST);
}
return parser.parseModule();
}
-int loadMLIR(mlir::MLIRContext &context, mlir::OwningModuleRef &module) {
+int loadMLIR(mlir::MLIRContext &context,
+ mlir::OwningOpRef<mlir::ModuleOp> &module) {
// Handle '.toy' input to the compiler.
if (inputType != InputType::MLIR &&
!llvm::StringRef(inputFilename).endswith(".mlir")) {
}
int loadAndProcessMLIR(mlir::MLIRContext &context,
- mlir::OwningModuleRef &module) {
+ mlir::OwningOpRef<mlir::ModuleOp> &module) {
if (int error = loadMLIR(context, module))
return error;
// Load our Dialect in this MLIR Context.
context.getOrLoadDialect<mlir::toy::ToyDialect>();
- mlir::OwningModuleRef module;
+ mlir::OwningOpRef<mlir::ModuleOp> module;
if (int error = loadAndProcessMLIR(context, module))
return error;
#define GET_OP_CLASSES
#include "mlir/IR/BuiltinOps.h.inc"
-//===----------------------------------------------------------------------===//
-// Dialect Utilities
-//===----------------------------------------------------------------------===//
-
-namespace mlir {
-/// This class acts as an owning reference to a module, and will automatically
-/// destroy the held module on destruction if the held module is valid.
-// TODO: Remove this class in favor of using OwningOpRef directly.
-class OwningModuleRef : public OwningOpRef<ModuleOp> {
-public:
- using OwningOpRef<ModuleOp>::OwningOpRef;
- OwningModuleRef() = default;
- OwningModuleRef(OwningOpRef<ModuleOp> &&other)
- : OwningOpRef<ModuleOp>(std::move(other)) {}
-};
-} // namespace mlir
-
namespace llvm {
/// Allow stealing the low bits of FuncOp.
template <>
PDLPatternModule() = default;
/// Construct a PDL pattern with the given module.
- PDLPatternModule(OwningModuleRef pdlModule)
+ PDLPatternModule(OwningOpRef<ModuleOp> pdlModule)
: pdlModule(std::move(pdlModule)) {}
/// Merge the state in `other` into this pattern module.
private:
/// The module containing the `pdl.pattern` operations.
- OwningModuleRef pdlModule;
+ OwningOpRef<ModuleOp> pdlModule;
/// The external functions referenced from within the PDL module.
llvm::StringMap<PDLConstraintFunction> constraintFunctions;
/// TODO: These methods are deprecated in favor of the above template versions.
/// They should be removed when usages have been updated.
-inline OwningModuleRef parseSourceFile(const llvm::SourceMgr &sourceMgr,
- MLIRContext *context) {
+inline OwningOpRef<ModuleOp> parseSourceFile(const llvm::SourceMgr &sourceMgr,
+ MLIRContext *context) {
return parseSourceFile<ModuleOp>(sourceMgr, context);
}
-inline OwningModuleRef parseSourceFile(llvm::StringRef filename,
- MLIRContext *context) {
+inline OwningOpRef<ModuleOp> parseSourceFile(llvm::StringRef filename,
+ MLIRContext *context) {
return parseSourceFile<ModuleOp>(filename, context);
}
-inline OwningModuleRef parseSourceFile(llvm::StringRef filename,
- llvm::SourceMgr &sourceMgr,
- MLIRContext *context) {
+inline OwningOpRef<ModuleOp> parseSourceFile(llvm::StringRef filename,
+ llvm::SourceMgr &sourceMgr,
+ MLIRContext *context) {
return parseSourceFile<ModuleOp>(filename, sourceMgr, context);
}
-inline OwningModuleRef parseSourceString(llvm::StringRef moduleStr,
- MLIRContext *context) {
+inline OwningOpRef<ModuleOp> parseSourceString(llvm::StringRef moduleStr,
+ MLIRContext *context) {
return parseSourceString<ModuleOp>(moduleStr, context);
}
namespace mlir {
class DialectRegistry;
-class OwningModuleRef;
+
class MLIRContext;
/// Convert the given LLVM module into MLIR's LLVM dialect. The LLVM context is
/// extracted from the registered LLVM IR dialect. In case of error, report it
/// to the error handler registered with the MLIR context, if any (obtained from
/// the MLIR module), and return `{}`.
-OwningModuleRef
+OwningOpRef<ModuleOp>
translateLLVMIRToModule(std::unique_ptr<llvm::Module> llvmModule,
MLIRContext *context);
struct LogicalResult;
class MLIRContext;
class ModuleOp;
-class OwningModuleRef;
+template <typename OpTy>
+class OwningOpRef;
/// Interface of the function that translates the sources managed by `sourceMgr`
/// to MLIR. The source manager has at least one buffer. The implementation
/// should create a new MLIR ModuleOp in the given context and return a pointer
/// to it, or a nullptr in case of any error.
-using TranslateSourceMgrToMLIRFunction =
- std::function<OwningModuleRef(llvm::SourceMgr &sourceMgr, MLIRContext *)>;
+using TranslateSourceMgrToMLIRFunction = std::function<OwningOpRef<ModuleOp>(
+ llvm::SourceMgr &sourceMgr, MLIRContext *)>;
/// Interface of the function that translates the given string to MLIR. The
/// implementation should create a new MLIR ModuleOp in the given context. If
/// source-related error reporting is required from within the function, use
/// TranslateSourceMgrToMLIRFunction instead.
using TranslateStringRefToMLIRFunction =
- std::function<OwningModuleRef(llvm::StringRef, MLIRContext *)>;
+ std::function<OwningOpRef<ModuleOp>(llvm::StringRef, MLIRContext *)>;
/// Interface of the function that translates MLIR to a different format and
/// outputs the result to a stream. It is allowed to modify the module.
}
MlirModule mlirModuleCreateParse(MlirContext context, MlirStringRef module) {
- OwningModuleRef owning = parseSourceString(unwrap(module), unwrap(context));
+ OwningOpRef<ModuleOp> owning =
+ parseSourceString(unwrap(module), unwrap(context));
if (!owning)
return MlirModule{nullptr};
return MlirModule{owning.release().getOperation()};
}
void mlirModuleDestroy(MlirModule module) {
- // Transfer ownership to an OwningModuleRef so that its destructor is called.
- OwningModuleRef(unwrap(module));
+ // Transfer ownership to an OwningOpRef<ModuleOp> so that its destructor is
+ // called.
+ OwningOpRef<ModuleOp>(unwrap(module));
}
MlirOperation mlirModuleGetOperation(MlirModule module) {
} // namespace
-static OwningModuleRef parseMLIRInput(StringRef inputFilename,
- MLIRContext *context) {
+static OwningOpRef<ModuleOp> parseMLIRInput(StringRef inputFilename,
+ MLIRContext *context) {
// Set up the input file.
std::string errorMessage;
auto file = openInputFile(inputFilename, &errorMessage);
llvm::SourceMgr sourceMgr;
sourceMgr.AddNewSourceBuffer(std::move(file), SMLoc());
- return OwningModuleRef(parseSourceFile(sourceMgr, context));
+ return OwningOpRef<ModuleOp>(parseSourceFile(sourceMgr, context));
}
static inline Error makeStringError(const Twine &message) {
// Parse the input file and reset the context threading state.
TimingScope parserTiming = timing.nest("Parser");
- OwningModuleRef module(parseSourceFile(sourceMgr, context));
+ OwningOpRef<ModuleOp> module(parseSourceFile(sourceMgr, context));
context->enableMultithreading(wasThreadingEnabled);
if (!module)
return failure();
return success();
}
-OwningModuleRef
+OwningOpRef<ModuleOp>
mlir::translateLLVMIRToModule(std::unique_ptr<llvm::Module> llvmModule,
MLIRContext *context) {
context->loadDialect<LLVMDialect>();
- OwningModuleRef module(ModuleOp::create(
+ OwningOpRef<ModuleOp> module(ModuleOp::create(
FileLineColLoc::get(context, "", /*line=*/0, /*column=*/0)));
Importer deserializer(context, module.get());
// Deserializes the LLVM bitcode stored in `input` into an MLIR module in the
// LLVM dialect.
-OwningModuleRef translateLLVMIRToModule(llvm::SourceMgr &sourceMgr,
- MLIRContext *context) {
+OwningOpRef<ModuleOp> translateLLVMIRToModule(llvm::SourceMgr &sourceMgr,
+ MLIRContext *context) {
llvm::SMDiagnostic err;
llvm::LLVMContext llvmContext;
std::unique_ptr<llvm::Module> llvmModule = llvm::parseIR(
// Deserializes the SPIR-V binary module stored in the file named as
// `inputFilename` and returns a module containing the SPIR-V module.
-static OwningModuleRef deserializeModule(const llvm::MemoryBuffer *input,
- MLIRContext *context) {
+static OwningOpRef<ModuleOp> deserializeModule(const llvm::MemoryBuffer *input,
+ MLIRContext *context) {
context->loadDialect<spirv::SPIRVDialect>();
// Make sure the input stream can be treated as a stream of SPIR-V words
if (!spirvModule)
return {};
- OwningModuleRef module(ModuleOp::create(FileLineColLoc::get(
+ OwningOpRef<ModuleOp> module(ModuleOp::create(FileLineColLoc::get(
context, input->getBufferIdentifier(), /*line=*/0, /*column=*/0)));
module->getBody()->push_front(spirvModule.release());
return failure();
// Wrap around in a new MLIR module.
- OwningModuleRef dstModule(ModuleOp::create(
+ OwningOpRef<ModuleOp> dstModule(ModuleOp::create(
FileLineColLoc::get(&deserializationContext,
/*filename=*/"", /*line=*/0, /*column=*/0)));
dstModule->getBody()->push_front(spirvModule.release());
StringRef name, const TranslateSourceMgrToMLIRFunction &function) {
auto wrappedFn = [function](llvm::SourceMgr &sourceMgr, raw_ostream &output,
MLIRContext *context) {
- OwningModuleRef module = function(sourceMgr, context);
+ OwningOpRef<ModuleOp> module = function(sourceMgr, context);
if (!module || failed(verify(*module)))
return failure();
module->print(output);
DialectRegistry registry;
dialectRegistration(registry);
context->appendDialectRegistry(registry);
- auto module = OwningModuleRef(parseSourceFile(sourceMgr, context));
+ auto module = OwningOpRef<ModuleOp>(parseSourceFile(sourceMgr, context));
if (!module || failed(verify(*module)))
return failure();
return function(module.get(), output);
registerAllDialects(registry);
registerLLVMDialectTranslation(registry);
MLIRContext context(registry);
- OwningModuleRef module = parseSourceString(moduleStr, &context);
+ OwningOpRef<ModuleOp> module = parseSourceString(moduleStr, &context);
ASSERT_TRUE(!!module);
ASSERT_TRUE(succeeded(lowerToLLVMDialect(*module)));
auto jitOrError = ExecutionEngine::create(*module);
registerAllDialects(registry);
registerLLVMDialectTranslation(registry);
MLIRContext context(registry);
- OwningModuleRef module = parseSourceString(moduleStr, &context);
+ OwningOpRef<ModuleOp> module = parseSourceString(moduleStr, &context);
ASSERT_TRUE(!!module);
ASSERT_TRUE(succeeded(lowerToLLVMDialect(*module)));
auto jitOrError = ExecutionEngine::create(*module);
registerAllDialects(registry);
registerLLVMDialectTranslation(registry);
MLIRContext context(registry);
- OwningModuleRef module = parseSourceString(moduleStr, &context);
+ OwningOpRef<ModuleOp> module = parseSourceString(moduleStr, &context);
ASSERT_TRUE(!!module);
ASSERT_TRUE(succeeded(lowerToLLVMDialect(*module)));
auto jitOrError = ExecutionEngine::create(*module);
registry.insert<CFTestDialect>();
MLIRContext ctx(registry);
- OwningModuleRef module = parseSourceString(ir, &ctx);
+ OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
Operation *testOp = &module->getBody()->getOperations().front();
Operation *op1 = &testOp->getRegion(0).front().front();
Operation *op2 = &testOp->getRegion(1).front().front();
registry.insert<CFTestDialect>();
MLIRContext ctx(registry);
- OwningModuleRef module = parseSourceString(ir, &ctx);
+ OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
Operation *testOp = &module->getBody()->getOperations().front();
Operation *op1 = &testOp->getRegion(0).front().front();
Operation *op2 = &testOp->getRegion(1).front().front();
registry.insert<CFTestDialect>();
MLIRContext ctx(registry);
- OwningModuleRef module = parseSourceString(ir, &ctx);
+ OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
Operation *testOp = &module->getBody()->getOperations().front();
Operation *op1 =
&testOp->getRegion(0).front().front().getRegion(0).front().front();
registry.insert<DLTIDialect, DLTestDialect>();
MLIRContext ctx(registry);
- OwningModuleRef module = parseSourceString(ir, &ctx);
+ OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
DataLayout layout(module.get());
EXPECT_EQ(layout.getTypeSize(IntegerType::get(&ctx, 42)), 6u);
EXPECT_EQ(layout.getTypeSize(Float16Type::get(&ctx)), 2u);
registry.insert<DLTIDialect, DLTestDialect>();
MLIRContext ctx(registry);
- OwningModuleRef module = parseSourceString(ir, &ctx);
+ OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
auto op =
cast<DataLayoutOpInterface>(module->getBody()->getOperations().front());
DataLayout layout(op);
registry.insert<DLTIDialect, DLTestDialect>();
MLIRContext ctx(registry);
- OwningModuleRef module = parseSourceString(ir, &ctx);
+ OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
auto op =
cast<DataLayoutOpInterface>(module->getBody()->getOperations().front());
DataLayout layout(op);
registry.insert<DLTIDialect, DLTestDialect>();
MLIRContext ctx(registry);
- OwningModuleRef module = parseSourceString(ir, &ctx);
+ OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
auto op =
cast<DataLayoutOpInterface>(module->getBody()->getOperations().front());
DataLayout layout(op);
registry.insert<DLTIDialect, DLTestDialect>();
MLIRContext ctx(registry);
- OwningModuleRef module = parseSourceString(ir, &ctx);
+ OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
auto op =
cast<DataLayoutOpInterface>(module->getBody()->getOperations().front());
DataLayout layout(op);
registry.insert<DLTIDialect, DLTestDialect>();
MLIRContext ctx(registry);
- OwningModuleRef module = parseSourceString(ir, &ctx);
+ OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
auto op =
cast<DataLayoutOpInterface>(module->getBody()->getOperations().front());
DataLayout layout(op);
registry.insert<DLTIDialect, DLTestDialect>();
MLIRContext ctx(registry);
- OwningModuleRef module = parseSourceString(ir, &ctx);
+ OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
auto op =
cast<DataLayoutOpInterface>(module->getBody()->getOperations().front());
DataLayout layout(op);
registry.insert<DLTIDialect, DLTestDialect>();
MLIRContext ctx(registry);
- OwningModuleRef module = parseSourceString(ir, &ctx);
+ OwningOpRef<ModuleOp> module = parseSourceString(ir, &ctx);
auto op =
cast<DataLayoutOpInterface>(module->getBody()->getOperations().front());
DataLayout layout(op);
DialectRegistry registry;
MLIRContext ctx;
- OwningModuleRef module;
+ OwningOpRef<ModuleOp> module;
FuncOp mapFn;
};
MLIRContext context;
// Test fine grain invalidation of the module analysis manager.
- OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context)));
+ OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr);
AnalysisManager am = mam;
Builder builder(&context);
// Create a function and a module.
- OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context)));
+ OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
FuncOp func1 =
FuncOp::create(builder.getUnknownLoc(), "foo",
builder.getFunctionType(llvm::None, llvm::None));
Builder builder(&context);
// Create a function and a module.
- OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context)));
+ OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
FuncOp func1 =
FuncOp::create(builder.getUnknownLoc(), "foo",
builder.getFunctionType(llvm::None, llvm::None));
Builder builder(&context);
// Create a function and a module.
- OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context)));
+ OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr);
AnalysisManager am = mam;
MLIRContext context;
// Create a module.
- OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context)));
+ OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr);
AnalysisManager am = mam;
MLIRContext context;
// Create a module.
- OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context)));
+ OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr);
AnalysisManager am = mam;
MLIRContext context;
// Create a module.
- OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context)));
+ OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr);
AnalysisManager am = mam;
MLIRContext context;
// Create a module.
- OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context)));
+ OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr);
AnalysisManager am = mam;
Builder builder(&context);
// Create a module with 2 functions.
- OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context)));
+ OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
for (StringRef name : {"secret", "not_secret"}) {
FuncOp func =
FuncOp::create(builder.getUnknownLoc(), name,
context.allowUnregisteredDialects();
// Create a module
- OwningModuleRef module(ModuleOp::create(UnknownLoc::get(&context)));
+ OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
// Add a single "invalid_op" operation
OpBuilder builder(&module->getBodyRegion());
%1 = "test.foo"() {sym_name = "B"} : () -> (f32)
)mlir";
- OwningModuleRef module = mlir::parseSourceString(code, &context);
+ OwningOpRef<ModuleOp> module = mlir::parseSourceString(code, &context);
ASSERT_TRUE(succeeded(mgr.run(*module)));
EXPECT_TRUE(module->lookupSymbol("B"));