| 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 Inst *I = *Context.getCur(); |
| 114 bool ShouldSkip = llvm::isa<InstFakeUse>(I) || llvm::isa<InstFakeDef>(I) || |
| 115 llvm::isa<InstFakeKill>(I) || I->isRedundantAssign() || |
| 116 I->isDeleted(); |
| 117 if (!ShouldSkip) { |
| 118 for (int I = 0; I < MaxNopsPerInstruction; ++I) { |
| 119 randomlyInsertNop(NopProbabilityAsPercentage / 100.0); |
| 120 } |
| 121 } |
| 122 } |
| 123 |
| 93 // Lowers a single instruction according to the information in | 124 // Lowers a single instruction according to the information in |
| 94 // Context, by checking the Context.Cur instruction kind and calling | 125 // Context, by checking the Context.Cur instruction kind and calling |
| 95 // the appropriate lowering method. The lowering method should insert | 126 // the appropriate lowering method. The lowering method should insert |
| 96 // target instructions at the Cur.Next insertion point, and should not | 127 // target instructions at the Cur.Next insertion point, and should not |
| 97 // delete the Context.Cur instruction or advance Context.Cur. | 128 // delete the Context.Cur instruction or advance Context.Cur. |
| 98 // | 129 // |
| 99 // The lowering method may look ahead in the instruction stream as | 130 // The lowering method may look ahead in the instruction stream as |
| 100 // desired, and lower additional instructions in conjunction with the | 131 // desired, and lower additional instructions in conjunction with the |
| 101 // current one, for example fusing a compare and branch. If it does, | 132 // 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 | 133 // 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) | 239 if (Target == Target_ARM64) |
| 209 return IceTargetGlobalInitARM64::create(Ctx); | 240 return IceTargetGlobalInitARM64::create(Ctx); |
| 210 #endif | 241 #endif |
| 211 llvm_unreachable("Unsupported target"); | 242 llvm_unreachable("Unsupported target"); |
| 212 return NULL; | 243 return NULL; |
| 213 } | 244 } |
| 214 | 245 |
| 215 TargetGlobalInitLowering::~TargetGlobalInitLowering() {} | 246 TargetGlobalInitLowering::~TargetGlobalInitLowering() {} |
| 216 | 247 |
| 217 } // end of namespace Ice | 248 } // end of namespace Ice |
| OLD | NEW |