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 namespace cl = llvm::cl; | |
31 cl::opt<bool> DoNopInsertion("insert-nops", cl::desc("Randomly insert NOPs"), | |
32 cl::init(false)); | |
33 cl::opt<int> NopProbability("nop-probability", | |
34 cl::desc("Nop insertion probability"), | |
jvoung (off chromium)
2014/08/14 15:17:17
A default of "10" should be a strong hint at the u
wala
2014/08/14 23:29:50
Done.
| |
35 cl::init(10)); | |
36 } // end anonymous namespace | |
Jim Stichnoth
2014/08/14 01:20:10
end of anonymous namespace
wala
2014/08/14 23:29:50
Done.
| |
37 | |
38 | |
27 void LoweringContext::init(CfgNode *N) { | 39 void LoweringContext::init(CfgNode *N) { |
28 Node = N; | 40 Node = N; |
29 Begin = getNode()->getInsts().begin(); | 41 Begin = getNode()->getInsts().begin(); |
30 Cur = Begin; | 42 Cur = Begin; |
31 End = getNode()->getInsts().end(); | 43 End = getNode()->getInsts().end(); |
32 skipDeleted(Cur); | 44 skipDeleted(Cur); |
33 Next = Cur; | 45 Next = Cur; |
34 advanceForward(Next); | 46 advanceForward(Next); |
35 } | 47 } |
36 | 48 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 | 95 |
84 void TargetLowering::doAddressOpt() { | 96 void TargetLowering::doAddressOpt() { |
85 if (llvm::isa<InstLoad>(*Context.getCur())) | 97 if (llvm::isa<InstLoad>(*Context.getCur())) |
86 doAddressOptLoad(); | 98 doAddressOptLoad(); |
87 else if (llvm::isa<InstStore>(*Context.getCur())) | 99 else if (llvm::isa<InstStore>(*Context.getCur())) |
88 doAddressOptStore(); | 100 doAddressOptStore(); |
89 Context.advanceCur(); | 101 Context.advanceCur(); |
90 Context.advanceNext(); | 102 Context.advanceNext(); |
91 } | 103 } |
92 | 104 |
105 bool TargetLowering::shouldDoNopInsertion() const { | |
106 return DoNopInsertion; | |
107 } | |
108 | |
109 void TargetLowering::doNopInsertion() { | |
110 randomlyInsertNop(NopProbability / 100.0); | |
111 Context.advanceCur(); | |
112 Context.advanceNext(); | |
113 } | |
114 | |
93 // Lowers a single instruction according to the information in | 115 // Lowers a single instruction according to the information in |
94 // Context, by checking the Context.Cur instruction kind and calling | 116 // Context, by checking the Context.Cur instruction kind and calling |
95 // the appropriate lowering method. The lowering method should insert | 117 // the appropriate lowering method. The lowering method should insert |
96 // target instructions at the Cur.Next insertion point, and should not | 118 // target instructions at the Cur.Next insertion point, and should not |
97 // delete the Context.Cur instruction or advance Context.Cur. | 119 // delete the Context.Cur instruction or advance Context.Cur. |
98 // | 120 // |
99 // The lowering method may look ahead in the instruction stream as | 121 // The lowering method may look ahead in the instruction stream as |
100 // desired, and lower additional instructions in conjunction with the | 122 // desired, and lower additional instructions in conjunction with the |
101 // current one, for example fusing a compare and branch. If it does, | 123 // 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 | 124 // 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) | 230 if (Target == Target_ARM64) |
209 return IceTargetGlobalInitARM64::create(Ctx); | 231 return IceTargetGlobalInitARM64::create(Ctx); |
210 #endif | 232 #endif |
211 llvm_unreachable("Unsupported target"); | 233 llvm_unreachable("Unsupported target"); |
212 return NULL; | 234 return NULL; |
213 } | 235 } |
214 | 236 |
215 TargetGlobalInitLowering::~TargetGlobalInitLowering() {} | 237 TargetGlobalInitLowering::~TargetGlobalInitLowering() {} |
216 | 238 |
217 } // end of namespace Ice | 239 } // end of namespace Ice |
OLD | NEW |