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

Side by Side Diff: src/IceCfgNode.cpp

Issue 1349833005: Improve use of CfgLocalAllocator and introduce containers that use it. (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/IceDefs.h » ('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 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 } 820 }
821 } 821 }
822 822
823 // ======================== Dump routines ======================== // 823 // ======================== Dump routines ======================== //
824 824
825 namespace { 825 namespace {
826 826
827 // Helper functions for emit(). 827 // Helper functions for emit().
828 828
829 void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node, 829 void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node,
830 bool IsLiveIn, std::vector<SizeT> &LiveRegCount) { 830 bool IsLiveIn, CfgVector<SizeT> &LiveRegCount) {
831 if (!BuildDefs::dump()) 831 if (!BuildDefs::dump())
832 return; 832 return;
833 Liveness *Liveness = Func->getLiveness(); 833 Liveness *Liveness = Func->getLiveness();
834 const LivenessBV *Live; 834 const LivenessBV *Live;
835 if (IsLiveIn) { 835 if (IsLiveIn) {
836 Live = &Liveness->getLiveIn(Node); 836 Live = &Liveness->getLiveIn(Node);
837 Str << "\t\t\t\t# LiveIn="; 837 Str << "\t\t\t\t# LiveIn=";
838 } else { 838 } else {
839 Live = &Liveness->getLiveOut(Node); 839 Live = &Liveness->getLiveOut(Node);
840 Str << "\t\t\t\t# LiveOut="; 840 Str << "\t\t\t\t# LiveOut=";
841 } 841 }
842 if (!Live->empty()) { 842 if (!Live->empty()) {
843 std::vector<Variable *> LiveRegs; 843 CfgVector<Variable *> LiveRegs;
844 for (SizeT i = 0; i < Live->size(); ++i) { 844 for (SizeT i = 0; i < Live->size(); ++i) {
845 if ((*Live)[i]) { 845 if ((*Live)[i]) {
846 Variable *Var = Liveness->getVariable(i, Node); 846 Variable *Var = Liveness->getVariable(i, Node);
847 if (Var->hasReg()) { 847 if (Var->hasReg()) {
848 if (IsLiveIn) 848 if (IsLiveIn)
849 ++LiveRegCount[Var->getRegNum()]; 849 ++LiveRegCount[Var->getRegNum()];
850 LiveRegs.push_back(Var); 850 LiveRegs.push_back(Var);
851 } 851 }
852 } 852 }
853 } 853 }
854 // Sort the variables by regnum so they are always printed in a familiar 854 // Sort the variables by regnum so they are always printed in a familiar
855 // order. 855 // order.
856 std::sort(LiveRegs.begin(), LiveRegs.end(), 856 std::sort(LiveRegs.begin(), LiveRegs.end(),
857 [](const Variable *V1, const Variable *V2) { 857 [](const Variable *V1, const Variable *V2) {
858 return V1->getRegNum() < V2->getRegNum(); 858 return V1->getRegNum() < V2->getRegNum();
859 }); 859 });
860 bool First = true; 860 bool First = true;
861 for (Variable *Var : LiveRegs) { 861 for (Variable *Var : LiveRegs) {
862 if (!First) 862 if (!First)
863 Str << ","; 863 Str << ",";
864 First = false; 864 First = false;
865 Var->emit(Func); 865 Var->emit(Func);
866 } 866 }
867 } 867 }
868 Str << "\n"; 868 Str << "\n";
869 } 869 }
870 870
871 void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr, 871 void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr,
872 std::vector<SizeT> &LiveRegCount) { 872 CfgVector<SizeT> &LiveRegCount) {
873 if (!BuildDefs::dump()) 873 if (!BuildDefs::dump())
874 return; 874 return;
875 bool First = true; 875 bool First = true;
876 Variable *Dest = Instr->getDest(); 876 Variable *Dest = Instr->getDest();
877 // Normally we increment the live count for the dest register. But we 877 // Normally we increment the live count for the dest register. But we
878 // shouldn't if the instruction's IsDestNonKillable flag is set, because this 878 // shouldn't if the instruction's IsDestNonKillable flag is set, because this
879 // means that the target lowering created this instruction as a non-SSA 879 // means that the target lowering created this instruction as a non-SSA
880 // assignment; i.e., a different, previous instruction started the dest 880 // assignment; i.e., a different, previous instruction started the dest
881 // variable's live range. 881 // variable's live range.
882 if (!Instr->isDestNonKillable() && Dest && Dest->hasReg()) 882 if (!Instr->isDestNonKillable() && Dest && Dest->hasReg())
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 Func->setCurrentNode(this); 928 Func->setCurrentNode(this);
929 Ostream &Str = Func->getContext()->getStrEmit(); 929 Ostream &Str = Func->getContext()->getStrEmit();
930 Liveness *Liveness = Func->getLiveness(); 930 Liveness *Liveness = Func->getLiveness();
931 bool DecorateAsm = 931 bool DecorateAsm =
932 Liveness && Func->getContext()->getFlags().getDecorateAsm(); 932 Liveness && Func->getContext()->getFlags().getDecorateAsm();
933 Str << getAsmName() << ":\n"; 933 Str << getAsmName() << ":\n";
934 // LiveRegCount keeps track of the number of currently live variables that 934 // LiveRegCount keeps track of the number of currently live variables that
935 // each register is assigned to. Normally that would be only 0 or 1, but the 935 // each register is assigned to. Normally that would be only 0 or 1, but the
936 // register allocator's AllowOverlap inference allows it to be greater than 1 936 // register allocator's AllowOverlap inference allows it to be greater than 1
937 // for short periods. 937 // for short periods.
938 std::vector<SizeT> LiveRegCount(Func->getTarget()->getNumRegisters()); 938 CfgVector<SizeT> LiveRegCount(Func->getTarget()->getNumRegisters());
939 if (DecorateAsm) { 939 if (DecorateAsm) {
940 constexpr bool IsLiveIn = true; 940 constexpr bool IsLiveIn = true;
941 emitRegisterUsage(Str, Func, this, IsLiveIn, LiveRegCount); 941 emitRegisterUsage(Str, Func, this, IsLiveIn, LiveRegCount);
942 } 942 }
943 943
944 for (const Inst &I : Phis) { 944 for (const Inst &I : Phis) {
945 if (I.isDeleted()) 945 if (I.isDeleted())
946 continue; 946 continue;
947 // Emitting a Phi instruction should cause an error. 947 // Emitting a Phi instruction should cause an error.
948 I.emit(Func); 948 I.emit(Func);
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 InstIntrinsicCall *Inst = InstIntrinsicCall::create( 1303 InstIntrinsicCall *Inst = InstIntrinsicCall::create(
1304 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); 1304 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info);
1305 Inst->addArg(AtomicRMWOp); 1305 Inst->addArg(AtomicRMWOp);
1306 Inst->addArg(Counter); 1306 Inst->addArg(Counter);
1307 Inst->addArg(One); 1307 Inst->addArg(One);
1308 Inst->addArg(OrderAcquireRelease); 1308 Inst->addArg(OrderAcquireRelease);
1309 Insts.push_front(Inst); 1309 Insts.push_front(Inst);
1310 } 1310 }
1311 1311
1312 } // end of namespace Ice 1312 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfg.cpp ('k') | src/IceDefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698