[Mlir-commits] [mlir] [mlir][EmitC] Create a pass to add a reflection map to a class (PR #205464)

Andrzej WarzyƄski llvmlistbot at llvm.org
Fri Jul 17 09:12:26 PDT 2026


================
@@ -60,4 +60,49 @@ def WrapFuncInClassPass : Pass<"wrap-emitc-func-in-class", "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
+    `included-field-attrs` option) that is an array containing a single string
+    attribute. If a field possesses both an attribute specified by
+    `included-field-attrs` and an attribute specified in `excluded-field-attrs`,
+    the `included-field-attrs` attribute takes precedence and the field will be
+    included in the reflection map.
----------------
banach-space wrote:

> We also wouldn't need https://github.com/llvm/llvm-project/pull/207069 anymore either.

Then it's a win-win :)

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


More information about the Mlir-commits mailing list