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, |
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 | 24 |
| 25 #include "llvm/Support/CommandLine.h" |
| 26 |
25 namespace Ice { | 27 namespace Ice { |
26 | 28 |
| 29 namespace { |
| 30 |
| 31 namespace cl = llvm::cl; |
| 32 cl::opt<bool> DoNopInsertion("nop-insertion", cl::desc("Randomly insert NOPs"), |
| 33 cl::init(false)); |
| 34 |
| 35 cl::opt<int> MaxNopsPerInstruction( |
| 36 "max-nops-per-instruction", |
| 37 cl::desc("Max number of nops to insert per instruction"), cl::init(1)); |
| 38 |
| 39 cl::opt<int> NopProbabilityAsPercentage( |
| 40 "nop-insertion-percentage", |
| 41 cl::desc("Nop insertion probability as percentage"), cl::init(10)); |
| 42 } // end of anonymous namespace |
| 43 |
27 void LoweringContext::init(CfgNode *N) { | 44 void LoweringContext::init(CfgNode *N) { |
28 Node = N; | 45 Node = N; |
29 Begin = getNode()->getInsts().begin(); | 46 Begin = getNode()->getInsts().begin(); |
30 Cur = Begin; | 47 Cur = Begin; |
31 End = getNode()->getInsts().end(); | 48 End = getNode()->getInsts().end(); |
32 skipDeleted(Cur); | 49 skipDeleted(Cur); |
33 Next = Cur; | 50 Next = Cur; |
34 advanceForward(Next); | 51 advanceForward(Next); |
35 } | 52 } |
36 | 53 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 100 |
84 void TargetLowering::doAddressOpt() { | 101 void TargetLowering::doAddressOpt() { |
85 if (llvm::isa<InstLoad>(*Context.getCur())) | 102 if (llvm::isa<InstLoad>(*Context.getCur())) |
86 doAddressOptLoad(); | 103 doAddressOptLoad(); |
87 else if (llvm::isa<InstStore>(*Context.getCur())) | 104 else if (llvm::isa<InstStore>(*Context.getCur())) |
88 doAddressOptStore(); | 105 doAddressOptStore(); |
89 Context.advanceCur(); | 106 Context.advanceCur(); |
90 Context.advanceNext(); | 107 Context.advanceNext(); |
91 } | 108 } |
92 | 109 |
| 110 bool TargetLowering::shouldDoNopInsertion() const { return DoNopInsertion; } |
| 111 |
| 112 void TargetLowering::doNopInsertion() { |
| 113 for (int I = 0; I < MaxNopsPerInstruction; ++I) { |
| 114 randomlyInsertNop(NopProbabilityAsPercentage / 100.0); |
| 115 } |
| 116 Context.advanceCur(); |
| 117 Context.advanceNext(); |
| 118 } |
| 119 |
93 // Lowers a single instruction according to the information in | 120 // Lowers a single instruction according to the information in |
94 // Context, by checking the Context.Cur instruction kind and calling | 121 // Context, by checking the Context.Cur instruction kind and calling |
95 // the appropriate lowering method. The lowering method should insert | 122 // the appropriate lowering method. The lowering method should insert |
96 // target instructions at the Cur.Next insertion point, and should not | 123 // target instructions at the Cur.Next insertion point, and should not |
97 // delete the Context.Cur instruction or advance Context.Cur. | 124 // delete the Context.Cur instruction or advance Context.Cur. |
98 // | 125 // |
99 // The lowering method may look ahead in the instruction stream as | 126 // The lowering method may look ahead in the instruction stream as |
100 // desired, and lower additional instructions in conjunction with the | 127 // desired, and lower additional instructions in conjunction with the |
101 // current one, for example fusing a compare and branch. If it does, | 128 // current one, for example fusing a compare and branch. If it does, |
102 // it should advance Context.Cur to point to the next non-deleted | 129 // it should advance Context.Cur to point to the next non-deleted |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 if (Target == Target_ARM64) | 235 if (Target == Target_ARM64) |
209 return IceTargetGlobalInitARM64::create(Ctx); | 236 return IceTargetGlobalInitARM64::create(Ctx); |
210 #endif | 237 #endif |
211 llvm_unreachable("Unsupported target"); | 238 llvm_unreachable("Unsupported target"); |
212 return NULL; | 239 return NULL; |
213 } | 240 } |
214 | 241 |
215 TargetGlobalInitLowering::~TargetGlobalInitLowering() {} | 242 TargetGlobalInitLowering::~TargetGlobalInitLowering() {} |
216 | 243 |
217 } // end of namespace Ice | 244 } // end of namespace Ice |
OLD | NEW |