-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[LLVM][TableGen] Rename ListInit::getValues() to getElements()
#140289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LLVM][TableGen] Rename ListInit::getValues() to getElements()
#140289
Conversation
b1f2cf5 to
2c36635
Compare
Rename `ListInit::getValues()` to `getElements()` to better match with other `ListInit` members like `getElement`.
2c36635 to
6425e29
Compare
|
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-clang Author: Rahul Joshi (jurahul) ChangesRename Patch is 22.45 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/140289.diff 17 Files Affected:
diff --git a/clang/utils/TableGen/ClangOptionDocEmitter.cpp b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
index e39b8c9434a13..8a31686bc7727 100644
--- a/clang/utils/TableGen/ClangOptionDocEmitter.cpp
+++ b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
@@ -367,7 +367,7 @@ void emitOption(const DocumentedOption &Option, const Record *DocInfo,
R->getValueAsListOfDefs("HelpTextsForVariants")) {
// This is a list of visibilities.
ArrayRef<const Init *> Visibilities =
- VisibilityHelp->getValueAsListInit("Visibilities")->getValues();
+ VisibilityHelp->getValueAsListInit("Visibilities")->getElements();
// See if any of the program's visibilities are in the list.
for (StringRef DocInfoMask :
diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index 39493d718f0af..409f1c4f71834 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -486,7 +486,7 @@ class Intrinsic {
return Idx;
}
- bool hasBody() const { return Body && !Body->getValues().empty(); }
+ bool hasBody() const { return Body && !Body->empty(); }
void setNeededEarly() { NeededEarly = true; }
@@ -1436,14 +1436,14 @@ void Intrinsic::emitBodyAsBuiltinCall() {
void Intrinsic::emitBody(StringRef CallPrefix) {
std::vector<std::string> Lines;
- if (!Body || Body->getValues().empty()) {
+ if (!Body || Body->empty()) {
// Nothing specific to output - must output a builtin.
emitBodyAsBuiltinCall();
return;
}
// We have a list of "things to output". The last should be returned.
- for (auto *I : Body->getValues()) {
+ for (auto *I : Body->getElements()) {
if (const auto *SI = dyn_cast<StringInit>(I)) {
Lines.push_back(replaceParamsIn(SI->getAsString()));
} else if (const auto *DI = dyn_cast<DagInit>(I)) {
diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h
index 8b8abb6d52d0a..593688e7cfc0e 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -747,7 +747,7 @@ class ListInit final : public TypedInit,
public FoldingSetNode,
private TrailingObjects<ListInit, const Init *> {
friend TrailingObjects;
- unsigned NumValues;
+ unsigned NumElements;
public:
using const_iterator = const Init *const *;
@@ -769,11 +769,14 @@ class ListInit final : public TypedInit,
void Profile(FoldingSetNodeID &ID) const;
- ArrayRef<const Init *> getValues() const {
- return ArrayRef(getTrailingObjects(), NumValues);
+ ArrayRef<const Init *> getElements() const {
+ return ArrayRef(getTrailingObjects(), NumElements);
}
- const Init *getElement(unsigned Idx) const { return getValues()[Idx]; }
+ LLVM_DEPRECATED("Use getElements instead", "getElements")
+ ArrayRef<const Init *> getValues() const { return getElements(); }
+
+ const Init *getElement(unsigned Idx) const { return getElements()[Idx]; }
const RecTy *getElementType() const {
return cast<ListRecTy>(getType())->getElementType();
@@ -794,11 +797,11 @@ class ListInit final : public TypedInit,
bool isConcrete() const override;
std::string getAsString() const override;
- const_iterator begin() const { return getValues().begin(); }
- const_iterator end() const { return getValues().end(); }
+ const_iterator begin() const { return getElements().begin(); }
+ const_iterator end() const { return getElements().end(); }
- size_t size () const { return NumValues; }
- bool empty() const { return NumValues == 0; }
+ size_t size() const { return NumElements; }
+ bool empty() const { return NumElements == 0; }
const Init *getBit(unsigned Bit) const override {
llvm_unreachable("Illegal bit reference off list");
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index 97e185bbd1267..4efd80de7e45a 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -692,18 +692,19 @@ const Init *StringInit::convertInitializerTo(const RecTy *Ty) const {
return nullptr;
}
-static void ProfileListInit(FoldingSetNodeID &ID, ArrayRef<const Init *> Range,
+static void ProfileListInit(FoldingSetNodeID &ID,
+ ArrayRef<const Init *> Elements,
const RecTy *EltTy) {
- ID.AddInteger(Range.size());
+ ID.AddInteger(Elements.size());
ID.AddPointer(EltTy);
- for (const Init *I : Range)
- ID.AddPointer(I);
+ for (const Init *E : Elements)
+ ID.AddPointer(E);
}
ListInit::ListInit(ArrayRef<const Init *> Elements, const RecTy *EltTy)
: TypedInit(IK_ListInit, ListRecTy::get(EltTy)),
- NumValues(Elements.size()) {
+ NumElements(Elements.size()) {
llvm::uninitialized_copy(Elements, getTrailingObjects());
}
@@ -729,7 +730,7 @@ const ListInit *ListInit::get(ArrayRef<const Init *> Elements,
void ListInit::Profile(FoldingSetNodeID &ID) const {
const RecTy *EltTy = cast<ListRecTy>(getType())->getElementType();
- ProfileListInit(ID, getValues(), EltTy);
+ ProfileListInit(ID, getElements(), EltTy);
}
const Init *ListInit::convertInitializerTo(const RecTy *Ty) const {
@@ -738,13 +739,13 @@ const Init *ListInit::convertInitializerTo(const RecTy *Ty) const {
if (const auto *LRT = dyn_cast<ListRecTy>(Ty)) {
SmallVector<const Init *, 8> Elements;
- Elements.reserve(getValues().size());
+ Elements.reserve(size());
// Verify that all of the elements of the list are subclasses of the
// appropriate class!
bool Changed = false;
const RecTy *ElementType = LRT->getElementType();
- for (const Init *I : getValues())
+ for (const Init *I : getElements())
if (const Init *CI = I->convertInitializerTo(ElementType)) {
Elements.push_back(CI);
if (CI != I)
@@ -773,7 +774,7 @@ const Init *ListInit::resolveReferences(Resolver &R) const {
Resolved.reserve(size());
bool Changed = false;
- for (const Init *CurElt : getValues()) {
+ for (const Init *CurElt : getElements()) {
const Init *E = CurElt->resolveReferences(R);
Changed |= E != CurElt;
Resolved.push_back(E);
@@ -944,9 +945,10 @@ const Init *UnOpInit::Fold(const Record *CurRec, bool IsFinal) const {
case TAIL:
if (const auto *LHSl = dyn_cast<ListInit>(LHS)) {
assert(!LHSl->empty() && "Empty list in tail");
- // Note the +1. We can't just pass the result of getValues()
+ // Note the slice(1). We can't just pass the result of getElements()
// directly.
- return ListInit::get(LHSl->getValues().slice(1), LHSl->getElementType());
+ return ListInit::get(LHSl->getElements().slice(1),
+ LHSl->getElementType());
}
break;
@@ -1012,11 +1014,11 @@ const Init *UnOpInit::Fold(const Record *CurRec, bool IsFinal) const {
[](const ListInit *List) -> std::optional<std::vector<const Init *>> {
std::vector<const Init *> Flattened;
// Concatenate elements of all the inner lists.
- for (const Init *InnerInit : List->getValues()) {
+ for (const Init *InnerInit : List->getElements()) {
const auto *InnerList = dyn_cast<ListInit>(InnerInit);
if (!InnerList)
return std::nullopt;
- llvm::append_range(Flattened, InnerList->getValues());
+ llvm::append_range(Flattened, InnerList->getElements());
};
return Flattened;
};
@@ -1116,7 +1118,7 @@ static const StringInit *interleaveStringList(const ListInit *List,
SmallString<80> Result(Element->getValue());
StringInit::StringFormat Fmt = StringInit::SF_String;
- for (const Init *Elem : List->getValues().drop_front()) {
+ for (const Init *Elem : List->getElements().drop_front()) {
Result.append(Delim->getValue());
const auto *Element = dyn_cast<StringInit>(Elem);
if (!Element)
@@ -1138,7 +1140,7 @@ static const StringInit *interleaveIntList(const ListInit *List,
return nullptr;
SmallString<80> Result(Element->getAsString());
- for (const Init *Elem : List->getValues().drop_front()) {
+ for (const Init *Elem : List->getElements().drop_front()) {
Result.append(Delim->getValue());
const auto *Element = dyn_cast_or_null<IntInit>(
Elem->convertInitializerTo(IntRecTy::get(RK)));
@@ -1720,7 +1722,7 @@ static const Init *FilterHelper(const Init *LHS, const Init *MHS,
if (const auto *MHSl = dyn_cast<ListInit>(MHS)) {
SmallVector<const Init *, 8> NewList;
- for (const Init *Item : MHSl->getValues()) {
+ for (const Init *Item : MHSl->getElements()) {
const Init *Include = ItemApply(LHS, Item, RHS, CurRec);
if (!Include)
return nullptr;
@@ -3092,7 +3094,7 @@ std::vector<const Record *>
Record::getValueAsListOfDefs(StringRef FieldName) const {
const ListInit *List = getValueAsListInit(FieldName);
std::vector<const Record *> Defs;
- for (const Init *I : List->getValues()) {
+ for (const Init *I : List->getElements()) {
if (const auto *DI = dyn_cast<DefInit>(I))
Defs.push_back(DI->getDef());
else
@@ -3121,7 +3123,7 @@ std::vector<int64_t>
Record::getValueAsListOfInts(StringRef FieldName) const {
const ListInit *List = getValueAsListInit(FieldName);
std::vector<int64_t> Ints;
- for (const Init *I : List->getValues()) {
+ for (const Init *I : List->getElements()) {
if (const auto *II = dyn_cast<IntInit>(I))
Ints.push_back(II->getValue());
else
@@ -3137,7 +3139,7 @@ std::vector<StringRef>
Record::getValueAsListOfStrings(StringRef FieldName) const {
const ListInit *List = getValueAsListInit(FieldName);
std::vector<StringRef> Strings;
- for (const Init *I : List->getValues()) {
+ for (const Init *I : List->getElements()) {
if (const auto *SI = dyn_cast<StringInit>(I))
Strings.push_back(SI->getValue());
else
diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
index 1e8f3ed01635f..2771facb004cc 100644
--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
@@ -1402,7 +1402,7 @@ void AsmMatcherInfo::buildOperandClasses() {
CI->Kind = ClassInfo::UserClass0 + Index;
const ListInit *Supers = Rec->getValueAsListInit("SuperClasses");
- for (const Init *I : Supers->getValues()) {
+ for (const Init *I : Supers->getElements()) {
const DefInit *DI = dyn_cast<DefInit>(I);
if (!DI) {
PrintError(Rec->getLoc(), "Invalid super class reference!");
diff --git a/llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp b/llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp
index e7fc5250bf9d8..897788fe0f91e 100644
--- a/llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp
+++ b/llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp
@@ -301,7 +301,7 @@ static TypeSigTy ComputeTypeSignature(const CodeGenIntrinsic &Int) {
const Record *TypeInfo = Int.TheDef->getValueAsDef("TypeInfo");
const ListInit *TypeList = TypeInfo->getValueAsListInit("TypeSig");
- for (const auto *TypeListEntry : TypeList->getValues())
+ for (const auto *TypeListEntry : TypeList->getElements())
TypeSig.emplace_back(cast<IntInit>(TypeListEntry)->getValue());
return TypeSig;
}
diff --git a/llvm/utils/TableGen/CallingConvEmitter.cpp b/llvm/utils/TableGen/CallingConvEmitter.cpp
index 6a2a2442a6044..3084d90d444aa 100644
--- a/llvm/utils/TableGen/CallingConvEmitter.cpp
+++ b/llvm/utils/TableGen/CallingConvEmitter.cpp
@@ -154,7 +154,7 @@ void CallingConvEmitter::emitAction(const Record *Action, indent Indent,
O << Indent << "static const MCPhysReg " << RLName << "[] = {\n";
O << Indent << " ";
ListSeparator LS;
- for (const Init *V : RL->getValues())
+ for (const Init *V : RL->getElements())
O << LS << getQualifiedRegisterName(V);
O << "\n" << Indent << "};\n";
};
diff --git a/llvm/utils/TableGen/CodeGenMapTable.cpp b/llvm/utils/TableGen/CodeGenMapTable.cpp
index bce7278bf901c..eccd1aff422d0 100644
--- a/llvm/utils/TableGen/CodeGenMapTable.cpp
+++ b/llvm/utils/TableGen/CodeGenMapTable.cpp
@@ -137,7 +137,7 @@ class InstrMap {
"' has empty " +
"`ValueCols' field!");
- for (const Init *I : ColValList->getValues()) {
+ for (const Init *I : ColValList->getElements()) {
const auto *ColI = cast<ListInit>(I);
// Make sure that all the sub-lists in 'ValueCols' have same number of
@@ -228,7 +228,7 @@ void MapTableEmitter::buildRowInstrMap() {
for (const Record *CurInstr : InstrDefs) {
std::vector<const Init *> KeyValue;
const ListInit *RowFields = InstrMapDesc.getRowFields();
- for (const Init *RowField : RowFields->getValues()) {
+ for (const Init *RowField : RowFields->getElements()) {
const RecordVal *RecVal = CurInstr->getValue(RowField);
if (RecVal == nullptr)
PrintFatalError(CurInstr->getLoc(),
@@ -303,7 +303,7 @@ const Record *MapTableEmitter::getInstrForColumn(const Record *KeyInstr,
std::vector<const Init *> KeyValue;
// Construct KeyValue using KeyInstr's values for RowFields.
- for (const Init *RowField : RowFields->getValues()) {
+ for (const Init *RowField : RowFields->getElements()) {
const Init *KeyInstrVal = KeyInstr->getValue(RowField)->getValue();
KeyValue.push_back(KeyInstrVal);
}
@@ -475,7 +475,7 @@ void MapTableEmitter::emitTablesWithFunc(raw_ostream &OS) {
OS << "// " << InstrMapDesc.getName() << "\nLLVM_READONLY\n";
OS << "int " << InstrMapDesc.getName() << "(uint16_t Opcode";
if (ValueCols.size() > 1) {
- for (const Init *CF : ColFields->getValues()) {
+ for (const Init *CF : ColFields->getElements()) {
std::string ColName = CF->getAsUnquotedString();
OS << ", enum " << ColName << " in" << ColName;
}
diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
index 45f144627ac30..f03cbd9a170e2 100644
--- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
@@ -1012,7 +1012,7 @@ std::string TreePredicateFn::getPredCode() const {
" if (";
ListSeparator LS(" && ");
- for (const Init *Val : AddressSpaces->getValues()) {
+ for (const Init *Val : AddressSpaces->getElements()) {
Code += LS;
const IntInit *IntVal = dyn_cast<IntInit>(Val);
@@ -1489,7 +1489,7 @@ int PatternToMatch::getPatternComplexity(const CodeGenDAGPatterns &CGP) const {
void PatternToMatch::getPredicateRecords(
SmallVectorImpl<const Record *> &PredicateRecs) const {
- for (const Init *I : Predicates->getValues()) {
+ for (const Init *I : Predicates->getElements()) {
if (const DefInit *Pred = dyn_cast<DefInit>(I)) {
const Record *Def = Pred->getDef();
if (!Def->isSubClassOf("Predicate")) {
@@ -1934,7 +1934,7 @@ static unsigned GetNumNodeResults(const Record *Operator,
const ListInit *LI = Operator->getValueAsListInit("Fragments");
assert(LI && "Invalid Fragment");
unsigned NumResults = 0;
- for (const Init *I : LI->getValues()) {
+ for (const Init *I : LI->getElements()) {
const Record *Op = nullptr;
if (const DagInit *Dag = dyn_cast<DagInit>(I))
if (const DefInit *DI = dyn_cast<DefInit>(Dag->getOperator()))
@@ -2855,7 +2855,7 @@ TreePattern::TreePattern(const Record *TheRec, const ListInit *RawPat,
bool isInput, CodeGenDAGPatterns &cdp)
: TheRecord(TheRec), CDP(cdp), isInputPattern(isInput), HasError(false),
Infer(*this) {
- for (const Init *I : RawPat->getValues())
+ for (const Init *I : RawPat->getElements())
Trees.push_back(ParseTreePattern(I, ""));
}
@@ -3766,7 +3766,7 @@ static bool hasNullFragReference(const DagInit *DI) {
/// hasNullFragReference - Return true if any DAG in the list references
/// the null_frag operator.
static bool hasNullFragReference(const ListInit *LI) {
- for (const Init *I : LI->getValues()) {
+ for (const Init *I : LI->getElements()) {
const DagInit *DI = dyn_cast<DagInit>(I);
assert(DI && "non-dag in an instruction Pattern list?!");
if (hasNullFragReference(DI))
diff --git a/llvm/utils/TableGen/Common/CodeGenRegisters.cpp b/llvm/utils/TableGen/Common/CodeGenRegisters.cpp
index 3b7604a05fa88..a0e6be1e019d4 100644
--- a/llvm/utils/TableGen/Common/CodeGenRegisters.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenRegisters.cpp
@@ -771,7 +771,7 @@ CodeGenRegisterClass::CodeGenRegisterClass(CodeGenRegBank &RegBank,
// Alternative allocation orders may be subsets.
SetTheory::RecSet Order;
- for (auto [Idx, AltOrderElem] : enumerate(AltOrders->getValues())) {
+ for (auto [Idx, AltOrderElem] : enumerate(AltOrders->getElements())) {
RegBank.getSets().evaluate(AltOrderElem, Order, R->getLoc());
Orders[1 + Idx].append(Order.begin(), Order.end());
// Verify that all altorder members are regclass members.
diff --git a/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp b/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
index 9fcce0b80838e..090e6bb37c3aa 100644
--- a/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
@@ -1404,7 +1404,7 @@ bool CombineRuleBuilder::addFeaturePredicates(RuleMatcher &M) {
return true;
const ListInit *Preds = RuleDef.getValueAsListInit("Predicates");
- for (const Init *PI : Preds->getValues()) {
+ for (const Init *PI : Preds->getElements()) {
const DefInit *Pred = dyn_cast<DefInit>(PI);
if (!Pred)
continue;
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index 092dba58ad8b5..d516879f088d3 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -129,7 +129,7 @@ static std::string explainPredicates(const TreePatternNode &N) {
OS << " AddressSpaces=[";
StringRef AddrSpaceSeparator;
- for (const Init *Val : AddrSpaces->getValues()) {
+ for (const Init *Val : AddrSpaces->getElements()) {
const IntInit *IntVal = dyn_cast<IntInit>(Val);
if (!IntVal)
continue;
@@ -600,7 +600,7 @@ Expected<InstructionMatcher &> GlobalISelEmitter::addBuiltinPredicates(
if (const ListInit *AddrSpaces = Predicate.getAddressSpaces()) {
SmallVector<unsigned, 4> ParsedAddrSpaces;
- for (const Init *Val : AddrSpaces->getValues()) {
+ for (const Init *Val : AddrSpaces->getElements()) {
const IntInit *IntVal = dyn_cast<IntInit>(Val);
if (!IntVal)
return failedImport("Address space is not an integer");
diff --git a/llvm/utils/TableGen/OptionParserEmitter.cpp b/llvm/utils/TableGen/OptionParserEmitter.cpp
index ba99015657796..85b220070d1f3 100644
--- a/llvm/utils/TableGen/OptionParserEmitter.cpp
+++ b/llvm/utils/TableGen/OptionParserEmitter.cpp
@@ -501,7 +501,7 @@ static void emitOptionParser(const RecordKeeper &Records, raw_ostream &OS) {
for (const Record *VisibilityHelp :
R.getValueAsListOfDefs("HelpTextsForVariants")) {
ArrayRef<const Init *> Visibilities =
- VisibilityHelp->getValueAsListInit("Visibilities")->getValues();
+ VisibilityHelp->getValueAsListInit("Visibilities")->getElements();
std::vector<std::string> VisibilityNames;
for (const Init *Visibility : Visibilities)
@@ -523,11 +523,10 @@ static void emitOptionParser(const RecordKeeper &Records, raw_ostream &OS) {
OS << ", ";
if (!isa<UnsetInit>(R.getValueInit("Values")))
writeCstring(OS, R.getValueAsString("Values"));
- else if (!isa<UnsetInit>(R.getValueInit("ValuesCode"))) {
+ else if (!isa<UnsetInit>(R.getValueInit("ValuesCode")))
OS << getOptionName(R) << "_Values";
- } else {
+ else
OS << "nullptr";
- }
};
auto IsMarshallingOption = [](const Record &R) {
diff --git a/mlir/lib/TableGen/AttrOrTypeDef.cpp b/mlir/lib/TableGen/AttrOrTypeDef.cpp
index 08e4afe291d61..4659265e24bda 100644
--- a/mlir/lib/TableGen/AttrOrTypeDef.cpp
+++ b/mlir/lib/TableGen/AttrOrTypeDef.cpp
@@ -46,7 +46,7 @@ AttrOrTypeDef::AttrOrTypeDef(const Record *def) : def(def) {
const auto *builderList =
dyn_cast_or_null<ListInit>(def->getValueInit("builders"));
if (builderList && !builderList->...
[truncated]
|
|
I've landed 195e640 to fix the build failure from this PR. Thanks! |
Thanks so much! |
Rename
ListInit::getValues()togetElements()to better match with otherListInitmembers likegetElement. KeepgetValues()for existing downstream code but mark it deprecated.