[Mlir-commits] [mlir] [mlir][emitC] Add support to emitter for `classop`, `fieldop` and `getfieldop` (PR #145605)

Jaden Angella llvmlistbot at llvm.org
Thu Jun 26 12:34:00 PDT 2025


================
@@ -997,6 +997,49 @@ static LogicalResult printOperation(CppEmitter &emitter, ModuleOp moduleOp) {
   return success();
 }
 
+static LogicalResult printOperation(CppEmitter &emitter, ClassOp classOp) {
+  CppEmitter::Scope classScope(emitter);
+  raw_indented_ostream &os = emitter.ostream();
+  os << "class " << classOp.getSymName() << " {\n";
+  os << "public:\n";
+  os.indent();
+
+  for (Operation &op : classOp) {
+    if (failed(emitter.emitOperation(op, /*trailingSemicolon=*/false)))
+      return failure();
+  }
+
+  os.unindent();
+  os << "};";
+  return success();
+}
+
+static LogicalResult printOperation(CppEmitter &emitter, FieldOp fieldOp) {
+  raw_ostream &os = emitter.ostream();
+  if (failed(emitter.emitType(fieldOp->getLoc(), fieldOp.getType())))
+    return failure();
+  os << " " << fieldOp.getSymName() << ";";
+  return success();
+}
+
+static LogicalResult printOperation(CppEmitter &emitter,
+                                    GetFieldOp getFieldOp) {
+  raw_indented_ostream &os = emitter.ostream();
+  Location loc = getFieldOp->getLoc();
+
+  if (getFieldOp->getNumResults() > 0) {
+    Value result = getFieldOp->getResult(0);
----------------
Jaddyen wrote:

yes it is!
thanks for the pointer.
ive addressed this now.

https://github.com/llvm/llvm-project/pull/145605


More information about the Mlir-commits mailing list