OLD | NEW |
---|---|
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, |
(...skipping 11 matching lines...) Expand all Loading... | |
22 #include "IceCfgNode.h" | 22 #include "IceCfgNode.h" |
23 #include "IceOperand.h" | 23 #include "IceOperand.h" |
24 #include "IceRegAlloc.h" | 24 #include "IceRegAlloc.h" |
25 #include "IceTargetLowering.h" | 25 #include "IceTargetLowering.h" |
26 #include "IceTargetLoweringX8632.h" | 26 #include "IceTargetLoweringX8632.h" |
27 | 27 |
28 namespace Ice { | 28 namespace Ice { |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 // TODO(stichnot): Move this machinery into llvm2ice.cpp. | |
32 namespace cl = llvm::cl; | 33 namespace cl = llvm::cl; |
33 cl::opt<bool> DoNopInsertion("nop-insertion", cl::desc("Randomly insert NOPs"), | 34 cl::opt<bool> DoNopInsertion("nop-insertion", cl::desc("Randomly insert NOPs"), |
34 cl::init(false)); | 35 cl::init(false)); |
35 | 36 |
36 cl::opt<int> MaxNopsPerInstruction( | 37 cl::opt<int> MaxNopsPerInstruction( |
37 "max-nops-per-instruction", | 38 "max-nops-per-instruction", |
38 cl::desc("Max number of nops to insert per instruction"), cl::init(1)); | 39 cl::desc("Max number of nops to insert per instruction"), cl::init(1)); |
39 | 40 |
40 cl::opt<int> NopProbabilityAsPercentage( | 41 cl::opt<int> NopProbabilityAsPercentage( |
41 "nop-insertion-percentage", | 42 "nop-insertion-percentage", |
42 cl::desc("Nop insertion probability as percentage"), cl::init(10)); | 43 cl::desc("Nop insertion probability as percentage"), cl::init(10)); |
44 | |
45 cl::opt<bool> | |
46 CLRandomizeRegisterAllocation("randomize-regalloc", | |
47 cl::desc("Randomize register allocation"), | |
48 cl::init(false)); | |
43 } // end of anonymous namespace | 49 } // end of anonymous namespace |
44 | 50 |
45 void LoweringContext::init(CfgNode *N) { | 51 void LoweringContext::init(CfgNode *N) { |
46 Node = N; | 52 Node = N; |
47 End = getNode()->getInsts().end(); | 53 End = getNode()->getInsts().end(); |
48 rewind(); | 54 rewind(); |
49 advanceForward(Next); | 55 advanceForward(Next); |
50 } | 56 } |
51 | 57 |
52 void LoweringContext::rewind() { | 58 void LoweringContext::rewind() { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 return IceTargetX8664::create(Func); | 94 return IceTargetX8664::create(Func); |
89 if (Target == Target_ARM32) | 95 if (Target == Target_ARM32) |
90 return IceTargetARM32::create(Func); | 96 return IceTargetARM32::create(Func); |
91 if (Target == Target_ARM64) | 97 if (Target == Target_ARM64) |
92 return IceTargetARM64::create(Func); | 98 return IceTargetARM64::create(Func); |
93 #endif | 99 #endif |
94 Func->setError("Unsupported target"); | 100 Func->setError("Unsupported target"); |
95 return NULL; | 101 return NULL; |
96 } | 102 } |
97 | 103 |
104 TargetLowering::TargetLowering(Cfg *Func) | |
105 : Func(Func), Ctx(Func->getContext()), HasComputedFrame(false), | |
106 StackAdjustment(0), | |
107 RandomizeRegisterAllocation(CLRandomizeRegisterAllocation) {} | |
JF
2014/12/17 18:56:18
Missing CallsReturnsTwice and Context.
Jim Stichnoth
2014/12/18 18:52:03
Done for CallsReturnsTwice. For Context, its ctor
Jim Stichnoth
2014/12/18 18:59:34
I don't know what happened before, but it's done n
| |
108 | |
98 Assembler *TargetLowering::createAssembler(TargetArch Target, Cfg *Func) { | 109 Assembler *TargetLowering::createAssembler(TargetArch Target, Cfg *Func) { |
99 // These statements can be #ifdef'd to specialize the assembler | 110 // These statements can be #ifdef'd to specialize the assembler |
100 // to a subset of the available targets. TODO: use CRTP. | 111 // to a subset of the available targets. TODO: use CRTP. |
101 if (Target == Target_X8632) | 112 if (Target == Target_X8632) |
102 return new x86::AssemblerX86(); | 113 return new x86::AssemblerX86(); |
103 Func->setError("Unsupported target"); | 114 Func->setError("Unsupported target"); |
104 return NULL; | 115 return NULL; |
105 } | 116 } |
106 | 117 |
107 void TargetLowering::doAddressOpt() { | 118 void TargetLowering::doAddressOpt() { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 TimerMarker T(TimerStack::TT_regAlloc, Func); | 240 TimerMarker T(TimerStack::TT_regAlloc, Func); |
230 LinearScan LinearScan(Func); | 241 LinearScan LinearScan(Func); |
231 RegSetMask RegInclude = RegSet_None; | 242 RegSetMask RegInclude = RegSet_None; |
232 RegSetMask RegExclude = RegSet_None; | 243 RegSetMask RegExclude = RegSet_None; |
233 RegInclude |= RegSet_CallerSave; | 244 RegInclude |= RegSet_CallerSave; |
234 RegInclude |= RegSet_CalleeSave; | 245 RegInclude |= RegSet_CalleeSave; |
235 if (hasFramePointer()) | 246 if (hasFramePointer()) |
236 RegExclude |= RegSet_FramePointer; | 247 RegExclude |= RegSet_FramePointer; |
237 LinearScan.init(Kind); | 248 LinearScan.init(Kind); |
238 llvm::SmallBitVector RegMask = getRegisterSet(RegInclude, RegExclude); | 249 llvm::SmallBitVector RegMask = getRegisterSet(RegInclude, RegExclude); |
239 LinearScan.scan(RegMask); | 250 LinearScan.scan(RegMask, RandomizeRegisterAllocation); |
240 } | 251 } |
241 | 252 |
242 TargetGlobalInitLowering * | 253 TargetGlobalInitLowering * |
243 TargetGlobalInitLowering::createLowering(TargetArch Target, | 254 TargetGlobalInitLowering::createLowering(TargetArch Target, |
244 GlobalContext *Ctx) { | 255 GlobalContext *Ctx) { |
245 // These statements can be #ifdef'd to specialize the code generator | 256 // These statements can be #ifdef'd to specialize the code generator |
246 // to a subset of the available targets. TODO: use CRTP. | 257 // to a subset of the available targets. TODO: use CRTP. |
247 if (Target == Target_X8632) | 258 if (Target == Target_X8632) |
248 return TargetGlobalInitX8632::create(Ctx); | 259 return TargetGlobalInitX8632::create(Ctx); |
249 #if 0 | 260 #if 0 |
250 if (Target == Target_X8664) | 261 if (Target == Target_X8664) |
251 return IceTargetGlobalInitX8664::create(Ctx); | 262 return IceTargetGlobalInitX8664::create(Ctx); |
252 if (Target == Target_ARM32) | 263 if (Target == Target_ARM32) |
253 return IceTargetGlobalInitARM32::create(Ctx); | 264 return IceTargetGlobalInitARM32::create(Ctx); |
254 if (Target == Target_ARM64) | 265 if (Target == Target_ARM64) |
255 return IceTargetGlobalInitARM64::create(Ctx); | 266 return IceTargetGlobalInitARM64::create(Ctx); |
256 #endif | 267 #endif |
257 llvm_unreachable("Unsupported target"); | 268 llvm_unreachable("Unsupported target"); |
258 return NULL; | 269 return NULL; |
259 } | 270 } |
260 | 271 |
261 TargetGlobalInitLowering::~TargetGlobalInitLowering() {} | 272 TargetGlobalInitLowering::~TargetGlobalInitLowering() {} |
262 | 273 |
263 } // end of namespace Ice | 274 } // end of namespace Ice |
OLD | NEW |