1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-21 18:22:53 +01:00

[TableGen] Use range-based for loops (NFC)

This commit is contained in:
Kazu Hirata 2021-02-01 20:55:08 -08:00
parent 8694450fb2
commit e420343cf4
6 changed files with 14 additions and 21 deletions

View File

@ -1100,8 +1100,8 @@ bool MatchableInfo::validate(StringRef CommentDelimiter, bool IsAlias) const {
static std::string getEnumNameForToken(StringRef Str) {
std::string Res;
for (StringRef::iterator it = Str.begin(), ie = Str.end(); it != ie; ++it) {
switch (*it) {
for (char C : Str) {
switch (C) {
case '*': Res += "_STAR_"; break;
case '%': Res += "_PCT_"; break;
case ':': Res += "_COLON_"; break;
@ -1112,10 +1112,10 @@ static std::string getEnumNameForToken(StringRef Str) {
case '-': Res += "_MINUS_"; break;
case '#': Res += "_HASH_"; break;
default:
if (isAlnum(*it))
Res += *it;
if (isAlnum(C))
Res += C;
else
Res += "_" + utostr((unsigned) *it) + "_";
Res += "_" + utostr((unsigned)C) + "_";
}
}

View File

@ -461,9 +461,7 @@ void CodeEmitterGen::run(raw_ostream &o) {
std::map<std::string, std::vector<std::string>> CaseMap;
// Construct all cases statement for each opcode
for (std::vector<Record*>::iterator IC = Insts.begin(), EC = Insts.end();
IC != EC; ++IC) {
Record *R = *IC;
for (Record *R : Insts) {
if (R->getValueAsString("Namespace") == "TargetOpcode" ||
R->getValueAsBit("isPseudo"))
continue;

View File

@ -4032,8 +4032,7 @@ void CodeGenDAGPatterns::InferInstructionFlags() {
/// Verify instruction flags against pattern node properties.
void CodeGenDAGPatterns::VerifyInstructionFlags() {
unsigned Errors = 0;
for (ptm_iterator I = ptm_begin(), E = ptm_end(); I != E; ++I) {
const PatternToMatch &PTM = *I;
for (const PatternToMatch &PTM : ptms()) {
SmallVector<Record*, 8> Instrs;
getInstructionsInTree(PTM.getDstPattern(), Instrs);
if (Instrs.empty())

View File

@ -738,9 +738,8 @@ namespace llvm {
// Get the sum of unit weights.
unsigned getRegUnitSetWeight(const std::vector<unsigned> &Units) const {
unsigned Weight = 0;
for (std::vector<unsigned>::const_iterator
I = Units.begin(), E = Units.end(); I != E; ++I)
Weight += getRegUnit(*I).Weight;
for (unsigned Unit : Units)
Weight += getRegUnit(Unit).Weight;
return Weight;
}

View File

@ -153,9 +153,8 @@ void DAGISelEmitter::run(raw_ostream &OS) {
// Add all the patterns to a temporary list so we can sort them.
Records.startTimer("Sort patterns");
std::vector<const PatternToMatch*> Patterns;
for (CodeGenDAGPatterns::ptm_iterator I = CGP.ptm_begin(), E = CGP.ptm_end();
I != E; ++I)
Patterns.push_back(&*I);
for (const PatternToMatch &PTM : CGP.ptms())
Patterns.push_back(&PTM);
// We want to process the matches in order of minimal cost. Sort the patterns
// so the least cost one is at the start.

View File

@ -179,8 +179,8 @@ void SubtargetEmitter::Enumeration(raw_ostream &OS,
static void printFeatureMask(raw_ostream &OS, RecVec &FeatureList,
const DenseMap<Record *, unsigned> &FeatureMap) {
std::array<uint64_t, MAX_SUBTARGET_WORDS> Mask = {};
for (unsigned j = 0, M = FeatureList.size(); j < M; ++j) {
unsigned Bit = FeatureMap.lookup(FeatureList[j]);
for (const Record *Feature : FeatureList) {
unsigned Bit = FeatureMap.lookup(Feature);
Mask[Bit / 64] |= 1ULL << (Bit % 64);
}
@ -215,10 +215,8 @@ unsigned SubtargetEmitter::FeatureKeyValues(
// For each feature
unsigned NumFeatures = 0;
for (unsigned i = 0, N = FeatureList.size(); i < N; ++i) {
for (const Record *Feature : FeatureList) {
// Next feature
Record *Feature = FeatureList[i];
StringRef Name = Feature->getName();
StringRef CommandLineName = Feature->getValueAsString("Name");
StringRef Desc = Feature->getValueAsString("Desc");