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

Side by Side Diff: src/IceCfgNode.cpp

Issue 798693003: Subzero: Don't store std::string objects inside Variable. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 6 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
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
11 // of instruction insertion and in-edge calculation. 11 // of instruction insertion and in-edge calculation.
12 // 12 //
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #include "assembler.h" 15 #include "assembler.h"
16 #include "IceCfg.h" 16 #include "IceCfg.h"
17 #include "IceCfgNode.h" 17 #include "IceCfgNode.h"
18 #include "IceInst.h" 18 #include "IceInst.h"
19 #include "IceLiveness.h" 19 #include "IceLiveness.h"
20 #include "IceOperand.h" 20 #include "IceOperand.h"
21 #include "IceTargetLowering.h" 21 #include "IceTargetLowering.h"
22 22
23 namespace Ice { 23 namespace Ice {
24 24
25 CfgNode::CfgNode(Cfg *Func, SizeT LabelNumber) 25 CfgNode::CfgNode(Cfg *Func, SizeT LabelNumber)
26 : Func(Func), Number(LabelNumber), NameIndex(-1), HasReturn(false), 26 : Func(Func), Number(LabelNumber), NameIndex(Cfg::IdentifierIndexInvalid),
27 NeedsPlacement(false), InstCountEstimate(0) {} 27 HasReturn(false), NeedsPlacement(false), InstCountEstimate(0) {}
28 28
29 // Returns the name the node was created with. If no name was given, 29 // Returns the name the node was created with. If no name was given,
30 // it synthesizes a (hopefully) unique name. 30 // it synthesizes a (hopefully) unique name.
31 IceString CfgNode::getName() const { 31 IceString CfgNode::getName() const {
32 if (NameIndex >= 0) 32 if (NameIndex >= 0)
33 return Func->getNodeName(NameIndex); 33 return Func->getIdentifierName(NameIndex);
34 return "__" + std::to_string(getIndex()); 34 return "__" + std::to_string(getIndex());
35 } 35 }
36 36
37 // Adds an instruction to either the Phi list or the regular 37 // Adds an instruction to either the Phi list or the regular
38 // instruction list. Validates that all Phis are added before all 38 // instruction list. Validates that all Phis are added before all
39 // regular instructions. 39 // regular instructions.
40 void CfgNode::appendInst(Inst *Inst) { 40 void CfgNode::appendInst(Inst *Inst) {
41 ++InstCountEstimate; 41 ++InstCountEstimate;
42 if (InstPhi *Phi = llvm::dyn_cast<InstPhi>(Inst)) { 42 if (InstPhi *Phi = llvm::dyn_cast<InstPhi>(Inst)) {
43 if (!Insts.empty()) { 43 if (!Insts.empty()) {
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 bool Found = false; 430 bool Found = false;
431 // If the target instruction "A=B" is part of a cycle, find 431 // If the target instruction "A=B" is part of a cycle, find
432 // the "X=A" assignment in the cycle because it will have to 432 // the "X=A" assignment in the cycle because it will have to
433 // be rewritten as "X=tmp". 433 // be rewritten as "X=tmp".
434 for (size_t J = 0; !Found && J < NumPhis; ++J) { 434 for (size_t J = 0; !Found && J < NumPhis; ++J) {
435 if (Desc[J].Processed) 435 if (Desc[J].Processed)
436 continue; 436 continue;
437 Operand *OtherSrc = Desc[J].Src; 437 Operand *OtherSrc = Desc[J].Src;
438 if (Desc[J].NumPred && sameVarOrReg(Dest, OtherSrc)) { 438 if (Desc[J].NumPred && sameVarOrReg(Dest, OtherSrc)) {
439 SizeT VarNum = Func->getNumVariables(); 439 SizeT VarNum = Func->getNumVariables();
440 Variable *Tmp = Func->makeVariable( 440 Variable *Tmp = Func->makeVariable(OtherSrc->getType());
441 OtherSrc->getType(), "__split_" + std::to_string(VarNum)); 441 if (ALLOW_DUMP)
442 Tmp->setName(Func, "__split_" + std::to_string(VarNum));
442 Assignments.push_back(InstAssign::create(Func, Tmp, OtherSrc)); 443 Assignments.push_back(InstAssign::create(Func, Tmp, OtherSrc));
443 Desc[J].Src = Tmp; 444 Desc[J].Src = Tmp;
444 Found = true; 445 Found = true;
445 } 446 }
446 } 447 }
447 assert(Found); 448 assert(Found);
448 } 449 }
449 // Now that a cycle (if any) has been broken, create the actual 450 // Now that a cycle (if any) has been broken, create the actual
450 // assignment. 451 // assignment.
451 Assignments.push_back(InstAssign::create(Func, Dest, Src)); 452 Assignments.push_back(InstAssign::create(Func, Dest, Src));
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 } 964 }
964 // Dump the live-in variables. 965 // Dump the live-in variables.
965 LivenessBV LiveIn; 966 LivenessBV LiveIn;
966 if (Liveness) 967 if (Liveness)
967 LiveIn = Liveness->getLiveIn(this); 968 LiveIn = Liveness->getLiveIn(this);
968 if (Func->getContext()->isVerbose(IceV_Liveness) && !LiveIn.empty()) { 969 if (Func->getContext()->isVerbose(IceV_Liveness) && !LiveIn.empty()) {
969 Str << " // LiveIn:"; 970 Str << " // LiveIn:";
970 for (SizeT i = 0; i < LiveIn.size(); ++i) { 971 for (SizeT i = 0; i < LiveIn.size(); ++i) {
971 if (LiveIn[i]) { 972 if (LiveIn[i]) {
972 Variable *Var = Liveness->getVariable(i, this); 973 Variable *Var = Liveness->getVariable(i, this);
973 Str << " %" << Var->getName(); 974 Str << " %" << Var->getName(Func);
974 if (Func->getContext()->isVerbose(IceV_RegOrigins) && Var->hasReg()) { 975 if (Func->getContext()->isVerbose(IceV_RegOrigins) && Var->hasReg()) {
975 Str << ":" << Func->getTarget()->getRegName(Var->getRegNum(), 976 Str << ":" << Func->getTarget()->getRegName(Var->getRegNum(),
976 Var->getType()); 977 Var->getType());
977 } 978 }
978 } 979 }
979 } 980 }
980 Str << "\n"; 981 Str << "\n";
981 } 982 }
982 // Dump each instruction. 983 // Dump each instruction.
983 if (Func->getContext()->isVerbose(IceV_Instructions)) { 984 if (Func->getContext()->isVerbose(IceV_Instructions)) {
984 for (auto I = Phis.begin(), E = Phis.end(); I != E; ++I) 985 for (auto I = Phis.begin(), E = Phis.end(); I != E; ++I)
985 I->dumpDecorated(Func); 986 I->dumpDecorated(Func);
986 for (auto I = Insts.begin(), E = Insts.end(); I != E; ++I) 987 for (auto I = Insts.begin(), E = Insts.end(); I != E; ++I)
987 I->dumpDecorated(Func); 988 I->dumpDecorated(Func);
988 } 989 }
989 // Dump the live-out variables. 990 // Dump the live-out variables.
990 LivenessBV LiveOut; 991 LivenessBV LiveOut;
991 if (Liveness) 992 if (Liveness)
992 LiveOut = Liveness->getLiveOut(this); 993 LiveOut = Liveness->getLiveOut(this);
993 if (Func->getContext()->isVerbose(IceV_Liveness) && !LiveOut.empty()) { 994 if (Func->getContext()->isVerbose(IceV_Liveness) && !LiveOut.empty()) {
994 Str << " // LiveOut:"; 995 Str << " // LiveOut:";
995 for (SizeT i = 0; i < LiveOut.size(); ++i) { 996 for (SizeT i = 0; i < LiveOut.size(); ++i) {
996 if (LiveOut[i]) { 997 if (LiveOut[i]) {
997 Variable *Var = Liveness->getVariable(i, this); 998 Variable *Var = Liveness->getVariable(i, this);
998 Str << " %" << Var->getName(); 999 Str << " %" << Var->getName(Func);
999 if (Func->getContext()->isVerbose(IceV_RegOrigins) && Var->hasReg()) { 1000 if (Func->getContext()->isVerbose(IceV_RegOrigins) && Var->hasReg()) {
1000 Str << ":" << Func->getTarget()->getRegName(Var->getRegNum(), 1001 Str << ":" << Func->getTarget()->getRegName(Var->getRegNum(),
1001 Var->getType()); 1002 Var->getType());
1002 } 1003 }
1003 } 1004 }
1004 } 1005 }
1005 Str << "\n"; 1006 Str << "\n";
1006 } 1007 }
1007 // Dump list of successor nodes. 1008 // Dump list of successor nodes.
1008 if (Func->getContext()->isVerbose(IceV_Succs)) { 1009 if (Func->getContext()->isVerbose(IceV_Succs)) {
1009 Str << " // succs = "; 1010 Str << " // succs = ";
1010 bool First = true; 1011 bool First = true;
1011 for (CfgNode *I : OutEdges) { 1012 for (CfgNode *I : OutEdges) {
1012 if (!First) 1013 if (!First)
1013 Str << ", "; 1014 Str << ", ";
1014 First = false; 1015 First = false;
1015 Str << "%" << I->getName(); 1016 Str << "%" << I->getName();
1016 } 1017 }
1017 Str << "\n"; 1018 Str << "\n";
1018 } 1019 }
1019 } 1020 }
1020 1021
1021 } // end of namespace Ice 1022 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfgNode.h ('k') | src/IceConverter.cpp » ('j') | src/IceOperand.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698