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

Side by Side Diff: src/IceCfgNode.cpp

Issue 1521863002: Subzero: Fix mid-line comments when using -asm-verbose . (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix lit tests Created 5 years 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 | « no previous file | src/IceInstX86BaseImpl.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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node, 910 void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node,
911 bool IsLiveIn, CfgVector<SizeT> &LiveRegCount) { 911 bool IsLiveIn, CfgVector<SizeT> &LiveRegCount) {
912 if (!BuildDefs::dump()) 912 if (!BuildDefs::dump())
913 return; 913 return;
914 Liveness *Liveness = Func->getLiveness(); 914 Liveness *Liveness = Func->getLiveness();
915 const LivenessBV *Live; 915 const LivenessBV *Live;
916 const int32_t StackReg = Func->getTarget()->getStackReg(); 916 const int32_t StackReg = Func->getTarget()->getStackReg();
917 const int32_t FrameOrStackReg = Func->getTarget()->getFrameOrStackReg(); 917 const int32_t FrameOrStackReg = Func->getTarget()->getFrameOrStackReg();
918 if (IsLiveIn) { 918 if (IsLiveIn) {
919 Live = &Liveness->getLiveIn(Node); 919 Live = &Liveness->getLiveIn(Node);
920 Str << "\t\t\t\t# LiveIn="; 920 Str << "\t\t\t\t/* LiveIn=";
921 } else { 921 } else {
922 Live = &Liveness->getLiveOut(Node); 922 Live = &Liveness->getLiveOut(Node);
923 Str << "\t\t\t\t# LiveOut="; 923 Str << "\t\t\t\t/* LiveOut=";
924 } 924 }
925 if (!Live->empty()) { 925 if (!Live->empty()) {
926 CfgVector<Variable *> LiveRegs; 926 CfgVector<Variable *> LiveRegs;
927 for (SizeT i = 0; i < Live->size(); ++i) { 927 for (SizeT i = 0; i < Live->size(); ++i) {
928 if (!(*Live)[i]) 928 if (!(*Live)[i])
929 continue; 929 continue;
930 Variable *Var = Liveness->getVariable(i, Node); 930 Variable *Var = Liveness->getVariable(i, Node);
931 if (!Var->hasReg()) 931 if (!Var->hasReg())
932 continue; 932 continue;
933 const int32_t RegNum = Var->getRegNum(); 933 const int32_t RegNum = Var->getRegNum();
(...skipping 10 matching lines...) Expand all
944 return V1->getRegNum() < V2->getRegNum(); 944 return V1->getRegNum() < V2->getRegNum();
945 }); 945 });
946 bool First = true; 946 bool First = true;
947 for (Variable *Var : LiveRegs) { 947 for (Variable *Var : LiveRegs) {
948 if (!First) 948 if (!First)
949 Str << ","; 949 Str << ",";
950 First = false; 950 First = false;
951 Var->emit(Func); 951 Var->emit(Func);
952 } 952 }
953 } 953 }
954 Str << "\n"; 954 Str << " */\n";
955 } 955 }
956 956
957 /// Returns true if some text was emitted - in which case the caller definitely 957 /// Returns true if some text was emitted - in which case the caller definitely
958 /// needs to emit a newline character. 958 /// needs to emit a newline character.
959 bool emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr, 959 bool emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr,
960 CfgVector<SizeT> &LiveRegCount) { 960 CfgVector<SizeT> &LiveRegCount) {
961 bool Printed = false; 961 bool Printed = false;
962 if (!BuildDefs::dump()) 962 if (!BuildDefs::dump())
963 return Printed; 963 return Printed;
964 Variable *Dest = Instr->getDest(); 964 Variable *Dest = Instr->getDest();
965 // Normally we increment the live count for the dest register. But we 965 // Normally we increment the live count for the dest register. But we
966 // shouldn't if the instruction's IsDestRedefined flag is set, because this 966 // shouldn't if the instruction's IsDestRedefined flag is set, because this
967 // means that the target lowering created this instruction as a non-SSA 967 // means that the target lowering created this instruction as a non-SSA
968 // assignment; i.e., a different, previous instruction started the dest 968 // assignment; i.e., a different, previous instruction started the dest
969 // variable's live range. 969 // variable's live range.
970 if (!Instr->isDestRedefined() && Dest && Dest->hasReg()) 970 if (!Instr->isDestRedefined() && Dest && Dest->hasReg())
971 ++LiveRegCount[Dest->getRegNum()]; 971 ++LiveRegCount[Dest->getRegNum()];
972 FOREACH_VAR_IN_INST(Var, *Instr) { 972 FOREACH_VAR_IN_INST(Var, *Instr) {
973 bool ShouldReport = Instr->isLastUse(Var); 973 bool ShouldReport = Instr->isLastUse(Var);
974 if (ShouldReport && Var->hasReg()) { 974 if (ShouldReport && Var->hasReg()) {
975 // Don't report end of live range until the live count reaches 0. 975 // Don't report end of live range until the live count reaches 0.
976 SizeT NewCount = --LiveRegCount[Var->getRegNum()]; 976 SizeT NewCount = --LiveRegCount[Var->getRegNum()];
977 if (NewCount) 977 if (NewCount)
978 ShouldReport = false; 978 ShouldReport = false;
979 } 979 }
980 if (ShouldReport) { 980 if (ShouldReport) {
981 if (Printed) 981 if (Printed)
982 Str << ","; 982 Str << ",";
983 else 983 else
984 Str << " \t@ END="; 984 Str << " \t/* END=";
985 Var->emit(Func); 985 Var->emit(Func);
986 Printed = true; 986 Printed = true;
987 } 987 }
988 } 988 }
989 if (Printed)
990 Str << " */";
989 return Printed; 991 return Printed;
990 } 992 }
991 993
992 void updateStats(Cfg *Func, const Inst *I) { 994 void updateStats(Cfg *Func, const Inst *I) {
993 if (!BuildDefs::dump()) 995 if (!BuildDefs::dump())
994 return; 996 return;
995 // Update emitted instruction count, plus fill/spill count for Variable 997 // Update emitted instruction count, plus fill/spill count for Variable
996 // operands without a physical register. 998 // operands without a physical register.
997 if (uint32_t Count = I->getEmitInstCount()) { 999 if (uint32_t Count = I->getEmitInstCount()) {
998 Func->getContext()->statsUpdateEmitted(Count); 1000 Func->getContext()->statsUpdateEmitted(Count);
(...skipping 23 matching lines...) Expand all
1022 Str << getAsmName() << ":\n"; 1024 Str << getAsmName() << ":\n";
1023 // LiveRegCount keeps track of the number of currently live variables that 1025 // LiveRegCount keeps track of the number of currently live variables that
1024 // each register is assigned to. Normally that would be only 0 or 1, but the 1026 // each register is assigned to. Normally that would be only 0 or 1, but the
1025 // register allocator's AllowOverlap inference allows it to be greater than 1 1027 // register allocator's AllowOverlap inference allows it to be greater than 1
1026 // for short periods. 1028 // for short periods.
1027 CfgVector<SizeT> LiveRegCount(Func->getTarget()->getNumRegisters()); 1029 CfgVector<SizeT> LiveRegCount(Func->getTarget()->getNumRegisters());
1028 if (DecorateAsm) { 1030 if (DecorateAsm) {
1029 constexpr bool IsLiveIn = true; 1031 constexpr bool IsLiveIn = true;
1030 emitRegisterUsage(Str, Func, this, IsLiveIn, LiveRegCount); 1032 emitRegisterUsage(Str, Func, this, IsLiveIn, LiveRegCount);
1031 if (getInEdges().size()) { 1033 if (getInEdges().size()) {
1032 Str << "\t\t\t\t# preds="; 1034 Str << "\t\t\t\t/* preds=";
1033 bool First = true; 1035 bool First = true;
1034 for (CfgNode *I : getInEdges()) { 1036 for (CfgNode *I : getInEdges()) {
1035 if (!First) 1037 if (!First)
1036 Str << ","; 1038 Str << ",";
1037 First = false; 1039 First = false;
1038 Str << "$" << I->getName(); 1040 Str << "$" << I->getName();
1039 } 1041 }
1040 Str << "\n"; 1042 Str << " */\n";
1041 } 1043 }
1042 if (getLoopNestDepth()) { 1044 if (getLoopNestDepth()) {
1043 Str << "\t\t\t\t# loop depth=" << getLoopNestDepth() << "\n"; 1045 Str << "\t\t\t\t/* loop depth=" << getLoopNestDepth() << " */\n";
1044 } 1046 }
1045 } 1047 }
1046 1048
1047 for (const Inst &I : Phis) { 1049 for (const Inst &I : Phis) {
1048 if (I.isDeleted()) 1050 if (I.isDeleted())
1049 continue; 1051 continue;
1050 // Emitting a Phi instruction should cause an error. 1052 // Emitting a Phi instruction should cause an error.
1051 I.emit(Func); 1053 I.emit(Func);
1052 } 1054 }
1053 for (const Inst &I : Insts) { 1055 for (const Inst &I : Insts) {
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 auto *Inst = InstIntrinsicCall::create( 1409 auto *Inst = InstIntrinsicCall::create(
1408 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); 1410 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info);
1409 Inst->addArg(AtomicRMWOp); 1411 Inst->addArg(AtomicRMWOp);
1410 Inst->addArg(Counter); 1412 Inst->addArg(Counter);
1411 Inst->addArg(One); 1413 Inst->addArg(One);
1412 Inst->addArg(OrderAcquireRelease); 1414 Inst->addArg(OrderAcquireRelease);
1413 Insts.push_front(Inst); 1415 Insts.push_front(Inst);
1414 } 1416 }
1415 1417
1416 } // end of namespace Ice 1418 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | src/IceInstX86BaseImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698