| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // The lowering method may look ahead in the instruction stream as | 123 // The lowering method may look ahead in the instruction stream as |
| 124 // desired, and lower additional instructions in conjunction with the | 124 // desired, and lower additional instructions in conjunction with the |
| 125 // current one, for example fusing a compare and branch. If it does, | 125 // current one, for example fusing a compare and branch. If it does, |
| 126 // it should advance Context.Cur to point to the next non-deleted | 126 // it should advance Context.Cur to point to the next non-deleted |
| 127 // instruction to process, and it should delete any additional | 127 // instruction to process, and it should delete any additional |
| 128 // instructions it consumes. | 128 // instructions it consumes. |
| 129 void TargetLowering::lower() { | 129 void TargetLowering::lower() { |
| 130 assert(!Context.atEnd()); | 130 assert(!Context.atEnd()); |
| 131 Inst *Inst = Context.getCur(); | 131 Inst *Inst = Context.getCur(); |
| 132 Inst->deleteIfDead(); | 132 Inst->deleteIfDead(); |
| 133 if (!Inst->isDeleted()) { | 133 if (!Inst->isDeleted() && !llvm::isa<InstFakeDef>(Inst) && |
| 134 !llvm::isa<InstFakeUse>(Inst)) { |
| 134 // Mark the current instruction as deleted before lowering, | 135 // Mark the current instruction as deleted before lowering, |
| 135 // otherwise the Dest variable will likely get marked as non-SSA. | 136 // otherwise the Dest variable will likely get marked as non-SSA. |
| 136 // See Variable::setDefinition(). | 137 // See Variable::setDefinition(). However, just pass-through |
| 138 // FakeDef and FakeUse instructions that might have been inserted |
| 139 // prior to lowering. |
| 137 Inst->setDeleted(); | 140 Inst->setDeleted(); |
| 138 switch (Inst->getKind()) { | 141 switch (Inst->getKind()) { |
| 139 case Inst::Alloca: | 142 case Inst::Alloca: |
| 140 lowerAlloca(llvm::cast<InstAlloca>(Inst)); | 143 lowerAlloca(llvm::cast<InstAlloca>(Inst)); |
| 141 break; | 144 break; |
| 142 case Inst::Arithmetic: | 145 case Inst::Arithmetic: |
| 143 lowerArithmetic(llvm::cast<InstArithmetic>(Inst)); | 146 lowerArithmetic(llvm::cast<InstArithmetic>(Inst)); |
| 144 break; | 147 break; |
| 145 case Inst::Assign: | 148 case Inst::Assign: |
| 146 lowerAssign(llvm::cast<InstAssign>(Inst)); | 149 lowerAssign(llvm::cast<InstAssign>(Inst)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 break; | 190 break; |
| 188 case Inst::Store: | 191 case Inst::Store: |
| 189 lowerStore(llvm::cast<InstStore>(Inst)); | 192 lowerStore(llvm::cast<InstStore>(Inst)); |
| 190 break; | 193 break; |
| 191 case Inst::Switch: | 194 case Inst::Switch: |
| 192 lowerSwitch(llvm::cast<InstSwitch>(Inst)); | 195 lowerSwitch(llvm::cast<InstSwitch>(Inst)); |
| 193 break; | 196 break; |
| 194 case Inst::Unreachable: | 197 case Inst::Unreachable: |
| 195 lowerUnreachable(llvm::cast<InstUnreachable>(Inst)); | 198 lowerUnreachable(llvm::cast<InstUnreachable>(Inst)); |
| 196 break; | 199 break; |
| 197 case Inst::BundleLock: | 200 default: |
| 198 case Inst::BundleUnlock: | 201 lowerOther(Inst); |
| 199 case Inst::FakeDef: | |
| 200 case Inst::FakeUse: | |
| 201 case Inst::FakeKill: | |
| 202 case Inst::Target: | |
| 203 // These are all Target instruction types and shouldn't be | |
| 204 // encountered at this stage. | |
| 205 Func->setError("Can't lower unsupported instruction type"); | |
| 206 break; | 202 break; |
| 207 } | 203 } |
| 208 | 204 |
| 209 postLower(); | 205 postLower(); |
| 210 } | 206 } |
| 211 | 207 |
| 212 Context.advanceCur(); | 208 Context.advanceCur(); |
| 213 Context.advanceNext(); | 209 Context.advanceNext(); |
| 214 } | 210 } |
| 215 | 211 |
| 212 void TargetLowering::lowerOther(const Inst *Instr) { |
| 213 (void)Instr; |
| 214 Func->setError("Can't lower unsupported instruction type"); |
| 215 } |
| 216 |
| 216 // Drives register allocation, allowing all physical registers (except | 217 // Drives register allocation, allowing all physical registers (except |
| 217 // perhaps for the frame pointer) to be allocated. This set of | 218 // perhaps for the frame pointer) to be allocated. This set of |
| 218 // registers could potentially be parameterized if we want to restrict | 219 // registers could potentially be parameterized if we want to restrict |
| 219 // registers e.g. for performance testing. | 220 // registers e.g. for performance testing. |
| 220 void TargetLowering::regAlloc(RegAllocKind Kind) { | 221 void TargetLowering::regAlloc(RegAllocKind Kind) { |
| 221 TimerMarker T(TimerStack::TT_regAlloc, Func); | 222 TimerMarker T(TimerStack::TT_regAlloc, Func); |
| 222 LinearScan LinearScan(Func); | 223 LinearScan LinearScan(Func); |
| 223 RegSetMask RegInclude = RegSet_None; | 224 RegSetMask RegInclude = RegSet_None; |
| 224 RegSetMask RegExclude = RegSet_None; | 225 RegSetMask RegExclude = RegSet_None; |
| 225 RegInclude |= RegSet_CallerSave; | 226 RegInclude |= RegSet_CallerSave; |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 if (Target == Target_##X) \ | 537 if (Target == Target_##X) \ |
| 537 return TargetHeader##X::create(Ctx); | 538 return TargetHeader##X::create(Ctx); |
| 538 #include "llvm/Config/SZTargets.def" | 539 #include "llvm/Config/SZTargets.def" |
| 539 | 540 |
| 540 llvm::report_fatal_error("Unsupported target header lowering"); | 541 llvm::report_fatal_error("Unsupported target header lowering"); |
| 541 } | 542 } |
| 542 | 543 |
| 543 TargetHeaderLowering::~TargetHeaderLowering() {} | 544 TargetHeaderLowering::~TargetHeaderLowering() {} |
| 544 | 545 |
| 545 } // end of namespace Ice | 546 } // end of namespace Ice |
| OLD | NEW |