[ODS] NFC: Rename EnumAttr to StrEnumAttr to be consistent with IntEnumAttr

PiperOrigin-RevId: 256169019
This commit is contained in:
Lei Zhang 2019-07-02 08:27:32 -07:00 committed by jpienaar
parent 32f3c6c74e
commit 509411c229
5 changed files with 21 additions and 23 deletions

View 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_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 : EnumAttr<"ComparisonFn",
def fxpmath_CompareFnAttr : StrEnumAttr<"ComparisonFn",
"Type of subtraction-result comparison to perform.",
[
fxpmath_CompareZ,

View 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)>]>,

View 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 {

View 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)>;

View File

@ -17,10 +17,10 @@
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";