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

Side by Side Diff: src/IceCfgNode.cpp

Issue 1312433004: Weight variables by their number of uses for register allocation. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « src/IceCfg.cpp ('k') | src/IceLiveness.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) implementation -----===// 1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) implementation -----===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 // i1<i2, then i1's live range begins at instruction IBB->second 693 // i1<i2, then i1's live range begins at instruction IBB->second
694 // and extends through the end of the block. If i1>i2, then i2's 694 // and extends through the end of the block. If i1>i2, then i2's
695 // live range begins at the first instruction of the block and 695 // live range begins at the first instruction of the block and
696 // ends at IEB->second. In any case, we choose the lesser of i1 696 // ends at IEB->second. In any case, we choose the lesser of i1
697 // and i2 and proceed accordingly. 697 // and i2 and proceed accordingly.
698 InstNumberT LB = i == i1 ? IBB->second : FirstInstNum; 698 InstNumberT LB = i == i1 ? IBB->second : FirstInstNum;
699 InstNumberT LE = i == i2 ? IEB->second : LastInstNum + 1; 699 InstNumberT LE = i == i2 ? IEB->second : LastInstNum + 1;
700 700
701 Variable *Var = Liveness->getVariable(i, this); 701 Variable *Var = Liveness->getVariable(i, this);
702 if (LB > LE) { 702 if (LB > LE) {
703 Var->addLiveRange(FirstInstNum, LE, 1); 703 Var->addLiveRange(FirstInstNum, LE);
704 Var->addLiveRange(LB, LastInstNum + 1, 1); 704 Var->addLiveRange(LB, LastInstNum + 1);
705 // Assert that Var is a global variable by checking that its 705 // Assert that Var is a global variable by checking that its
706 // liveness index is less than the number of globals. This 706 // liveness index is less than the number of globals. This
707 // ensures that the LiveInAndOut[] access is valid. 707 // ensures that the LiveInAndOut[] access is valid.
708 assert(i < Liveness->getNumGlobalVars()); 708 assert(i < Liveness->getNumGlobalVars());
709 LiveInAndOut[i] = false; 709 LiveInAndOut[i] = false;
710 } else { 710 } else {
711 Var->addLiveRange(LB, LE, 1); 711 Var->addLiveRange(LB, LE);
712 } 712 }
713 if (i == i1) 713 if (i == i1)
714 ++IBB; 714 ++IBB;
715 if (i == i2) 715 if (i == i2)
716 ++IEB; 716 ++IEB;
717 } 717 }
718 // Process the variables that are live across the entire block. 718 // Process the variables that are live across the entire block.
719 for (int i = LiveInAndOut.find_first(); i != -1; 719 for (int i = LiveInAndOut.find_first(); i != -1;
720 i = LiveInAndOut.find_next(i)) { 720 i = LiveInAndOut.find_next(i)) {
721 Variable *Var = Liveness->getVariable(i, this); 721 Variable *Var = Liveness->getVariable(i, this);
722 if (Liveness->getRangeMask(Var->getIndex())) 722 if (Liveness->getRangeMask(Var->getIndex()))
723 Var->addLiveRange(FirstInstNum, LastInstNum + 1, 1); 723 Var->addLiveRange(FirstInstNum, LastInstNum + 1);
724 } 724 }
725 } 725 }
726 726
727 // If this node contains only deleted instructions, and ends in an 727 // If this node contains only deleted instructions, and ends in an
728 // unconditional branch, contract the node by repointing all its 728 // unconditional branch, contract the node by repointing all its
729 // in-edges to its successor. 729 // in-edges to its successor.
730 void CfgNode::contractIfEmpty() { 730 void CfgNode::contractIfEmpty() {
731 if (InEdges.empty()) 731 if (InEdges.empty())
732 return; 732 return;
733 Inst *Branch = nullptr; 733 Inst *Branch = nullptr;
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 InstIntrinsicCall *Inst = InstIntrinsicCall::create( 1277 InstIntrinsicCall *Inst = InstIntrinsicCall::create(
1278 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); 1278 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info);
1279 Inst->addArg(AtomicRMWOp); 1279 Inst->addArg(AtomicRMWOp);
1280 Inst->addArg(Counter); 1280 Inst->addArg(Counter);
1281 Inst->addArg(One); 1281 Inst->addArg(One);
1282 Inst->addArg(OrderAcquireRelease); 1282 Inst->addArg(OrderAcquireRelease);
1283 Insts.push_front(Inst); 1283 Insts.push_front(Inst);
1284 } 1284 }
1285 1285
1286 } // end of namespace Ice 1286 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfg.cpp ('k') | src/IceLiveness.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698