Skip to content

Commit

Permalink
Structure all ops
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasgrosser committed May 6, 2023
1 parent bfaada8 commit c3bb701
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions mlir/lib/Tools/mlir-irdlgen/MlirIrdlGenMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,7 @@
using namespace mlir;
using namespace llvm;

LogicalResult mlir::mlirIrdlGenMain(int argc, char **argv,
MLIRContext &ctx) {

ctx.getOrLoadDialect<irdl::IRDLDialect>();

auto unknownLoc = UnknownLoc::get(&ctx);
OwningOpRef<ModuleOp> module(ModuleOp::create(unknownLoc));

// Create the builder, and set its insertion point in the module.
OpBuilder builder(&ctx);
auto &moduleBlock = module->getRegion().getBlocks().front();
builder.setInsertionPoint(&moduleBlock, moduleBlock.begin());

void insertDialect(MLIRContext &ctx, OpBuilder &builder) {
// Create the IDRL dialect operation, and set the insertion point in it.
auto dialect = builder.create<irdl::DialectOp>(
UnknownLoc::get(&ctx), StringAttr::get(&ctx, "arith"));
Expand All @@ -78,6 +66,23 @@ LogicalResult mlir::mlirIrdlGenMain(int argc, char **argv,
auto opc = builder.create<irdl::OperationOp>(UnknownLoc::get(&ctx), StringAttr::get(&ctx, op));
auto &opBlock = opc.getBody().emplaceBlock();
}

}

LogicalResult mlir::mlirIrdlGenMain(int argc, char **argv,
MLIRContext &ctx) {

ctx.getOrLoadDialect<irdl::IRDLDialect>();

auto unknownLoc = UnknownLoc::get(&ctx);
OwningOpRef<ModuleOp> module(ModuleOp::create(unknownLoc));

// Create the builder, and set its insertion point in the module.
OpBuilder builder(&ctx);
auto &moduleBlock = module->getRegion().getBlocks().front();
builder.setInsertionPoint(&moduleBlock, moduleBlock.begin());

insertDialect(ctx, builder);

module->print(llvm::outs());

Expand Down

0 comments on commit c3bb701

Please sign in to comment.