[Mlir-commits] [mlir] [mlir][emitc] Add 'emitc.switch' op to the dialect (PR #102331)
Gil Rapaport
llvmlistbot at llvm.org
Thu Aug 8 09:30:33 PDT 2024
================
@@ -449,6 +449,45 @@ static LogicalResult printOperation(CppEmitter &emitter, emitc::SubOp subOp) {
return printBinaryOperation(emitter, operation, "-");
}
+static LogicalResult emitSwitchCase(CppEmitter &emitter,
+ raw_indented_ostream &os, Region ®ion) {
+ for (Region::OpIterator iteratorOp = region.op_begin(), end = region.op_end();
+ std::next(iteratorOp) != end; ++iteratorOp) {
+ if (failed(emitter.emitOperation(*iteratorOp, /*trailingSemicolon=*/true)))
+ return failure();
+ }
+ os << "break;\n";
+ return success();
+}
+
+static LogicalResult printOperation(CppEmitter &emitter,
+ emitc::SwitchOp switchOp) {
+ raw_indented_ostream &os = emitter.ostream();
+
+ os << "\nswitch(" << emitter.getOrCreateName(switchOp.getArg()) << ") {";
----------------
aniragil wrote:
```suggestion
os << "\nswitch (" << emitter.getOrCreateName(switchOp.getArg()) << ") {";
```
https://github.com/llvm/llvm-project/pull/102331
More information about the Mlir-commits
mailing list