Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: src/IceTargetLoweringX8632.cpp

Issue 619893002: Subzero: Auto-awesome iterators. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add TODOs for rbegin/rend Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceTargetLoweringX8632.cpp
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index 3145aa7069287dd32d0c8902250794644fbd2759..5615e8c9803fea300fb415bd5067409cdcc78413 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -544,9 +544,7 @@ void TargetX8632::sortByAlignment(VarList &Dest, const VarList &Source) const {
X86_LOG2_OF_MAX_STACK_SLOT_SIZE - X86_LOG2_OF_MIN_STACK_SLOT_SIZE + 1;
VarList Buckets[NumBuckets];
- for (VarList::const_iterator I = Source.begin(), E = Source.end(); I != E;
- ++I) {
- Variable *Var = *I;
+ for (Variable *Var : Source) {
uint32_t NaturalAlignment = typeWidthInBytesOnStack(Var->getType());
SizeT LogNaturalAlignment = llvm::findFirstSet(NaturalAlignment);
assert(LogNaturalAlignment >= X86_LOG2_OF_MIN_STACK_SLOT_SIZE);
@@ -687,9 +685,7 @@ void TargetX8632::addProlog(CfgNode *Node) {
// The entire spill locations area gets aligned to largest natural
// alignment of the variables that have a spill slot.
uint32_t SpillAreaAlignmentBytes = 0;
- for (VarList::const_iterator I = Variables.begin(), E = Variables.end();
- I != E; ++I) {
- Variable *Var = *I;
+ for (Variable *Var : Variables) {
if (Var->hasReg()) {
RegsUsed[Var->getRegNum()] = true;
continue;
@@ -715,10 +711,7 @@ void TargetX8632::addProlog(CfgNode *Node) {
SortedSpilledVariables.reserve(SpilledVariables.size());
sortByAlignment(SortedSpilledVariables, SpilledVariables);
- for (VarList::const_iterator I = SortedSpilledVariables.begin(),
- E = SortedSpilledVariables.end();
- I != E; ++I) {
- Variable *Var = *I;
+ for (Variable *Var : SortedSpilledVariables) {
size_t Increment = typeWidthInBytesOnStack(Var->getType());
if (!SpillAreaAlignmentBytes)
SpillAreaAlignmentBytes = Increment;
@@ -826,10 +819,7 @@ void TargetX8632::addProlog(CfgNode *Node) {
size_t GlobalsSpaceUsed = SpillAreaPaddingBytes;
LocalsSize.assign(LocalsSize.size(), 0);
size_t NextStackOffset = GlobalsSpaceUsed;
- for (VarList::const_iterator I = SortedSpilledVariables.begin(),
- E = SortedSpilledVariables.end();
- I != E; ++I) {
- Variable *Var = *I;
+ for (Variable *Var : SortedSpilledVariables) {
size_t Increment = typeWidthInBytesOnStack(Var->getType());
if (SimpleCoalescing && VMetadata->isTracked(Var)) {
if (VMetadata->isMultiBlock(Var)) {
@@ -855,10 +845,7 @@ void TargetX8632::addProlog(CfgNode *Node) {
// Assign stack offsets to variables that have been linked to spilled
// variables.
- for (VarList::const_iterator I = VariablesLinkedToSpillSlots.begin(),
- E = VariablesLinkedToSpillSlots.end();
- I != E; ++I) {
- Variable *Var = *I;
+ for (Variable *Var : VariablesLinkedToSpillSlots) {
Variable *Linked = (llvm::cast<SpillVariable>(Var))->getLinkedTo();
Var->setStackOffset(Linked->getStackOffset());
}
@@ -893,6 +880,7 @@ void TargetX8632::addProlog(CfgNode *Node) {
void TargetX8632::addEpilog(CfgNode *Node) {
InstList &Insts = Node->getInsts();
InstList::reverse_iterator RI, E;
+ // TODO(stichnot): Use llvm::make_range with LLVM 3.5.
for (RI = Insts.rbegin(), E = Insts.rend(); RI != E; ++RI) {
if (llvm::isa<InstX8632Ret>(*RI))
break;
@@ -968,9 +956,8 @@ template <typename T> void TargetX8632::emitConstantPool() const {
Str << "\t.section\t.rodata.cst" << Align << ",\"aM\",@progbits," << Align
<< "\n";
Str << "\t.align\t" << Align << "\n";
- for (ConstantList::const_iterator I = Pool.begin(), E = Pool.end(); I != E;
- ++I) {
- typename T::IceType *Const = llvm::cast<typename T::IceType>(*I);
+ for (Constant *C : Pool) {
+ typename T::IceType *Const = llvm::cast<typename T::IceType>(C);
typename T::PrimitiveFpType Value = Const->getValue();
// Use memcpy() to copy bits from Value into RawValue in a way
// that avoids breaking strict-aliasing rules.
@@ -4322,9 +4309,7 @@ void TargetX8632::postLower() {
// The first pass also keeps track of which instruction is the last
// use for each infinite-weight variable. After the last use, the
// variable is released to the free list.
- for (InstList::iterator I = Context.getCur(), E = Context.getEnd(); I != E;
- ++I) {
- const Inst *Inst = *I;
+ for (Inst *Inst : Context) {
if (Inst->isDeleted())
continue;
// Don't consider a FakeKill instruction, because (currently) it
@@ -4356,10 +4341,8 @@ void TargetX8632::postLower() {
// The second pass colors infinite-weight variables.
llvm::SmallBitVector AvailableRegisters = WhiteList;
llvm::SmallBitVector FreedRegisters(WhiteList.size());
- for (InstList::iterator I = Context.getCur(), E = Context.getEnd(); I != E;
- ++I) {
+ for (Inst *Inst : Context) {
FreedRegisters.reset();
- const Inst *Inst = *I;
if (Inst->isDeleted())
continue;
// Skip FakeKill instructions like above.
« src/IceCfg.cpp ('K') | « src/IceTargetLowering.h ('k') | src/IceTimerTree.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698