[ODS] NFC: Rename EnumAttr to StrEnumAttr to be consistent with IntEnumAttr
authorLei Zhang <antiagainst@google.com>
Tue, 2 Jul 2019 15:27:32 +0000 (08:27 -0700)
committerjpienaar <jpienaar@google.com>
Tue, 2 Jul 2019 17:28:36 +0000 (10:28 -0700)
PiperOrigin-RevId: 256169019

mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td
mlir/include/mlir/IR/OpBase.td
mlir/lib/TableGen/Attribute.cpp
mlir/test/lib/TestDialect/TestOps.td
mlir/unittests/TableGen/enums.td

index 1cf74fc..46b4293 100644 (file)
@@ -67,14 +67,14 @@ def fxpmath_EwUnaryFn_Tanh    : fxpmath_ConstEwUnaryFn<"TANH">;
 // Comparison functions (compares relative to zero on a subtraction result).
 //===----------------------------------------------------------------------===//
 
-def fxpmath_CompareZ    : EnumAttrCase<"CMPZ">;
-def fxpmath_CompareNZ   : EnumAttrCase<"CMPNZ">;
-def fxpmath_CompareLZ   : EnumAttrCase<"CMPLZ">;
-def fxpmath_CompareLZE  : EnumAttrCase<"CMPLZE">;
-def fxpmath_CompareGZ   : EnumAttrCase<"CMPGZ">;
-def fxpmath_CompareGZE  : EnumAttrCase<"CMPGZE">;
-
-def fxpmath_CompareFnAttr : EnumAttr<"ComparisonFn",
+def fxpmath_CompareZ    : StrEnumAttrCase<"CMPZ">;
+def fxpmath_CompareNZ   : StrEnumAttrCase<"CMPNZ">;
+def fxpmath_CompareLZ   : StrEnumAttrCase<"CMPLZ">;
+def fxpmath_CompareLZE  : StrEnumAttrCase<"CMPLZE">;
+def fxpmath_CompareGZ   : StrEnumAttrCase<"CMPGZ">;
+def fxpmath_CompareGZE  : StrEnumAttrCase<"CMPGZE">;
+
+def fxpmath_CompareFnAttr : StrEnumAttr<"ComparisonFn",
     "Type of subtraction-result comparison to perform.",
     [
       fxpmath_CompareZ,
index 802ae2c..40ef9e4 100644 (file)
@@ -655,8 +655,7 @@ class EnumAttrCaseInfo<string sym, int val> {
 }
 
 // An enum attribute case stored with StringAttr.
-// TODO(antiagainst): rename this to StrEnumAttrCase to be consistent
-class EnumAttrCase<string sym, int val = -1> :
+class StrEnumAttrCase<string sym, int val = -1> :
     EnumAttrCaseInfo<sym, val>,
     StringBasedAttr<
       CPred<"$_self.cast<StringAttr>().getValue() == \"" # sym # "\"">,
@@ -736,9 +735,8 @@ class EnumAttrInfo<string name, list<EnumAttrCaseInfo> cases> {
 // Op attributes of this kind are stored as StringAttr. Extra verification will
 // be generated on the string though: only the symbols of the allowed cases are
 // permitted as the string value.
-// TODO(antiagainst): rename this to StrEnumAttr to be consistent
-class EnumAttr<string name, string description,
-                  list<EnumAttrCase> cases> :
+class StrEnumAttr<string name, string description,
+                  list<StrEnumAttrCase> cases> :
     EnumAttrInfo<name, cases>,
     StringBasedAttr<
       And<[StrAttr.predicate, Or<!foreach(case, cases, case.predicate)>]>,
index c7dc002..f5eb6d3 100644 (file)
@@ -141,7 +141,7 @@ tblgen::EnumAttrCase::EnumAttrCase(const llvm::DefInit *init)
 }
 
 bool tblgen::EnumAttrCase::isStrCase() const {
-  return def->isSubClassOf("EnumAttrCase");
+  return def->isSubClassOf("StrEnumAttrCase");
 }
 
 StringRef tblgen::EnumAttrCase::getSymbol() const {
@@ -163,7 +163,7 @@ tblgen::EnumAttr::EnumAttr(const llvm::DefInit *init)
     : EnumAttr(init->getDef()) {}
 
 bool tblgen::EnumAttr::isStrEnum() const {
-  return def->isSubClassOf("EnumAttr");
+  return def->isSubClassOf("StrEnumAttr");
 }
 
 StringRef tblgen::EnumAttr::getEnumClassName() const {
index d64af5b..ba9b642 100644 (file)
@@ -104,10 +104,10 @@ def TypeStringAttrWithTypeOp : TEST_Op<"string_attr_with_type"> {
   }];
 }
 
-def StrCaseA: EnumAttrCase<"A">;
-def StrCaseB: EnumAttrCase<"B">;
+def StrCaseA: StrEnumAttrCase<"A">;
+def StrCaseB: StrEnumAttrCase<"B">;
 
-def SomeStrEnum: EnumAttr<
+def SomeStrEnum: StrEnumAttr<
   "SomeStrEnum", "", [StrCaseA, StrCaseB]>;
 
 def StrEnumAttrOp : TEST_Op<"str_enum_attr"> {
@@ -247,10 +247,10 @@ def SizedRegionOp : TEST_Op<"sized_region_op", []> {
 // Test Legalization
 //===----------------------------------------------------------------------===//
 
-def Test_LegalizerEnum_Success : EnumAttrCase<"Success">;
-def Test_LegalizerEnum_Failure : EnumAttrCase<"Failure">;
+def Test_LegalizerEnum_Success : StrEnumAttrCase<"Success">;
+def Test_LegalizerEnum_Failure : StrEnumAttrCase<"Failure">;
 
-def Test_LegalizerEnum : EnumAttr<"Success", "Failure",
+def Test_LegalizerEnum : StrEnumAttr<"Success", "Failure",
   [Test_LegalizerEnum_Success, Test_LegalizerEnum_Failure]>;
 
 def ILLegalOpA : TEST_Op<"illegal_op_a">, Results<(outs I32:$res)>;
index bd83067..a623e1e 100644 (file)
 
 include "mlir/IR/OpBase.td"
 
-def CaseA: EnumAttrCase<"CaseA">;
-def CaseB: EnumAttrCase<"CaseB", 10>;
+def CaseA: StrEnumAttrCase<"CaseA">;
+def CaseB: StrEnumAttrCase<"CaseB", 10>;
 
-def StrEnum: EnumAttr<"StrEnum", "A test enum", [CaseA, CaseB]> {
+def StrEnum: StrEnumAttr<"StrEnum", "A test enum", [CaseA, CaseB]> {
   let cppNamespace = "Outer::Inner";
   let stringToSymbolFnName = "ConvertToEnum";
   let symbolToStringFnName = "ConvertToString";