Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceTargetLoweringX86BaseImpl.h - x86 lowering -*- C++ -*-==// | 1 //===- subzero/src/IceTargetLoweringX86BaseImpl.h - x86 lowering -*- C++ -*-==// |
| 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 /// \file | 10 /// \file |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 802 return false; | 802 return false; |
| 803 } | 803 } |
| 804 | 804 |
| 805 template <typename TraitsType> void TargetX86Base<TraitsType>::doLoadOpt() { | 805 template <typename TraitsType> void TargetX86Base<TraitsType>::doLoadOpt() { |
| 806 TimerMarker _(TimerStack::TT_loadOpt, Func); | 806 TimerMarker _(TimerStack::TT_loadOpt, Func); |
| 807 for (CfgNode *Node : Func->getNodes()) { | 807 for (CfgNode *Node : Func->getNodes()) { |
| 808 Context.init(Node); | 808 Context.init(Node); |
| 809 while (!Context.atEnd()) { | 809 while (!Context.atEnd()) { |
| 810 Variable *LoadDest = nullptr; | 810 Variable *LoadDest = nullptr; |
| 811 Operand *LoadSrc = nullptr; | 811 Operand *LoadSrc = nullptr; |
| 812 Inst *CurInst = Context.getCur(); | 812 Inst *CurInst = iteratorToInst(Context.getCur()); |
|
Eric Holk
2016/08/17 00:33:46
Would just `*Context.getCur()` work?
Jim Stichnoth
2016/08/17 04:43:30
Given that the original code was:
Inst *CurInst
| |
| 813 Inst *Next = Context.getNextInst(); | 813 Inst *Next = Context.getNextInst(); |
| 814 // Determine whether the current instruction is a Load instruction or | 814 // Determine whether the current instruction is a Load instruction or |
| 815 // equivalent. | 815 // equivalent. |
| 816 if (auto *Load = llvm::dyn_cast<InstLoad>(CurInst)) { | 816 if (auto *Load = llvm::dyn_cast<InstLoad>(CurInst)) { |
| 817 // An InstLoad always qualifies. | 817 // An InstLoad always qualifies. |
| 818 LoadDest = Load->getDest(); | 818 LoadDest = Load->getDest(); |
| 819 constexpr bool DoLegalize = false; | 819 constexpr bool DoLegalize = false; |
| 820 LoadSrc = formMemoryOperand(Load->getSourceAddress(), | 820 LoadSrc = formMemoryOperand(Load->getSourceAddress(), |
| 821 LoadDest->getType(), DoLegalize); | 821 LoadDest->getType(), DoLegalize); |
| 822 } else if (auto *Intrin = llvm::dyn_cast<InstIntrinsicCall>(CurInst)) { | 822 } else if (auto *Intrin = llvm::dyn_cast<InstIntrinsicCall>(CurInst)) { |
| (...skipping 4850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5673 Operand *Src0 = formMemoryOperand(Load->getSourceAddress(), Ty); | 5673 Operand *Src0 = formMemoryOperand(Load->getSourceAddress(), Ty); |
| 5674 doMockBoundsCheck(Src0); | 5674 doMockBoundsCheck(Src0); |
| 5675 auto *Assign = InstAssign::create(Func, DestLoad, Src0); | 5675 auto *Assign = InstAssign::create(Func, DestLoad, Src0); |
| 5676 lowerAssign(Assign); | 5676 lowerAssign(Assign); |
| 5677 } | 5677 } |
| 5678 | 5678 |
| 5679 template <typename TraitsType> | 5679 template <typename TraitsType> |
| 5680 void TargetX86Base<TraitsType>::doAddressOptOther() { | 5680 void TargetX86Base<TraitsType>::doAddressOptOther() { |
| 5681 // Inverts some Icmp instructions which helps doAddressOptLoad later. | 5681 // Inverts some Icmp instructions which helps doAddressOptLoad later. |
| 5682 // TODO(manasijm): Refactor to unify the conditions for Var0 and Var1 | 5682 // TODO(manasijm): Refactor to unify the conditions for Var0 and Var1 |
| 5683 Inst *Instr = Context.getCur(); | 5683 Inst *Instr = iteratorToInst(Context.getCur()); |
| 5684 auto *VMetadata = Func->getVMetadata(); | 5684 auto *VMetadata = Func->getVMetadata(); |
| 5685 if (auto *Icmp = llvm::dyn_cast<InstIcmp>(Instr)) { | 5685 if (auto *Icmp = llvm::dyn_cast<InstIcmp>(Instr)) { |
| 5686 if (llvm::isa<Constant>(Icmp->getSrc(0)) || | 5686 if (llvm::isa<Constant>(Icmp->getSrc(0)) || |
| 5687 llvm::isa<Constant>(Icmp->getSrc(1))) | 5687 llvm::isa<Constant>(Icmp->getSrc(1))) |
| 5688 return; | 5688 return; |
| 5689 auto *Var0 = llvm::dyn_cast<Variable>(Icmp->getSrc(0)); | 5689 auto *Var0 = llvm::dyn_cast<Variable>(Icmp->getSrc(0)); |
| 5690 if (Var0 == nullptr) | 5690 if (Var0 == nullptr) |
| 5691 return; | 5691 return; |
| 5692 if (!VMetadata->isTracked(Var0)) | 5692 if (!VMetadata->isTracked(Var0)) |
| 5693 return; | 5693 return; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 5704 llvm::isa<InstLoad>(Op1Def)) { | 5704 llvm::isa<InstLoad>(Op1Def)) { |
| 5705 return; // Both are loads | 5705 return; // Both are loads |
| 5706 } | 5706 } |
| 5707 } | 5707 } |
| 5708 Icmp->reverseConditionAndOperands(); | 5708 Icmp->reverseConditionAndOperands(); |
| 5709 } | 5709 } |
| 5710 } | 5710 } |
| 5711 | 5711 |
| 5712 template <typename TraitsType> | 5712 template <typename TraitsType> |
| 5713 void TargetX86Base<TraitsType>::doAddressOptLoad() { | 5713 void TargetX86Base<TraitsType>::doAddressOptLoad() { |
| 5714 Inst *Instr = Context.getCur(); | 5714 Inst *Instr = iteratorToInst(Context.getCur()); |
| 5715 Operand *Addr = Instr->getSrc(0); | 5715 Operand *Addr = Instr->getSrc(0); |
| 5716 Variable *Dest = Instr->getDest(); | 5716 Variable *Dest = Instr->getDest(); |
| 5717 if (auto *OptAddr = computeAddressOpt(Instr, Dest->getType(), Addr)) { | 5717 if (auto *OptAddr = computeAddressOpt(Instr, Dest->getType(), Addr)) { |
| 5718 Instr->setDeleted(); | 5718 Instr->setDeleted(); |
| 5719 Context.insert<InstLoad>(Dest, OptAddr); | 5719 Context.insert<InstLoad>(Dest, OptAddr); |
| 5720 } | 5720 } |
| 5721 } | 5721 } |
| 5722 | 5722 |
| 5723 template <typename TraitsType> | 5723 template <typename TraitsType> |
| 5724 void TargetX86Base<TraitsType>::randomlyInsertNop(float Probability, | 5724 void TargetX86Base<TraitsType>::randomlyInsertNop(float Probability, |
| (...skipping 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8090 emitGlobal(*Var, SectionSuffix); | 8090 emitGlobal(*Var, SectionSuffix); |
| 8091 } | 8091 } |
| 8092 } | 8092 } |
| 8093 } break; | 8093 } break; |
| 8094 } | 8094 } |
| 8095 } | 8095 } |
| 8096 } // end of namespace X86NAMESPACE | 8096 } // end of namespace X86NAMESPACE |
| 8097 } // end of namespace Ice | 8097 } // end of namespace Ice |
| 8098 | 8098 |
| 8099 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H | 8099 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H |
| OLD | NEW |