[Mlir-commits] [mlir] [mlir][EmitC] Create a pass to add a reflection map to a class (PR #205464)
Bhavesh M
llvmlistbot at llvm.org
Tue Jul 14 13:00:39 PDT 2026
================
@@ -0,0 +1,57 @@
+// RUN: mlir-opt -split-input-file --mlgo-add-reflection-map="field-attr-name=emitc.field_ref excluded-field-attrs=emitc.other_field" %s | mlir-translate -mlir-to-cpp | FileCheck %s
+
+// Test that a reflection map and lookup function are generated in the class.
+
+emitc.class @actionClass {
+ emitc.field @fieldName0 : !emitc.array<1xf32> {emitc.field_ref = ["another_feature"]}
+ emitc.field @fieldName1 : !emitc.array<1xf32> {emitc.field_ref = ["some_feature"]}
+ emitc.func @"operator()"() {
+ %0 = get_field @fieldName0 : !emitc.array<1xf32>
+ return
+ }
+}
+
+// CHECK: #include <map>
+// CHECK-NEXT: #include <string>
+// CHECK-NEXT: class actionClass {
+// CHECK-NEXT: public:
+// CHECK-NEXT: float fieldName0[1];
+// CHECK-NEXT: float fieldName1[1];
+// CHECK-NEXT: const std::map<std::string, char*> reflectionMap = { { "another_feature", reinterpret_cast<char*>(&fieldName0) }, { "some_feature", reinterpret_cast<char*>(&fieldName1) } };
----------------
beamandala wrote:
Fixed
https://github.com/llvm/llvm-project/pull/205464
More information about the Mlir-commits
mailing list