Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/utils/TableGen/ClangOptionDocEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down
6 changes: 3 additions & 3 deletions clang/utils/TableGen/NeonEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down Expand Up @@ -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)) {
Expand Down
19 changes: 11 additions & 8 deletions llvm/include/llvm/TableGen/Record.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *;
Expand All @@ -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();
Expand All @@ -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");
Expand Down
40 changes: 21 additions & 19 deletions llvm/lib/TableGen/Record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand All @@ -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 {
Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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)
Expand All @@ -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)));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/AsmMatcherEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/CallingConvEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
Expand Down
8 changes: 4 additions & 4 deletions llvm/utils/TableGen/CodeGenMapTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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")) {
Expand Down Expand Up @@ -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()))
Expand Down Expand Up @@ -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, ""));
}

Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/Common/CodeGenRegisters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions llvm/utils/TableGen/GlobalISelEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
7 changes: 3 additions & 4 deletions llvm/utils/TableGen/OptionParserEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/TableGen/AttrOrTypeDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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->empty()) {
for (const Init *init : builderList->getValues()) {
for (const Init *init : builderList->getElements()) {
AttrOrTypeBuilder builder(cast<DefInit>(init)->getDef(), def->getLoc());

// Ensure that all parameters have names.
Expand Down
Loading