• Motivation LLVM TableGen currently lacks a way to accumulate field values across class hierarchies. • When a derived class sets a field via let , it completely replaces the parent’s value. • This forces users into verbose workarounds like: class Base { list items = [1, 2]; } class Derived : Base { // Must manually repeat parent values: let items = !listconcat(Base.items, [3, 4]); } This is especially painful in MLIR, where dialect authors want base op/type/attribute classes to inject shared C++ declarations into all derived definitions. • I attempted to solve this in PR [MLIR][TableGen] Add inheritableExtraClassDeclaration/Definition for Op and AttrOrTypeDef by xlauko · Pull Request #182265 · llvm/llvm-project · GitHub with MLIR-specific inheritableExtraClassDeclaration /Definition fields, but as @joker-eph pointed out, this is ad-hoc - the same inheritance problem exists for traits , arguments , results , and any other list/string/dag field. • Rather than adding inheritable* variants per field, we should solve this at the language level. • Design This PR adds two new modifiers to the let statement: append and prepend .

Article Summaries:

  • LLVM’s TableGen language now supports “append” and “prepend” modifiers on let statements, allowing derived classes to accumulate field values instead of replacing them. The change lets users concatenate lists, strings, and DAGs across inheritance chains, e.g., let append items = [3,4] adds to a base list. Plain let still replaces values, so the feature is opt‑in. Accumulation works naturally through multi‑level inheritance but follows the last‑writer‑wins rule for multiple inheritance, consistent with existing behavior. The update is backward compatible, using context‑sensitive keywords that only trigger when appropriate.

Sources: