| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 skipDeleted(Cur); | 55 skipDeleted(Cur); |
| 56 Next = Cur; | 56 Next = Cur; |
| 57 } | 57 } |
| 58 | 58 |
| 59 void LoweringContext::insert(Inst *Inst) { | 59 void LoweringContext::insert(Inst *Inst) { |
| 60 getNode()->getInsts().insert(Next, Inst); | 60 getNode()->getInsts().insert(Next, Inst); |
| 61 LastInserted = Inst; | 61 LastInserted = Inst; |
| 62 } | 62 } |
| 63 | 63 |
| 64 void LoweringContext::skipDeleted(InstList::iterator &I) const { | 64 void LoweringContext::skipDeleted(InstList::iterator &I) const { |
| 65 while (I != End && (*I)->isDeleted()) | 65 while (I != End && I->isDeleted()) |
| 66 ++I; | 66 ++I; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void LoweringContext::advanceForward(InstList::iterator &I) const { | 69 void LoweringContext::advanceForward(InstList::iterator &I) const { |
| 70 if (I != End) { | 70 if (I != End) { |
| 71 ++I; | 71 ++I; |
| 72 skipDeleted(I); | 72 skipDeleted(I); |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 doAddressOptLoad(); | 109 doAddressOptLoad(); |
| 110 else if (llvm::isa<InstStore>(*Context.getCur())) | 110 else if (llvm::isa<InstStore>(*Context.getCur())) |
| 111 doAddressOptStore(); | 111 doAddressOptStore(); |
| 112 Context.advanceCur(); | 112 Context.advanceCur(); |
| 113 Context.advanceNext(); | 113 Context.advanceNext(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 bool TargetLowering::shouldDoNopInsertion() const { return DoNopInsertion; } | 116 bool TargetLowering::shouldDoNopInsertion() const { return DoNopInsertion; } |
| 117 | 117 |
| 118 void TargetLowering::doNopInsertion() { | 118 void TargetLowering::doNopInsertion() { |
| 119 Inst *I = *Context.getCur(); | 119 Inst *I = Context.getCur(); |
| 120 bool ShouldSkip = llvm::isa<InstFakeUse>(I) || llvm::isa<InstFakeDef>(I) || | 120 bool ShouldSkip = llvm::isa<InstFakeUse>(I) || llvm::isa<InstFakeDef>(I) || |
| 121 llvm::isa<InstFakeKill>(I) || I->isRedundantAssign() || | 121 llvm::isa<InstFakeKill>(I) || I->isRedundantAssign() || |
| 122 I->isDeleted(); | 122 I->isDeleted(); |
| 123 if (!ShouldSkip) { | 123 if (!ShouldSkip) { |
| 124 for (int I = 0; I < MaxNopsPerInstruction; ++I) { | 124 for (int I = 0; I < MaxNopsPerInstruction; ++I) { |
| 125 randomlyInsertNop(NopProbabilityAsPercentage / 100.0); | 125 randomlyInsertNop(NopProbabilityAsPercentage / 100.0); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 // Lowers a single instruction according to the information in | 130 // Lowers a single instruction according to the information in |
| 131 // Context, by checking the Context.Cur instruction kind and calling | 131 // Context, by checking the Context.Cur instruction kind and calling |
| 132 // the appropriate lowering method. The lowering method should insert | 132 // the appropriate lowering method. The lowering method should insert |
| 133 // target instructions at the Cur.Next insertion point, and should not | 133 // target instructions at the Cur.Next insertion point, and should not |
| 134 // delete the Context.Cur instruction or advance Context.Cur. | 134 // delete the Context.Cur instruction or advance Context.Cur. |
| 135 // | 135 // |
| 136 // The lowering method may look ahead in the instruction stream as | 136 // The lowering method may look ahead in the instruction stream as |
| 137 // desired, and lower additional instructions in conjunction with the | 137 // desired, and lower additional instructions in conjunction with the |
| 138 // current one, for example fusing a compare and branch. If it does, | 138 // current one, for example fusing a compare and branch. If it does, |
| 139 // it should advance Context.Cur to point to the next non-deleted | 139 // it should advance Context.Cur to point to the next non-deleted |
| 140 // instruction to process, and it should delete any additional | 140 // instruction to process, and it should delete any additional |
| 141 // instructions it consumes. | 141 // instructions it consumes. |
| 142 void TargetLowering::lower() { | 142 void TargetLowering::lower() { |
| 143 assert(!Context.atEnd()); | 143 assert(!Context.atEnd()); |
| 144 Inst *Inst = *Context.getCur(); | 144 Inst *Inst = Context.getCur(); |
| 145 // Mark the current instruction as deleted before lowering, | 145 // Mark the current instruction as deleted before lowering, |
| 146 // otherwise the Dest variable will likely get marked as non-SSA. | 146 // otherwise the Dest variable will likely get marked as non-SSA. |
| 147 // See Variable::setDefinition(). | 147 // See Variable::setDefinition(). |
| 148 Inst->setDeleted(); | 148 Inst->setDeleted(); |
| 149 switch (Inst->getKind()) { | 149 switch (Inst->getKind()) { |
| 150 case Inst::Alloca: | 150 case Inst::Alloca: |
| 151 lowerAlloca(llvm::dyn_cast<InstAlloca>(Inst)); | 151 lowerAlloca(llvm::dyn_cast<InstAlloca>(Inst)); |
| 152 break; | 152 break; |
| 153 case Inst::Arithmetic: | 153 case Inst::Arithmetic: |
| 154 lowerArithmetic(llvm::dyn_cast<InstArithmetic>(Inst)); | 154 lowerArithmetic(llvm::dyn_cast<InstArithmetic>(Inst)); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 if (Target == Target_ARM64) | 253 if (Target == Target_ARM64) |
| 254 return IceTargetGlobalInitARM64::create(Ctx); | 254 return IceTargetGlobalInitARM64::create(Ctx); |
| 255 #endif | 255 #endif |
| 256 llvm_unreachable("Unsupported target"); | 256 llvm_unreachable("Unsupported target"); |
| 257 return NULL; | 257 return NULL; |
| 258 } | 258 } |
| 259 | 259 |
| 260 TargetGlobalInitLowering::~TargetGlobalInitLowering() {} | 260 TargetGlobalInitLowering::~TargetGlobalInitLowering() {} |
| 261 | 261 |
| 262 } // end of namespace Ice | 262 } // end of namespace Ice |
| OLD | NEW |