mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-19 04:32:19 +00:00
[TableGen] Use range-based for loops. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238805 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
69aef63931
commit
a1bedd75a0
@ -504,8 +504,8 @@ Init *ListInit::convertInitializerTo(RecTy *Ty) const {
|
|||||||
|
|
||||||
// Verify that all of the elements of the list are subclasses of the
|
// Verify that all of the elements of the list are subclasses of the
|
||||||
// appropriate class!
|
// appropriate class!
|
||||||
for (unsigned i = 0, e = getSize(); i != e; ++i)
|
for (Init *I : getValues())
|
||||||
if (Init *CI = getElement(i)->convertInitializerTo(LRT->getElementType()))
|
if (Init *CI = I->convertInitializerTo(LRT->getElementType()))
|
||||||
Elements.push_back(CI);
|
Elements.push_back(CI);
|
||||||
else
|
else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -541,9 +541,8 @@ Init *ListInit::resolveReferences(Record &R, const RecordVal *RV) const {
|
|||||||
Resolved.reserve(getSize());
|
Resolved.reserve(getSize());
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
|
|
||||||
for (unsigned i = 0, e = getSize(); i != e; ++i) {
|
for (Init *CurElt : getValues()) {
|
||||||
Init *E;
|
Init *E;
|
||||||
Init *CurElt = getElement(i);
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
E = CurElt;
|
E = CurElt;
|
||||||
@ -1744,8 +1743,8 @@ std::vector<Record*>
|
|||||||
Record::getValueAsListOfDefs(StringRef FieldName) const {
|
Record::getValueAsListOfDefs(StringRef FieldName) const {
|
||||||
ListInit *List = getValueAsListInit(FieldName);
|
ListInit *List = getValueAsListInit(FieldName);
|
||||||
std::vector<Record*> Defs;
|
std::vector<Record*> Defs;
|
||||||
for (unsigned i = 0; i < List->getSize(); i++) {
|
for (Init *I : List->getValues()) {
|
||||||
if (DefInit *DI = dyn_cast<DefInit>(List->getElement(i)))
|
if (DefInit *DI = dyn_cast<DefInit>(I))
|
||||||
Defs.push_back(DI->getDef());
|
Defs.push_back(DI->getDef());
|
||||||
else
|
else
|
||||||
PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
|
PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
|
||||||
@ -1778,8 +1777,8 @@ std::vector<int64_t>
|
|||||||
Record::getValueAsListOfInts(StringRef FieldName) const {
|
Record::getValueAsListOfInts(StringRef FieldName) const {
|
||||||
ListInit *List = getValueAsListInit(FieldName);
|
ListInit *List = getValueAsListInit(FieldName);
|
||||||
std::vector<int64_t> Ints;
|
std::vector<int64_t> Ints;
|
||||||
for (unsigned i = 0; i < List->getSize(); i++) {
|
for (Init *I : List->getValues()) {
|
||||||
if (IntInit *II = dyn_cast<IntInit>(List->getElement(i)))
|
if (IntInit *II = dyn_cast<IntInit>(I))
|
||||||
Ints.push_back(II->getValue());
|
Ints.push_back(II->getValue());
|
||||||
else
|
else
|
||||||
PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
|
PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
|
||||||
@ -1796,9 +1795,9 @@ std::vector<std::string>
|
|||||||
Record::getValueAsListOfStrings(StringRef FieldName) const {
|
Record::getValueAsListOfStrings(StringRef FieldName) const {
|
||||||
ListInit *List = getValueAsListInit(FieldName);
|
ListInit *List = getValueAsListInit(FieldName);
|
||||||
std::vector<std::string> Strings;
|
std::vector<std::string> Strings;
|
||||||
for (unsigned i = 0; i < List->getSize(); i++) {
|
for (Init *I : List->getValues()) {
|
||||||
if (StringInit *II = dyn_cast<StringInit>(List->getElement(i)))
|
if (StringInit *SI = dyn_cast<StringInit>(I))
|
||||||
Strings.push_back(II->getValue());
|
Strings.push_back(SI->getValue());
|
||||||
else
|
else
|
||||||
PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
|
PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
|
||||||
FieldName + "' does not have a list of strings initializer!");
|
FieldName + "' does not have a list of strings initializer!");
|
||||||
|
@ -1249,8 +1249,8 @@ void AsmMatcherInfo::buildOperandClasses() {
|
|||||||
CI->Kind = ClassInfo::UserClass0 + Index;
|
CI->Kind = ClassInfo::UserClass0 + Index;
|
||||||
|
|
||||||
ListInit *Supers = Rec->getValueAsListInit("SuperClasses");
|
ListInit *Supers = Rec->getValueAsListInit("SuperClasses");
|
||||||
for (unsigned i = 0, e = Supers->getSize(); i != e; ++i) {
|
for (Init *I : Supers->getValues()) {
|
||||||
DefInit *DI = dyn_cast<DefInit>(Supers->getElement(i));
|
DefInit *DI = dyn_cast<DefInit>(I);
|
||||||
if (!DI) {
|
if (!DI) {
|
||||||
PrintError(Rec->getLoc(), "Invalid super class reference!");
|
PrintError(Rec->getLoc(), "Invalid super class reference!");
|
||||||
continue;
|
continue;
|
||||||
|
@ -842,8 +842,8 @@ getPatternComplexity(const CodeGenDAGPatterns &CGP) const {
|
|||||||
///
|
///
|
||||||
std::string PatternToMatch::getPredicateCheck() const {
|
std::string PatternToMatch::getPredicateCheck() const {
|
||||||
std::string PredicateCheck;
|
std::string PredicateCheck;
|
||||||
for (unsigned i = 0, e = Predicates->getSize(); i != e; ++i) {
|
for (Init *I : Predicates->getValues()) {
|
||||||
if (DefInit *Pred = dyn_cast<DefInit>(Predicates->getElement(i))) {
|
if (DefInit *Pred = dyn_cast<DefInit>(I)) {
|
||||||
Record *Def = Pred->getDef();
|
Record *Def = Pred->getDef();
|
||||||
if (!Def->isSubClassOf("Predicate")) {
|
if (!Def->isSubClassOf("Predicate")) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@ -1999,8 +1999,8 @@ bool TreePatternNode::canPatternMatch(std::string &Reason,
|
|||||||
TreePattern::TreePattern(Record *TheRec, ListInit *RawPat, bool isInput,
|
TreePattern::TreePattern(Record *TheRec, ListInit *RawPat, bool isInput,
|
||||||
CodeGenDAGPatterns &cdp) : TheRecord(TheRec), CDP(cdp),
|
CodeGenDAGPatterns &cdp) : TheRecord(TheRec), CDP(cdp),
|
||||||
isInputPattern(isInput), HasError(false) {
|
isInputPattern(isInput), HasError(false) {
|
||||||
for (unsigned i = 0, e = RawPat->getSize(); i != e; ++i)
|
for (Init *I : RawPat->getValues())
|
||||||
Trees.push_back(ParseTreePattern(RawPat->getElement(i), ""));
|
Trees.push_back(ParseTreePattern(I, ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
TreePattern::TreePattern(Record *TheRec, DagInit *Pat, bool isInput,
|
TreePattern::TreePattern(Record *TheRec, DagInit *Pat, bool isInput,
|
||||||
@ -2860,8 +2860,8 @@ static bool hasNullFragReference(DagInit *DI) {
|
|||||||
/// hasNullFragReference - Return true if any DAG in the list references
|
/// hasNullFragReference - Return true if any DAG in the list references
|
||||||
/// the null_frag operator.
|
/// the null_frag operator.
|
||||||
static bool hasNullFragReference(ListInit *LI) {
|
static bool hasNullFragReference(ListInit *LI) {
|
||||||
for (unsigned i = 0, e = LI->getSize(); i != e; ++i) {
|
for (Init *I : LI->getValues()) {
|
||||||
DagInit *DI = dyn_cast<DagInit>(LI->getElement(i));
|
DagInit *DI = dyn_cast<DagInit>(I);
|
||||||
assert(DI && "non-dag in an instruction Pattern list?!");
|
assert(DI && "non-dag in an instruction Pattern list?!");
|
||||||
if (hasNullFragReference(DI))
|
if (hasNullFragReference(DI))
|
||||||
return true;
|
return true;
|
||||||
|
@ -132,8 +132,8 @@ public:
|
|||||||
PrintFatalError(MapRec->getLoc(), "InstrMapping record `" +
|
PrintFatalError(MapRec->getLoc(), "InstrMapping record `" +
|
||||||
MapRec->getName() + "' has empty " + "`ValueCols' field!");
|
MapRec->getName() + "' has empty " + "`ValueCols' field!");
|
||||||
|
|
||||||
for (unsigned i = 0, e = ColValList->getSize(); i < e; i++) {
|
for (Init *I : ColValList->getValues()) {
|
||||||
ListInit *ColI = dyn_cast<ListInit>(ColValList->getElement(i));
|
ListInit *ColI = dyn_cast<ListInit>(I);
|
||||||
|
|
||||||
// Make sure that all the sub-lists in 'ValueCols' have same number of
|
// Make sure that all the sub-lists in 'ValueCols' have same number of
|
||||||
// elements as the fields in 'ColFields'.
|
// elements as the fields in 'ColFields'.
|
||||||
@ -239,13 +239,11 @@ public:
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
void MapTableEmitter::buildRowInstrMap() {
|
void MapTableEmitter::buildRowInstrMap() {
|
||||||
for (unsigned i = 0, e = InstrDefs.size(); i < e; i++) {
|
for (Record *CurInstr : InstrDefs) {
|
||||||
Record *CurInstr = InstrDefs[i];
|
|
||||||
std::vector<Init*> KeyValue;
|
std::vector<Init*> KeyValue;
|
||||||
ListInit *RowFields = InstrMapDesc.getRowFields();
|
ListInit *RowFields = InstrMapDesc.getRowFields();
|
||||||
for (unsigned j = 0, endRF = RowFields->getSize(); j < endRF; j++) {
|
for (Init *RowField : RowFields->getValues()) {
|
||||||
Init *RowFieldsJ = RowFields->getElement(j);
|
Init *CurInstrVal = CurInstr->getValue(RowField)->getValue();
|
||||||
Init *CurInstrVal = CurInstr->getValue(RowFieldsJ)->getValue();
|
|
||||||
KeyValue.push_back(CurInstrVal);
|
KeyValue.push_back(CurInstrVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,8 +287,7 @@ void MapTableEmitter::buildMapTable() {
|
|||||||
// constraints.
|
// constraints.
|
||||||
const std::vector<ListInit*> &ValueCols = InstrMapDesc.getValueCols();
|
const std::vector<ListInit*> &ValueCols = InstrMapDesc.getValueCols();
|
||||||
unsigned NumOfCols = ValueCols.size();
|
unsigned NumOfCols = ValueCols.size();
|
||||||
for (unsigned j = 0, endKI = KeyInstrVec.size(); j < endKI; j++) {
|
for (Record *CurKeyInstr : KeyInstrVec) {
|
||||||
Record *CurKeyInstr = KeyInstrVec[j];
|
|
||||||
std::vector<Record*> ColInstrVec(NumOfCols);
|
std::vector<Record*> ColInstrVec(NumOfCols);
|
||||||
|
|
||||||
// Find the column instruction based on the constraints for the column.
|
// Find the column instruction based on the constraints for the column.
|
||||||
@ -313,9 +310,8 @@ Record *MapTableEmitter::getInstrForColumn(Record *KeyInstr,
|
|||||||
std::vector<Init*> KeyValue;
|
std::vector<Init*> KeyValue;
|
||||||
|
|
||||||
// Construct KeyValue using KeyInstr's values for RowFields.
|
// Construct KeyValue using KeyInstr's values for RowFields.
|
||||||
for (unsigned j = 0, endRF = RowFields->getSize(); j < endRF; j++) {
|
for (Init *RowField : RowFields->getValues()) {
|
||||||
Init *RowFieldsJ = RowFields->getElement(j);
|
Init *KeyInstrVal = KeyInstr->getValue(RowField)->getValue();
|
||||||
Init *KeyInstrVal = KeyInstr->getValue(RowFieldsJ)->getValue();
|
|
||||||
KeyValue.push_back(KeyInstrVal);
|
KeyValue.push_back(KeyInstrVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,8 +474,8 @@ void MapTableEmitter::emitTablesWithFunc(raw_ostream &OS) {
|
|||||||
OS << "// "<< InstrMapDesc.getName() << "\n";
|
OS << "// "<< InstrMapDesc.getName() << "\n";
|
||||||
OS << "int "<< InstrMapDesc.getName() << "(uint16_t Opcode";
|
OS << "int "<< InstrMapDesc.getName() << "(uint16_t Opcode";
|
||||||
if (ValueCols.size() > 1) {
|
if (ValueCols.size() > 1) {
|
||||||
for (unsigned i = 0, e = ColFields->getSize(); i < e; i++) {
|
for (Init *CF : ColFields->getValues()) {
|
||||||
std::string ColName = ColFields->getElement(i)->getAsUnquotedString();
|
std::string ColName = CF->getAsUnquotedString();
|
||||||
OS << ", enum " << ColName << " in" << ColName << ") {\n";
|
OS << ", enum " << ColName << " in" << ColName << ") {\n";
|
||||||
}
|
}
|
||||||
} else { OS << ") {\n"; }
|
} else { OS << ") {\n"; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user