[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 12:59:10 PDT 2026


================
@@ -60,43 +60,37 @@ def WrapFuncInClassPass : Pass<"wrap-emitc-func-in-class", "ModuleOp"> {
   ];
 }
 
-def AddReflectionMapPass : Pass<"add-reflection-map", "ModuleOp"> {
+def MLGOAddReflectionMapPass : Pass<"mlgo-add-reflection-map", "ModuleOp"> {
   let summary = "Add a reflection map and a helper method to EmitC classes for runtime field lookup.";
   let description = [{
     This pass adds a `reflectionMap` field and an accompanying `getBufferForName` method to 
     EmitC classes, enabling runtime lookup of class fields by name. 
     This requires that the class has fields with attributes.
     Each `emitc.field` is expected to have an attribute (configured by the
     `field-attr-name` option) that is an array containing a single string
-    attribute.
-
-
+    attribute. If a field possesses both the attribute specified by
+    `field-attr-name` and an attribute specified in `excluded-field-attrs`,
+    the `field-attr-name` attribute takes precedence and the field will be
+    included in the reflection map.
+    
     Example:
 
     ```mlir
     emitc.class @MyClass {
-      emitc.field @fieldName0 : !emitc.array<1xf32> {emitc.field_ref = ["another_feature"]}
-      emitc.field @fieldName1 : !emitc.array<1xf32> {emitc.field_ref = ["some_feature"]}
-      emitc.func @execute() { ... }
+      emitc.field @field0 : !emitc.array<1xf32> {emitc.field_ref = ["feature0"]}
+      emitc.func @operator()() { ... }
----------------
beamandala wrote:

I changed it to `@operator()()` because that's the function that's generated by the `wrap-emitc-func-in-class` pass which is run before this pass in our use case. This isn't a hard pre req to running this pass though so I'll change it back to `execute()`.

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


More information about the Mlir-commits mailing list