[Mlir-commits] [mlir] f00dcd3 - [mlir][ods] Add I8 and I16 cases to BitEnumAttr

Jeff Niu llvmlistbot at llvm.org
Thu Dec 8 21:10:22 PST 2022


Author: Jeff Niu
Date: 2022-12-08T21:10:15-08:00
New Revision: f00dcd3d7a6ce05b731f7d0d5d3c887bead5ca5a

URL: https://github.com/llvm/llvm-project/commit/f00dcd3d7a6ce05b731f7d0d5d3c887bead5ca5a
DIFF: https://github.com/llvm/llvm-project/commit/f00dcd3d7a6ce05b731f7d0d5d3c887bead5ca5a.diff

LOG: [mlir][ods] Add I8 and I16 cases to BitEnumAttr

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D139664

Added: 
    

Modified: 
    mlir/include/mlir/IR/EnumAttr.td

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/EnumAttr.td b/mlir/include/mlir/IR/EnumAttr.td
index ef2fd33b64e92..3b41e9fc219ca 100644
--- a/mlir/include/mlir/IR/EnumAttr.td
+++ b/mlir/include/mlir/IR/EnumAttr.td
@@ -51,23 +51,22 @@ class BitEnumAttrCaseBase<I intType, string sym, int val, string str = sym> :
     EnumAttrCaseInfo<sym, val, str>,
     SignlessIntegerAttrBase<intType, "case " #str>;
 
-// A bit enum case stored with a 32-bit IntegerAttr. `val` here is *not* the
-// ordinal number of a bit that is set. It is a 32-bit integer value with bits
-// set to match the case.
+class I8BitEnumAttrCase<string sym, int val, string str = sym>
+    : BitEnumAttrCaseBase<I8, sym, val, str>;
+class I16BitEnumAttrCase<string sym, int val, string str = sym>
+    : BitEnumAttrCaseBase<I16, sym, val, str>;
 class I32BitEnumAttrCase<string sym, int val, string str = sym>
     : BitEnumAttrCaseBase<I32, sym, val, str>;
-
-// A bit enum case stored with a 64-bit IntegerAttr. `val` here is *not* the
-// ordinal number of a bit that is set. It is a 64-bit integer value with bits
-// bits set to match the case.
 class I64BitEnumAttrCase<string sym, int val, string str = sym>
     : BitEnumAttrCaseBase<I64, sym, val, str>;
 
-// The special bit enum case for I32 with no bits set (i.e. value = 0).
+// The special bit enum case with no bits set (i.e. value = 0).
+class I8BitEnumAttrCaseNone<string sym, string str = sym>
+    : I8BitEnumAttrCase<sym, 0, str>;
+class I16BitEnumAttrCaseNone<string sym, string str = sym>
+    : I16BitEnumAttrCase<sym, 0, str>;
 class I32BitEnumAttrCaseNone<string sym, string str = sym>
     : I32BitEnumAttrCase<sym, 0, str>;
-
-// The special bit enum case for I64 with no bits set (i.e. value = 0).
 class I64BitEnumAttrCaseNone<string sym, string str = sym>
     : I64BitEnumAttrCase<sym, 0, str>;
 
@@ -80,17 +79,15 @@ class BitEnumAttrCaseBit<I intType, string sym, int pos, string str = sym>
       "bit position larger than underlying storage";
 }
 
-// A bit enum case for a single bit in a 32-bit enum, specified by the
-// bit position.
+class I8BitEnumAttrCaseBit<string sym, int pos, string str = sym>
+    : BitEnumAttrCaseBit<I8, sym, pos, str>;
+class I16BitEnumAttrCaseBit<string sym, int pos, string str = sym>
+    : BitEnumAttrCaseBit<I16, sym, pos, str>;
 class I32BitEnumAttrCaseBit<string sym, int pos, string str = sym>
     : BitEnumAttrCaseBit<I32, sym, pos, str>;
-
-// A bit enum case for a single bit in a 64-bit enum, specified by the
-// bit position.
 class I64BitEnumAttrCaseBit<string sym, int pos, string str = sym>
     : BitEnumAttrCaseBit<I64, sym, pos, str>;
 
-
 // A bit enum case for a group/list of previously declared cases, providing
 // a convenient alias for that group.
 class BitEnumAttrCaseGroup<I intType, string sym,
@@ -99,14 +96,15 @@ class BitEnumAttrCaseGroup<I intType, string sym,
           !foldl(0, cases, value, bitcase, !or(value, bitcase.value)),
           str>;
 
-// A 32-bit enum case for a group/list of previously declared cases, providing
-// a convenient alias for that group.
+class I8BitEnumAttrCaseGroup<string sym, list<BitEnumAttrCaseBase> cases,
+                              string str = sym>
+    : BitEnumAttrCaseGroup<I8, sym, cases, str>;
+class I16BitEnumAttrCaseGroup<string sym, list<BitEnumAttrCaseBase> cases,
+                              string str = sym>
+    : BitEnumAttrCaseGroup<I16, sym, cases, str>;
 class I32BitEnumAttrCaseGroup<string sym, list<BitEnumAttrCaseBase> cases,
                               string str = sym>
     : BitEnumAttrCaseGroup<I32, sym, cases, str>;
-
-// A 64-bit enum case for a group/list of previously declared cases, providing
-// a convenient alias for that group.
 class I64BitEnumAttrCaseGroup<string sym, list<BitEnumAttrCaseBase> cases,
                               string str = sym>
     : BitEnumAttrCaseGroup<I64, sym, cases, str>;
@@ -317,6 +315,18 @@ class BitEnumAttr<I intType, string name, string summary,
   bit printBitEnumPrimaryGroups = 0;
 }
 
+class I8BitEnumAttr<string name, string summary,
+                     list<BitEnumAttrCaseBase> cases>
+    : BitEnumAttr<I8, name, summary, cases> {
+  let underlyingType = "uint8_t";
+}
+
+class I16BitEnumAttr<string name, string summary,
+                     list<BitEnumAttrCaseBase> cases>
+    : BitEnumAttr<I16, name, summary, cases> {
+  let underlyingType = "uint16_t";
+}
+
 class I32BitEnumAttr<string name, string summary,
                      list<BitEnumAttrCaseBase> cases>
     : BitEnumAttr<I32, name, summary, cases> {


        


More information about the Mlir-commits mailing list