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

Side by Side Diff: src/IceCfg.cpp

Issue 1641653004: Subzero: Make the register allocator more robust with -reg-use and -reg-exclude. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Test code accidentally left in Created 4 years, 10 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.h ('k') | src/IceClFlags.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/IceCfg.cpp - Control flow graph implementation ---------===// 1 //===- subzero/src/IceCfg.cpp - Control flow graph 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // generator to generate a cookie for constant blinding. 48 // generator to generate a cookie for constant blinding.
49 RandomNumberGenerator RNG(Ctx->getFlags().getRandomSeed(), 49 RandomNumberGenerator RNG(Ctx->getFlags().getRandomSeed(),
50 RPE_ConstantBlinding, this->SequenceNumber); 50 RPE_ConstantBlinding, this->SequenceNumber);
51 ConstantBlindingCookie = 51 ConstantBlindingCookie =
52 (uint32_t)RNG.next((uint64_t)std::numeric_limits<uint32_t>::max() + 1); 52 (uint32_t)RNG.next((uint64_t)std::numeric_limits<uint32_t>::max() + 1);
53 } 53 }
54 } 54 }
55 55
56 Cfg::~Cfg() { assert(ICE_TLS_GET_FIELD(CurrentCfg) == nullptr); } 56 Cfg::~Cfg() { assert(ICE_TLS_GET_FIELD(CurrentCfg) == nullptr); }
57 57
58 /// Create a string like "foo(i=123:b=9)" indicating the function name, number
59 /// of high-level instructions, and number of basic blocks. This string is only
60 /// used for dumping and other diagnostics, and the idea is that given a set of
61 /// functions to debug a problem on, it's easy to find the smallest or simplest
62 /// function to attack. Note that the counts may change somewhat depending on
63 /// what point it is called during the translation passes.
64 IceString Cfg::getFunctionNameAndSize() const {
65 if (!BuildDefs::dump())
66 return getFunctionName();
67 SizeT NodeCount = 0;
68 SizeT InstCount = 0;
69 for (CfgNode *Node : getNodes()) {
70 ++NodeCount;
71 // Note: deleted instructions are *not* ignored.
72 InstCount += Node->getPhis().size();
73 for (Inst &I : Node->getInsts()) {
74 if (!llvm::isa<InstTarget>(&I))
75 ++InstCount;
76 }
77 }
78 return getFunctionName() + "(i=" + std::to_string(InstCount) + ":b=" +
79 std::to_string(NodeCount) + ")";
80 }
81
58 void Cfg::setError(const IceString &Message) { 82 void Cfg::setError(const IceString &Message) {
59 HasError = true; 83 HasError = true;
60 ErrorMessage = Message; 84 ErrorMessage = Message;
61 } 85 }
62 86
63 CfgNode *Cfg::makeNode() { 87 CfgNode *Cfg::makeNode() {
64 SizeT LabelIndex = Nodes.size(); 88 SizeT LabelIndex = Nodes.size();
65 auto *Node = CfgNode::create(this, LabelIndex); 89 auto *Node = CfgNode::create(this, LabelIndex);
66 Nodes.push_back(Node); 90 Nodes.push_back(Node);
67 return Node; 91 return Node;
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 Str << "define "; 1092 Str << "define ";
1069 if (getInternal() && !Ctx->getFlags().getDisableInternal()) 1093 if (getInternal() && !Ctx->getFlags().getDisableInternal())
1070 Str << "internal "; 1094 Str << "internal ";
1071 Str << ReturnType << " @" << Ctx->mangleName(getFunctionName()) << "("; 1095 Str << ReturnType << " @" << Ctx->mangleName(getFunctionName()) << "(";
1072 for (SizeT i = 0; i < Args.size(); ++i) { 1096 for (SizeT i = 0; i < Args.size(); ++i) {
1073 if (i > 0) 1097 if (i > 0)
1074 Str << ", "; 1098 Str << ", ";
1075 Str << Args[i]->getType() << " "; 1099 Str << Args[i]->getType() << " ";
1076 Args[i]->dump(this); 1100 Args[i]->dump(this);
1077 } 1101 }
1078 Str << ") {\n"; 1102 // Append an extra copy of the function name here, in order to print its
1103 // size stats but not mess up lit tests.
1104 Str << ") { # " << getFunctionNameAndSize() << "\n";
1079 } 1105 }
1080 resetCurrentNode(); 1106 resetCurrentNode();
1081 if (isVerbose(IceV_Liveness)) { 1107 if (isVerbose(IceV_Liveness)) {
1082 // Print summary info about variables 1108 // Print summary info about variables
1083 for (Variable *Var : Variables) { 1109 for (Variable *Var : Variables) {
1084 Str << "// multiblock="; 1110 Str << "// multiblock=";
1085 if (getVMetadata()->isTracked(Var)) 1111 if (getVMetadata()->isTracked(Var))
1086 Str << getVMetadata()->isMultiBlock(Var); 1112 Str << getVMetadata()->isMultiBlock(Var);
1087 else 1113 else
1088 Str << "?"; 1114 Str << "?";
(...skipping 19 matching lines...) Expand all
1108 } 1134 }
1109 } 1135 }
1110 // Print each basic block 1136 // Print each basic block
1111 for (CfgNode *Node : Nodes) 1137 for (CfgNode *Node : Nodes)
1112 Node->dump(this); 1138 Node->dump(this);
1113 if (isVerbose(IceV_Instructions)) 1139 if (isVerbose(IceV_Instructions))
1114 Str << "}\n"; 1140 Str << "}\n";
1115 } 1141 }
1116 1142
1117 } // end of namespace Ice 1143 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfg.h ('k') | src/IceClFlags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698