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

Side by Side Diff: src/IceCfgNode.cpp

Issue 700263003: Rearrange emit vs emitIAS. Wait till function is done before dumping text. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: remove comment... might end up using the iterator Created 6 years, 1 month 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/IceCfgNode.h ('k') | src/IceInstX8632.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 // This file implements the CfgNode class, including the complexities 10 // This file implements the CfgNode class, including the complexities
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 else 857 else
858 Str << ","; 858 Str << ",";
859 Var->emit(Func); 859 Var->emit(Func);
860 First = false; 860 First = false;
861 } 861 }
862 } 862 }
863 } 863 }
864 } 864 }
865 } 865 }
866 866
867 void updateStats(Cfg *Func, const Inst *I) {
868 // Update emitted instruction count, plus fill/spill count for
869 // Variable operands without a physical register.
870 if (uint32_t Count = I->getEmitInstCount()) {
871 Func->getContext()->statsUpdateEmitted(Count);
872 if (Variable *Dest = I->getDest()) {
873 if (!Dest->hasReg())
874 Func->getContext()->statsUpdateFills();
875 }
876 for (SizeT S = 0; S < I->getSrcSize(); ++S) {
877 if (Variable *Src = llvm::dyn_cast<Variable>(I->getSrc(S))) {
878 if (!Src->hasReg())
879 Func->getContext()->statsUpdateSpills();
880 }
881 }
882 }
883 }
884
867 } // end of anonymous namespace 885 } // end of anonymous namespace
868 886
869 void CfgNode::emit(Cfg *Func) const { 887 void CfgNode::emit(Cfg *Func) const {
870 Func->setCurrentNode(this); 888 Func->setCurrentNode(this);
871 Ostream &Str = Func->getContext()->getStrEmit(); 889 Ostream &Str = Func->getContext()->getStrEmit();
872 Liveness *Liveness = Func->getLiveness(); 890 Liveness *Liveness = Func->getLiveness();
873 bool DecorateAsm = Liveness && Func->getContext()->getFlags().DecorateAsm; 891 bool DecorateAsm = Liveness && Func->getContext()->getFlags().DecorateAsm;
874 if (Func->getEntryNode() == this) {
875 Str << Func->getContext()->mangleName(Func->getFunctionName()) << ":\n";
876 }
877 Str << getAsmName() << ":\n"; 892 Str << getAsmName() << ":\n";
878 if (Func->useIntegratedAssembler()) {
879 Assembler *Asm = Func->getAssembler<Assembler>();
880 Asm->BindCfgNodeLabel(getIndex());
881 }
882 std::vector<SizeT> LiveRegCount(Func->getTarget()->getNumRegisters()); 893 std::vector<SizeT> LiveRegCount(Func->getTarget()->getNumRegisters());
883 if (DecorateAsm) 894 if (DecorateAsm)
884 emitRegisterUsage(Str, Func, this, true, LiveRegCount); 895 emitRegisterUsage(Str, Func, this, true, LiveRegCount);
885 896
886 for (InstPhi *Phi : Phis) { 897 for (InstPhi *Phi : Phis) {
887 if (Phi->isDeleted()) 898 if (Phi->isDeleted())
888 continue; 899 continue;
889 // Emitting a Phi instruction should cause an error. 900 // Emitting a Phi instruction should cause an error.
890 Inst *Instr = Phi; 901 Inst *Instr = Phi;
891 Instr->emit(Func); 902 Instr->emit(Func);
892 } 903 }
893 for (Inst *I : Insts) { 904 for (Inst *I : Insts) {
894 if (I->isDeleted()) 905 if (I->isDeleted())
895 continue; 906 continue;
896 if (I->isRedundantAssign()) { 907 if (I->isRedundantAssign()) {
897 Variable *Dest = I->getDest(); 908 Variable *Dest = I->getDest();
898 if (DecorateAsm && Dest->hasReg() && !I->isLastUse(I->getSrc(0))) 909 if (DecorateAsm && Dest->hasReg() && !I->isLastUse(I->getSrc(0)))
899 ++LiveRegCount[Dest->getRegNum()]; 910 ++LiveRegCount[Dest->getRegNum()];
900 continue; 911 continue;
901 } 912 }
902 if (Func->useIntegratedAssembler()) { 913 I->emit(Func);
903 I->emitIAS(Func); 914 if (DecorateAsm)
904 } else { 915 emitLiveRangesEnded(Str, Func, I, LiveRegCount);
905 I->emit(Func); 916 Str << "\n";
906 if (DecorateAsm) 917 updateStats(Func, I);
907 emitLiveRangesEnded(Str, Func, I, LiveRegCount);
908 Str << "\n";
909 }
910 // Update emitted instruction count, plus fill/spill count for
911 // Variable operands without a physical register.
912 if (uint32_t Count = I->getEmitInstCount()) {
913 Func->getContext()->statsUpdateEmitted(Count);
914 if (Variable *Dest = I->getDest()) {
915 if (!Dest->hasReg())
916 Func->getContext()->statsUpdateFills();
917 }
918 for (SizeT S = 0; S < I->getSrcSize(); ++S) {
919 if (Variable *Src = llvm::dyn_cast<Variable>(I->getSrc(S))) {
920 if (!Src->hasReg())
921 Func->getContext()->statsUpdateSpills();
922 }
923 }
924 }
925 } 918 }
926 if (DecorateAsm) 919 if (DecorateAsm)
927 emitRegisterUsage(Str, Func, this, false, LiveRegCount); 920 emitRegisterUsage(Str, Func, this, false, LiveRegCount);
928 } 921 }
929 922
923 void CfgNode::emitIAS(Cfg *Func) const {
924 Func->setCurrentNode(this);
925 Assembler *Asm = Func->getAssembler<Assembler>();
926 Asm->BindCfgNodeLabel(getIndex());
927 for (InstPhi *Phi : Phis) {
928 if (Phi->isDeleted())
929 continue;
930 // Emitting a Phi instruction should cause an error.
931 Inst *Instr = Phi;
932 Instr->emitIAS(Func);
933 }
934 for (Inst *I : Insts) {
935 if (I->isDeleted())
936 continue;
937 if (I->isRedundantAssign())
938 continue;
939 I->emitIAS(Func);
940 updateStats(Func, I);
941 }
942 }
943
930 void CfgNode::dump(Cfg *Func) const { 944 void CfgNode::dump(Cfg *Func) const {
931 Func->setCurrentNode(this); 945 Func->setCurrentNode(this);
932 Ostream &Str = Func->getContext()->getStrDump(); 946 Ostream &Str = Func->getContext()->getStrDump();
933 Liveness *Liveness = Func->getLiveness(); 947 Liveness *Liveness = Func->getLiveness();
934 if (Func->getContext()->isVerbose(IceV_Instructions)) { 948 if (Func->getContext()->isVerbose(IceV_Instructions)) {
935 Str << getName() << ":\n"; 949 Str << getName() << ":\n";
936 } 950 }
937 // Dump list of predecessor nodes. 951 // Dump list of predecessor nodes.
938 if (Func->getContext()->isVerbose(IceV_Preds) && !InEdges.empty()) { 952 if (Func->getContext()->isVerbose(IceV_Preds) && !InEdges.empty()) {
939 Str << " // preds = "; 953 Str << " // preds = ";
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 if (!First) 1011 if (!First)
998 Str << ", "; 1012 Str << ", ";
999 First = false; 1013 First = false;
1000 Str << "%" << I->getName(); 1014 Str << "%" << I->getName();
1001 } 1015 }
1002 Str << "\n"; 1016 Str << "\n";
1003 } 1017 }
1004 } 1018 }
1005 1019
1006 } // end of namespace Ice 1020 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfgNode.h ('k') | src/IceInstX8632.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698