File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
include/mlir/Dialect/EmitC/IR Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,11 @@ def EmitC_TranslationUnitOp : EmitC_Op<"tu",
8585 let regions = (region SizedRegion<1>:$bodyRegion);
8686
8787 let assemblyFormat = "$id attr-dict-with-keyword $bodyRegion";
88+ let builders = [OpBuilder<(ins CArg<"StringRef">:$id)>];
8889 let extraClassDeclaration = [{
90+ /// Construct a module from the given location with an optional name.
91+ static TranslationUnitOp create(Location loc, StringRef name);
92+
8993 //===------------------------------------------------------------------===//
9094 // OpAsmOpInterface Methods
9195 //===------------------------------------------------------------------===//
@@ -96,6 +100,10 @@ def EmitC_TranslationUnitOp : EmitC_Op<"tu",
96100 return "emitc";
97101 }
98102 }];
103+
104+ // We need to ensure that the body region has a block;
105+ // the auto-generated builders do not guarantee that.
106+ let skipDefaultBuilders = 1;
99107}
100108
101109def EmitC_AddOp : EmitC_BinaryOp<"add", [CExpression]> {
Original file line number Diff line number Diff line change @@ -1251,6 +1251,16 @@ GetGlobalOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
12511251 return success ();
12521252}
12531253
1254+ // ===----------------------------------------------------------------------===//
1255+ // TranslationUnitOp
1256+ // ===----------------------------------------------------------------------===//
1257+ void TranslationUnitOp::build (OpBuilder &builder, OperationState &state,
1258+ StringRef id) {
1259+ state.addRegion ()->emplaceBlock ();
1260+ state.attributes .push_back (
1261+ builder.getNamedAttr (" id" , builder.getStringAttr (id)));
1262+ }
1263+
12541264// ===----------------------------------------------------------------------===//
12551265// TableGen'd op method definitions
12561266// ===----------------------------------------------------------------------===//
You can’t perform that action at this time.
0 commit comments