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

Unified Diff: src/IceOperand.cpp

Issue 1312433004: Weight variables by their number of uses for register allocation. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceOperand.h ('k') | src/IceRegAlloc.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceOperand.cpp
diff --git a/src/IceOperand.cpp b/src/IceOperand.cpp
index e46fac03d9387604f3d1a0fea6fc48bb37c49713..32316ba6ffda6d4f1e8bcab3e1a1ddd589960695 100644
--- a/src/IceOperand.cpp
+++ b/src/IceOperand.cpp
@@ -145,9 +145,21 @@ Variable *Variable::asType(Type Ty) {
return V;
}
+RegWeight Variable::getWeight(const Cfg *Func) const {
+ VariablesMetadata *VMetadata = Func->getVMetadata();
+ return RegWeight(mustHaveReg()
+ ? RegWeight::Inf
+ : mustNotHaveReg() ? RegWeight::Zero
+ : VMetadata->getUseWeight(this));
+}
+
void VariableTracking::markUse(MetadataKind TrackingKind, const Inst *Instr,
CfgNode *Node, bool IsImplicit) {
(void)TrackingKind;
+
+ // TODO(ascull): get the loop nest depth from CfgNode
+ UseWeight += 1;
+
if (MultiBlock == MBS_MultiBlock)
return;
// TODO(stichnot): If the use occurs as a source operand in the
@@ -383,6 +395,13 @@ CfgNode *VariablesMetadata::getLocalUseNode(const Variable *Var) const {
return Metadata[VarNum].getNode();
}
+uint32_t VariablesMetadata::getUseWeight(const Variable *Var) const {
+ if (!isTracked(Var))
+ return 1; // conservative answer
+ SizeT VarNum = Var->getIndex();
+ return Metadata[VarNum].getUseWeight();
+}
+
const InstDefList VariablesMetadata::NoDefinitions;
// ======================== dump routines ======================== //
@@ -466,7 +485,6 @@ void ConstantUndef::emit(TargetLowering *Target) const { Target->emit(this); }
void LiveRange::dump(Ostream &Str) const {
if (!BuildDefs::dump())
return;
- Str << "(weight=" << Weight << ") ";
bool First = true;
for (const RangeElementType &I : Range) {
if (!First)
« no previous file with comments | « src/IceOperand.h ('k') | src/IceRegAlloc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698