[Mlir-commits] [mlir] 543cd76 - Update OpBase.td AttrDef class to define default value for returnType and convertFromStorage (NFC)
Mehdi Amini
llvmlistbot at llvm.org
Wed Apr 14 12:25:36 PDT 2021
Author: Mehdi Amini
Date: 2021-04-14T19:22:07Z
New Revision: 543cd763a4882285f34a75db930f19fd6a21b14b
URL: https://github.com/llvm/llvm-project/commit/543cd763a4882285f34a75db930f19fd6a21b14b
DIFF: https://github.com/llvm/llvm-project/commit/543cd763a4882285f34a75db930f19fd6a21b14b.diff
LOG: Update OpBase.td AttrDef class to define default value for returnType and convertFromStorage (NFC)
Differential Revision: https://reviews.llvm.org/D100356
Added:
Modified:
mlir/include/mlir/IR/OpBase.td
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td
index f0b741ee4dee2..20f3c7fa84130 100644
--- a/mlir/include/mlir/IR/OpBase.td
+++ b/mlir/include/mlir/IR/OpBase.td
@@ -2699,6 +2699,20 @@ class AttrDef<Dialect dialect, string name,
// The name of the C++ Attribute class.
string cppClassName = name # "Attr";
+ // The underlying C++ value type
+ let returnType = dialect.cppNamespace # "::" # cppClassName;
+
+ // The call expression to convert from the storage type to the return
+ // type. For example, an enum can be stored as an int but returned as an
+ // enum class.
+ //
+ // Format: $_self will be expanded to the attribute.
+ //
+ // For example, `$_self.getValue().getSExtValue()` for `IntegerAttr val` will
+ // expand to `getAttrOfType<IntegerAttr>("val").getValue().getSExtValue()`.
+ let convertFromStorage = "$_self.cast<" # dialect.cppNamespace #
+ "::" # cppClassName # ">()";
+
// A code block used to build the value 'Type' of an Attribute when
// initializing its storage instance. This field is optional, and if not
// present the attribute will have its value type set to `NoneType`. This code
More information about the Mlir-commits
mailing list