[llvm-branch-commits] [mlir] [mlir] Add predicates to tablegen-defined properties (PR #120176)

Mehdi Amini via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Dec 17 07:22:31 PST 2024


================
@@ -330,6 +337,56 @@ def UnitProperty : Property<"bool", "unit property"> {
   }];
 }
 
+//===----------------------------------------------------------------------===//
+// Property field overwrites
+
+/// Class for giving a property a default value.
+/// This doesn't change anything about the property other than giving it a default
+/// which can be used by ODS to elide printing.
+class DefaultValuedProperty<Property p, string default = "", string storageDefault = ""> : Property<p.storageType, p.summary> {
+  let defaultValue = default;
+  let storageTypeValueOverride = storageDefault;
+  let baseProperty = p;
+  // Keep up to date with `Property` above.
+  let summary = p.summary;
+  let description = p.description;
+  let storageType = p.storageType;
+  let interfaceType = p.interfaceType;
+  let convertFromStorage = p.convertFromStorage;
+  let assignToStorage = p.assignToStorage;
+  let convertToAttribute = p.convertToAttribute;
+  let convertFromAttribute = p.convertFromAttribute;
+  let predicate = p.predicate;
+  let hashProperty = p.hashProperty;
+  let parser = p.parser;
+  let optionalParser = p.optionalParser;
+  let printer = p.printer;
+  let readFromMlirBytecode = p.readFromMlirBytecode;
+  let writeToMlirBytecode = p.writeToMlirBytecode;
+}
+
+class ConfinedProperty<Property p, Pred pred, string newSummary = "">
----------------
joker-eph wrote:

Please add a short doc for the class

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


More information about the llvm-branch-commits mailing list