| OLD | NEW |
| 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 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 } | 791 } |
| 792 | 792 |
| 793 // ======================== Dump routines ======================== // | 793 // ======================== Dump routines ======================== // |
| 794 | 794 |
| 795 namespace { | 795 namespace { |
| 796 | 796 |
| 797 // Helper functions for emit(). | 797 // Helper functions for emit(). |
| 798 | 798 |
| 799 void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node, | 799 void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node, |
| 800 bool IsLiveIn, std::vector<SizeT> &LiveRegCount) { | 800 bool IsLiveIn, std::vector<SizeT> &LiveRegCount) { |
| 801 if (!ALLOW_DUMP) |
| 802 return; |
| 801 Liveness *Liveness = Func->getLiveness(); | 803 Liveness *Liveness = Func->getLiveness(); |
| 802 const LivenessBV *Live; | 804 const LivenessBV *Live; |
| 803 if (IsLiveIn) { | 805 if (IsLiveIn) { |
| 804 Live = &Liveness->getLiveIn(Node); | 806 Live = &Liveness->getLiveIn(Node); |
| 805 Str << "\t\t\t\t# LiveIn="; | 807 Str << "\t\t\t\t# LiveIn="; |
| 806 } else { | 808 } else { |
| 807 Live = &Liveness->getLiveOut(Node); | 809 Live = &Liveness->getLiveOut(Node); |
| 808 Str << "\t\t\t\t# LiveOut="; | 810 Str << "\t\t\t\t# LiveOut="; |
| 809 } | 811 } |
| 810 if (!Live->empty()) { | 812 if (!Live->empty()) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 821 Var->emit(Func); | 823 Var->emit(Func); |
| 822 } | 824 } |
| 823 } | 825 } |
| 824 } | 826 } |
| 825 } | 827 } |
| 826 Str << "\n"; | 828 Str << "\n"; |
| 827 } | 829 } |
| 828 | 830 |
| 829 void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr, | 831 void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr, |
| 830 std::vector<SizeT> &LiveRegCount) { | 832 std::vector<SizeT> &LiveRegCount) { |
| 833 if (!ALLOW_DUMP) |
| 834 return; |
| 831 bool First = true; | 835 bool First = true; |
| 832 Variable *Dest = Instr->getDest(); | 836 Variable *Dest = Instr->getDest(); |
| 833 if (Dest && Dest->hasReg()) | 837 if (Dest && Dest->hasReg()) |
| 834 ++LiveRegCount[Dest->getRegNum()]; | 838 ++LiveRegCount[Dest->getRegNum()]; |
| 835 for (SizeT I = 0; I < Instr->getSrcSize(); ++I) { | 839 for (SizeT I = 0; I < Instr->getSrcSize(); ++I) { |
| 836 Operand *Src = Instr->getSrc(I); | 840 Operand *Src = Instr->getSrc(I); |
| 837 SizeT NumVars = Src->getNumVars(); | 841 SizeT NumVars = Src->getNumVars(); |
| 838 for (SizeT J = 0; J < NumVars; ++J) { | 842 for (SizeT J = 0; J < NumVars; ++J) { |
| 839 const Variable *Var = Src->getVar(J); | 843 const Variable *Var = Src->getVar(J); |
| 840 if (Var->hasReg()) { | 844 if (Var->hasReg()) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 866 if (!Src->hasReg()) | 870 if (!Src->hasReg()) |
| 867 Func->getContext()->statsUpdateSpills(); | 871 Func->getContext()->statsUpdateSpills(); |
| 868 } | 872 } |
| 869 } | 873 } |
| 870 } | 874 } |
| 871 } | 875 } |
| 872 | 876 |
| 873 } // end of anonymous namespace | 877 } // end of anonymous namespace |
| 874 | 878 |
| 875 void CfgNode::emit(Cfg *Func) const { | 879 void CfgNode::emit(Cfg *Func) const { |
| 880 if (!ALLOW_DUMP) |
| 881 return; |
| 876 Func->setCurrentNode(this); | 882 Func->setCurrentNode(this); |
| 877 Ostream &Str = Func->getContext()->getStrEmit(); | 883 Ostream &Str = Func->getContext()->getStrEmit(); |
| 878 Liveness *Liveness = Func->getLiveness(); | 884 Liveness *Liveness = Func->getLiveness(); |
| 879 bool DecorateAsm = Liveness && Func->getContext()->getFlags().DecorateAsm; | 885 bool DecorateAsm = Liveness && Func->getContext()->getFlags().DecorateAsm; |
| 880 Str << getAsmName() << ":\n"; | 886 Str << getAsmName() << ":\n"; |
| 881 std::vector<SizeT> LiveRegCount(Func->getTarget()->getNumRegisters()); | 887 std::vector<SizeT> LiveRegCount(Func->getTarget()->getNumRegisters()); |
| 882 if (DecorateAsm) | 888 if (DecorateAsm) |
| 883 emitRegisterUsage(Str, Func, this, true, LiveRegCount); | 889 emitRegisterUsage(Str, Func, this, true, LiveRegCount); |
| 884 | 890 |
| 885 for (InstPhi *Phi : Phis) { | 891 for (InstPhi *Phi : Phis) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 if (I->isDeleted()) | 929 if (I->isDeleted()) |
| 924 continue; | 930 continue; |
| 925 if (I->isRedundantAssign()) | 931 if (I->isRedundantAssign()) |
| 926 continue; | 932 continue; |
| 927 I->emitIAS(Func); | 933 I->emitIAS(Func); |
| 928 updateStats(Func, I); | 934 updateStats(Func, I); |
| 929 } | 935 } |
| 930 } | 936 } |
| 931 | 937 |
| 932 void CfgNode::dump(Cfg *Func) const { | 938 void CfgNode::dump(Cfg *Func) const { |
| 939 if (!ALLOW_DUMP) |
| 940 return; |
| 933 Func->setCurrentNode(this); | 941 Func->setCurrentNode(this); |
| 934 Ostream &Str = Func->getContext()->getStrDump(); | 942 Ostream &Str = Func->getContext()->getStrDump(); |
| 935 Liveness *Liveness = Func->getLiveness(); | 943 Liveness *Liveness = Func->getLiveness(); |
| 936 if (Func->getContext()->isVerbose(IceV_Instructions)) { | 944 if (Func->getContext()->isVerbose(IceV_Instructions)) { |
| 937 Str << getName() << ":\n"; | 945 Str << getName() << ":\n"; |
| 938 } | 946 } |
| 939 // Dump list of predecessor nodes. | 947 // Dump list of predecessor nodes. |
| 940 if (Func->getContext()->isVerbose(IceV_Preds) && !InEdges.empty()) { | 948 if (Func->getContext()->isVerbose(IceV_Preds) && !InEdges.empty()) { |
| 941 Str << " // preds = "; | 949 Str << " // preds = "; |
| 942 bool First = true; | 950 bool First = true; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 if (!First) | 1007 if (!First) |
| 1000 Str << ", "; | 1008 Str << ", "; |
| 1001 First = false; | 1009 First = false; |
| 1002 Str << "%" << I->getName(); | 1010 Str << "%" << I->getName(); |
| 1003 } | 1011 } |
| 1004 Str << "\n"; | 1012 Str << "\n"; |
| 1005 } | 1013 } |
| 1006 } | 1014 } |
| 1007 | 1015 |
| 1008 } // end of namespace Ice | 1016 } // end of namespace Ice |
| OLD | NEW |