[Mlir-commits] [mlir] [mlir][emitc][cf] add 'cf.switch' support in CppEmitter (PR #101478)
Andrey Timonin
llvmlistbot at llvm.org
Thu Aug 1 06:07:09 PDT 2024
================
@@ -774,6 +774,41 @@ static LogicalResult printOperation(CppEmitter &emitter,
return printBinaryOperation(emitter, operation, "||");
}
+static LogicalResult printOperation(CppEmitter &emitter,
+ cf::SwitchOp switchOp) {
+ raw_indented_ostream &os = emitter.ostream();
+ auto iteratorCaseValues = (*switchOp.getCaseValues()).begin();
+ auto iteratorCaseValuesEnd = (*switchOp.getCaseValues()).end();
+
+ os << "\nswitch(" << emitter.getOrCreateName(switchOp.getFlag()) << ") {";
+
+ for (const auto caseBlock : switchOp.getCaseDestinations()) {
+ if (iteratorCaseValues == iteratorCaseValuesEnd)
+ return switchOp.emitOpError("case's value is absent for case block");
+
+ os << "\ncase " << *(iteratorCaseValues++) << ": {\n";
+ os.indent() << "goto ";
----------------
EtoAndruwa wrote:
Thank you! That was a critical error. Fixed.
https://github.com/llvm/llvm-project/pull/101478
More information about the Mlir-commits
mailing list