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

Side by Side Diff: src/IceTargetLowering.cpp

Issue 456033003: Subzero: Randomize register assignment. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Typo Created 6 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 unified diff | Download patch
« no previous file with comments | « src/IceTargetLowering.h ('k') | src/IceTargetLoweringX8632.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/IceTargetLowering.cpp - Basic lowering implementation --===// 1 //===- subzero/src/IceTargetLowering.cpp - Basic lowering 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 skeleton of the TargetLowering class, 10 // This file implements the skeleton of the TargetLowering class,
11 // specifically invoking the appropriate lowering method for a given 11 // specifically invoking the appropriate lowering method for a given
12 // instruction kind and driving global register allocation. It also 12 // instruction kind and driving global register allocation. It also
13 // implements the non-deleted instruction iteration in 13 // implements the non-deleted instruction iteration in
14 // LoweringContext. 14 // LoweringContext.
15 // 15 //
16 //===----------------------------------------------------------------------===// 16 //===----------------------------------------------------------------------===//
17 17
18 #include "IceCfg.h" // setError() 18 #include "IceCfg.h" // setError()
19 #include "IceCfgNode.h" 19 #include "IceCfgNode.h"
20 #include "IceOperand.h" 20 #include "IceOperand.h"
21 #include "IceRegAlloc.h" 21 #include "IceRegAlloc.h"
22 #include "IceTargetLowering.h" 22 #include "IceTargetLowering.h"
23 #include "IceTargetLoweringX8632.h" 23 #include "IceTargetLoweringX8632.h"
24 #include "llvm/Support/CommandLine.h"
24 25
25 namespace Ice { 26 namespace Ice {
26 27
28 namespace {
29
30 namespace cl = ::llvm::cl;
31 cl::opt<bool>
32 CLRandomizeRegisterAllocation("randomize-regalloc",
33 cl::desc("Randomize register allocation"),
34 cl::init(false));
35
36 } // end of anonymous namespace
37
27 void LoweringContext::init(CfgNode *N) { 38 void LoweringContext::init(CfgNode *N) {
28 Node = N; 39 Node = N;
29 Begin = getNode()->getInsts().begin(); 40 Begin = getNode()->getInsts().begin();
30 Cur = Begin; 41 Cur = Begin;
31 End = getNode()->getInsts().end(); 42 End = getNode()->getInsts().end();
32 skipDeleted(Cur); 43 skipDeleted(Cur);
33 Next = Cur; 44 Next = Cur;
34 advanceForward(Next); 45 advanceForward(Next);
35 } 46 }
36 47
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 return IceTargetX8664::create(Func); 85 return IceTargetX8664::create(Func);
75 if (Target == Target_ARM32) 86 if (Target == Target_ARM32)
76 return IceTargetARM32::create(Func); 87 return IceTargetARM32::create(Func);
77 if (Target == Target_ARM64) 88 if (Target == Target_ARM64)
78 return IceTargetARM64::create(Func); 89 return IceTargetARM64::create(Func);
79 #endif 90 #endif
80 Func->setError("Unsupported target"); 91 Func->setError("Unsupported target");
81 return NULL; 92 return NULL;
82 } 93 }
83 94
95 TargetLowering::TargetLowering(Cfg *Func)
96 : Func(Func), Ctx(Func->getContext()), HasComputedFrame(false),
97 StackAdjustment(0),
98 RandomizeRegisterAllocation(CLRandomizeRegisterAllocation) {}
99
84 void TargetLowering::doAddressOpt() { 100 void TargetLowering::doAddressOpt() {
85 if (llvm::isa<InstLoad>(*Context.getCur())) 101 if (llvm::isa<InstLoad>(*Context.getCur()))
86 doAddressOptLoad(); 102 doAddressOptLoad();
87 else if (llvm::isa<InstStore>(*Context.getCur())) 103 else if (llvm::isa<InstStore>(*Context.getCur()))
88 doAddressOptStore(); 104 doAddressOptStore();
89 Context.advanceCur(); 105 Context.advanceCur();
90 Context.advanceNext(); 106 Context.advanceNext();
91 } 107 }
92 108
93 // Lowers a single instruction according to the information in 109 // Lowers a single instruction according to the information in
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // registers e.g. for performance testing. 199 // registers e.g. for performance testing.
184 void TargetLowering::regAlloc() { 200 void TargetLowering::regAlloc() {
185 LinearScan LinearScan(Func); 201 LinearScan LinearScan(Func);
186 RegSetMask RegInclude = RegSet_None; 202 RegSetMask RegInclude = RegSet_None;
187 RegSetMask RegExclude = RegSet_None; 203 RegSetMask RegExclude = RegSet_None;
188 RegInclude |= RegSet_CallerSave; 204 RegInclude |= RegSet_CallerSave;
189 RegInclude |= RegSet_CalleeSave; 205 RegInclude |= RegSet_CalleeSave;
190 if (hasFramePointer()) 206 if (hasFramePointer())
191 RegExclude |= RegSet_FramePointer; 207 RegExclude |= RegSet_FramePointer;
192 llvm::SmallBitVector RegMask = getRegisterSet(RegInclude, RegExclude); 208 llvm::SmallBitVector RegMask = getRegisterSet(RegInclude, RegExclude);
193 LinearScan.scan(RegMask); 209 LinearScan.scan(RegMask, RandomizeRegisterAllocation);
194 } 210 }
195 211
196 TargetGlobalInitLowering * 212 TargetGlobalInitLowering *
197 TargetGlobalInitLowering::createLowering(TargetArch Target, 213 TargetGlobalInitLowering::createLowering(TargetArch Target,
198 GlobalContext *Ctx) { 214 GlobalContext *Ctx) {
199 // These statements can be #ifdef'd to specialize the code generator 215 // These statements can be #ifdef'd to specialize the code generator
200 // to a subset of the available targets. TODO: use CRTP. 216 // to a subset of the available targets. TODO: use CRTP.
201 if (Target == Target_X8632) 217 if (Target == Target_X8632)
202 return TargetGlobalInitX8632::create(Ctx); 218 return TargetGlobalInitX8632::create(Ctx);
203 #if 0 219 #if 0
204 if (Target == Target_X8664) 220 if (Target == Target_X8664)
205 return IceTargetGlobalInitX8664::create(Ctx); 221 return IceTargetGlobalInitX8664::create(Ctx);
206 if (Target == Target_ARM32) 222 if (Target == Target_ARM32)
207 return IceTargetGlobalInitARM32::create(Ctx); 223 return IceTargetGlobalInitARM32::create(Ctx);
208 if (Target == Target_ARM64) 224 if (Target == Target_ARM64)
209 return IceTargetGlobalInitARM64::create(Ctx); 225 return IceTargetGlobalInitARM64::create(Ctx);
210 #endif 226 #endif
211 llvm_unreachable("Unsupported target"); 227 llvm_unreachable("Unsupported target");
212 return NULL; 228 return NULL;
213 } 229 }
214 230
215 TargetGlobalInitLowering::~TargetGlobalInitLowering() {} 231 TargetGlobalInitLowering::~TargetGlobalInitLowering() {}
216 232
217 } // end of namespace Ice 233 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTargetLowering.h ('k') | src/IceTargetLoweringX8632.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698