@@ -185,6 +185,28 @@ bool omitRegionTerm(mlir::Region &r) {
185
185
return singleNonEmptyBlock && yieldsNothing ();
186
186
}
187
187
188
+ // ===----------------------------------------------------------------------===//
189
+ // CIR Custom Parsers/Printers
190
+ // ===----------------------------------------------------------------------===//
191
+
192
+ static mlir::ParseResult
193
+ parseOmittedTerminatorRegion (mlir::OpAsmParser &parser, mlir::Region ®ion) {
194
+ auto regionLoc = parser.getCurrentLocation ();
195
+ if (parser.parseRegion (region))
196
+ return failure ();
197
+ if (ensureRegionTerm (parser, region, regionLoc).failed ())
198
+ return failure ();
199
+ return success ();
200
+ }
201
+
202
+ static void printOmittedTerminatorRegion (mlir::OpAsmPrinter &printer,
203
+ mlir::cir::ScopeOp &op,
204
+ mlir::Region ®ion) {
205
+ printer.printRegion (region,
206
+ /* printEntryBlockArgs=*/ false ,
207
+ /* printBlockTerminators=*/ !omitRegionTerm (region));
208
+ }
209
+
188
210
// ===----------------------------------------------------------------------===//
189
211
// AllocaOp
190
212
// ===----------------------------------------------------------------------===//
@@ -581,35 +603,6 @@ LogicalResult IfOp::verify() { return success(); }
581
603
// ScopeOp
582
604
// ===----------------------------------------------------------------------===//
583
605
584
- ParseResult cir::ScopeOp::parse (OpAsmParser &parser, OperationState &result) {
585
- // Create one region within 'scope'.
586
- result.regions .reserve (1 );
587
- Region *scopeRegion = result.addRegion ();
588
- auto loc = parser.getCurrentLocation ();
589
-
590
- // Parse the scope region.
591
- if (parser.parseRegion (*scopeRegion, /* arguments=*/ {}, /* argTypes=*/ {}))
592
- return failure ();
593
-
594
- if (ensureRegionTerm (parser, *scopeRegion, loc).failed ())
595
- return failure ();
596
-
597
- // Parse the optional attribute list.
598
- if (parser.parseOptionalAttrDict (result.attributes ))
599
- return failure ();
600
- return success ();
601
- }
602
-
603
- void cir::ScopeOp::print (OpAsmPrinter &p) {
604
- p << ' ' ;
605
- auto &scopeRegion = this ->getScopeRegion ();
606
- p.printRegion (scopeRegion,
607
- /* printEntryBlockArgs=*/ false ,
608
- /* printBlockTerminators=*/ !omitRegionTerm (scopeRegion));
609
-
610
- p.printOptionalAttrDict (getOperation ()->getAttrs ());
611
- }
612
-
613
606
// / Given the region at `index`, or the parent operation if `index` is None,
614
607
// / return the successor regions. These are the regions that may be selected
615
608
// / during the flow of control. `operands` is a set of optional attributes that
@@ -619,7 +612,7 @@ void ScopeOp::getSuccessorRegions(mlir::RegionBranchPoint point,
619
612
SmallVectorImpl<RegionSuccessor> ®ions) {
620
613
// The only region always branch back to the parent operation.
621
614
if (!point.isParent ()) {
622
- regions.push_back (RegionSuccessor (getResults ( )));
615
+ regions.push_back (RegionSuccessor (getODSResults ( 0 )));
623
616
return ;
624
617
}
625
618
0 commit comments