/// Trivial C++ wrappers make use of the EDSC C API.
struct PythonMLIRModule {
PythonMLIRModule()
- : mlirContext(), module(mlir::Module::create(&mlirContext)),
+ : mlirContext(),
+ module(mlir::Module::create(mlir::UnknownLoc::get(&mlirContext))),
moduleManager(*module) {}
PythonType makeScalarType(const std::string &mlirElemType,
TEST_FUNC(linalg_ops) {
MLIRContext context;
- OwningModuleRef module = Module::create(&context);
+ OwningModuleRef module = Module::create(UnknownLoc::get(&context));
auto indexType = mlir::IndexType::get(&context);
mlir::FuncOp f = makeFunction(*module, "linalg_ops",
{indexType, indexType, indexType}, {});
TEST_FUNC(linalg_ops_folded_slices) {
MLIRContext context;
- OwningModuleRef module = Module::create(&context);
+ OwningModuleRef module = Module::create(UnknownLoc::get(&context));
auto indexType = mlir::IndexType::get(&context);
mlir::FuncOp f = makeFunction(*module, "linalg_ops_folded_slices",
{indexType, indexType, indexType}, {});
TEST_FUNC(foo) {
MLIRContext context;
- OwningModuleRef module = Module::create(&context);
+ OwningModuleRef module = Module::create(UnknownLoc::get(&context));
mlir::FuncOp f = makeFunctionWithAMatmulOp(*module, "matmul_as_loops");
lowerToLoops(f);
TEST_FUNC(matmul_as_matvec) {
MLIRContext context;
- Module module = Module::create(&context);
+ Module module = Module::create(UnknownLoc::get(&context));
mlir::FuncOp f = makeFunctionWithAMatmulOp(module, "matmul_as_matvec");
lowerToFinerGrainedTensorContraction(f);
composeSliceOps(f);
TEST_FUNC(matmul_as_dot) {
MLIRContext context;
- Module module = Module::create(&context);
+ Module module = Module::create(UnknownLoc::get(&context));
mlir::FuncOp f = makeFunctionWithAMatmulOp(module, "matmul_as_dot");
lowerToFinerGrainedTensorContraction(f);
lowerToFinerGrainedTensorContraction(f);
TEST_FUNC(matmul_as_loops) {
MLIRContext context;
- Module module = Module::create(&context);
+ Module module = Module::create(UnknownLoc::get(&context));
mlir::FuncOp f = makeFunctionWithAMatmulOp(module, "matmul_as_loops");
lowerToLoops(f);
composeSliceOps(f);
TEST_FUNC(matmul_as_matvec_as_loops) {
MLIRContext context;
- Module module = Module::create(&context);
+ Module module = Module::create(UnknownLoc::get(&context));
mlir::FuncOp f =
makeFunctionWithAMatmulOp(module, "matmul_as_matvec_as_loops");
lowerToFinerGrainedTensorContraction(f);
TEST_FUNC(matmul_as_matvec_as_affine) {
MLIRContext context;
- Module module = Module::create(&context);
+ Module module = Module::create(UnknownLoc::get(&context));
mlir::FuncOp f =
makeFunctionWithAMatmulOp(module, "matmul_as_matvec_as_affine");
lowerToFinerGrainedTensorContraction(f);
// linalg.matmul operation and lower it all the way down to the LLVM IR
// dialect through partial conversions.
MLIRContext context;
- OwningModuleRef module = Module::create(&context);
+ OwningModuleRef module = Module::create(UnknownLoc::get(&context));
mlir::FuncOp f = makeFunctionWithAMatmulOp(*module, "matmul_as_loops");
lowerToLoops(f);
convertLinalg3ToLLVM(*module);
TEST_FUNC(matmul_tiled_loops) {
MLIRContext context;
- OwningModuleRef module = Module::create(&context);
+ OwningModuleRef module = Module::create(UnknownLoc::get(&context));
mlir::FuncOp f = makeFunctionWithAMatmulOp(*module, "matmul_tiled_loops");
lowerToTiledLoops(f, {8, 9});
PassManager pm;
TEST_FUNC(matmul_tiled_views) {
MLIRContext context;
- OwningModuleRef module = Module::create(&context);
+ OwningModuleRef module = Module::create(UnknownLoc::get(&context));
mlir::FuncOp f = makeFunctionWithAMatmulOp(*module, "matmul_tiled_views");
OpBuilder b(f.getBody());
lowerToTiledViews(f, {b.create<ConstantIndexOp>(f.getLoc(), 8),
TEST_FUNC(matmul_tiled_views_as_loops) {
MLIRContext context;
- OwningModuleRef module = Module::create(&context);
+ OwningModuleRef module = Module::create(UnknownLoc::get(&context));
mlir::FuncOp f =
makeFunctionWithAMatmulOp(*module, "matmul_tiled_views_as_loops");
OpBuilder b(f.getBody());
mlir::Module mlirGen(ModuleAST &moduleAST) {
// We create an empty MLIR module and codegen functions one at a time and
// add them to the module.
- theModule = mlir::Module::create(&context);
+ theModule = mlir::Module::create(mlir::UnknownLoc::get(&context));
for (FunctionAST &F : moduleAST) {
auto func = mlirGen(F);
mlir::OwningModuleRef mlirGen(ModuleAST &moduleAST) {
// We create an empty MLIR module and codegen functions one at a time and
// add them to the module.
- theModule = mlir::Module::create(&context);
+ theModule = mlir::Module::create(mlir::UnknownLoc::get(&context));
for (FunctionAST &F : moduleAST) {
auto func = mlirGen(F);
mlir::OwningModuleRef mlirGen(ModuleAST &moduleAST) {
// We create an empty MLIR module and codegen functions one at a time and
// add them to the module.
- theModule = mlir::Module::create(&context);
+ theModule = mlir::Module::create(mlir::UnknownLoc::get(&context));
for (FunctionAST &F : moduleAST) {
auto func = mlirGen(F);
mlir::OwningModuleRef mlirGen(ModuleAST &moduleAST) {
// We create an empty MLIR module and codegen functions one at a time and
// add them to the module.
- theModule = mlir::Module::create(&context);
+ theModule = mlir::Module::create(mlir::UnknownLoc::get(&context));
for (FunctionAST &F : moduleAST) {
auto func = mlirGen(F);
MLIRContext *getContext() const { return context; }
Identifier getIdentifier(StringRef str);
- Module createModule();
// Locations.
Location getUnknownLoc();
static void build(Builder *builder, OperationState *result);
- /// Construct a module from the given context.
- static ModuleOp create(MLIRContext *context);
+ /// Construct a module from the given location.
+ static ModuleOp create(Location loc);
/// Operation hooks.
static ParseResult parse(OpAsmParser *parser, OperationState *result);
GpuKernelToCubinPass::translateGpuKernelToCubinAnnotation(FuncOp &function) {
Builder builder(function.getContext());
- OwningModuleRef module = builder.createModule();
+ OwningModuleRef module = Module::create(function.getLoc());
// TODO(herhut): Also handle called functions.
module->push_back(function.clone());
return Identifier::get(str, context);
}
-Module Builder::createModule() { return Module::create(context); }
-
//===----------------------------------------------------------------------===//
// Locations.
//===----------------------------------------------------------------------===//
}
/// Construct a module from the given context.
-ModuleOp ModuleOp::create(MLIRContext *context) {
- OperationState state(UnknownLoc::get(context), "module");
- Builder builder(context);
+ModuleOp ModuleOp::create(Location loc) {
+ OperationState state(loc, "module");
+ Builder builder(loc->getContext());
ModuleOp::build(&builder, &state);
return llvm::cast<ModuleOp>(Operation::create(state));
}
/// null.
Module mlir::parseSourceFile(const llvm::SourceMgr &sourceMgr,
MLIRContext *context) {
+ auto sourceBuf = sourceMgr.getMemoryBuffer(sourceMgr.getMainFileID());
// This is the result module we are parsing into.
- OwningModuleRef module(Module::create(context));
+ OwningModuleRef module(Module::create(FileLineColLoc::get(
+ sourceBuf->getBufferIdentifier(), /*line=*/0, /*column=*/0, context)));
ParserState state(sourceMgr, context);
if (ModuleParser(state).parseModule(*module))
// converted SPIR-V ModuleOp inside a MLIR module. This should be changed to
// return the SPIR-V ModuleOp directly after module and function are migrated
// to be general ops.
- OwningModuleRef module(builder.createModule());
+ OwningModuleRef module(Module::create(
+ FileLineColLoc::get(inputFilename, /*line=*/0, /*column=*/0, context)));
Block *block = createOneBlockFunction(builder, module.get());
block->push_front(spirvModule->getOperation());
MLIRContext context;
// Test fine grain invalidation of the module analysis manager.
- OwningModuleRef module(Module::create(&context));
+ OwningModuleRef module(Module::create(UnknownLoc::get(&context)));
ModuleAnalysisManager mam(*module, /*passInstrumentor=*/nullptr);
// Query two different analyses, but only preserve one before invalidating.
Builder builder(&context);
// Create a function and a module.
- OwningModuleRef module(Module::create(&context));
+ OwningModuleRef module(Module::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(Module::create(&context));
+ OwningModuleRef module(Module::create(UnknownLoc::get(&context)));
FuncOp func1 =
FuncOp::create(builder.getUnknownLoc(), "foo",
builder.getFunctionType(llvm::None, llvm::None));