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 5636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5647 // it doesn't need another level of transformation. | 5647 // it doesn't need another level of transformation. |
5648 Variable *DestLoad = Load->getDest(); | 5648 Variable *DestLoad = Load->getDest(); |
5649 Type Ty = DestLoad->getType(); | 5649 Type Ty = DestLoad->getType(); |
5650 Operand *Src0 = formMemoryOperand(Load->getSourceAddress(), Ty); | 5650 Operand *Src0 = formMemoryOperand(Load->getSourceAddress(), Ty); |
5651 doMockBoundsCheck(Src0); | 5651 doMockBoundsCheck(Src0); |
5652 auto *Assign = InstAssign::create(Func, DestLoad, Src0); | 5652 auto *Assign = InstAssign::create(Func, DestLoad, Src0); |
5653 lowerAssign(Assign); | 5653 lowerAssign(Assign); |
5654 } | 5654 } |
5655 | 5655 |
5656 template <typename TraitsType> | 5656 template <typename TraitsType> |
| 5657 void TargetX86Base<TraitsType>::doAddressOptOther() { |
| 5658 // Inverts some Icmp instructions which helps doAddressOptLoad later. |
| 5659 // TODO(manasijm): Refactor to unify the conditions for Var0 and Var1 |
| 5660 Inst *Instr = Context.getCur(); |
| 5661 auto *VMetadata = Func->getVMetadata(); |
| 5662 if (auto *Icmp = llvm::dyn_cast<InstIcmp>(Instr)) { |
| 5663 if (llvm::isa<Constant>(Icmp->getSrc(0)) || |
| 5664 llvm::isa<Constant>(Icmp->getSrc(1))) |
| 5665 return; |
| 5666 auto *Var0 = llvm::dyn_cast<Variable>(Icmp->getSrc(0)); |
| 5667 if (Var0 == nullptr) |
| 5668 return; |
| 5669 if (!VMetadata->isTracked(Var0)) |
| 5670 return; |
| 5671 auto *Op0Def = VMetadata->getFirstDefinitionSingleBlock(Var0); |
| 5672 if (Op0Def == nullptr || !llvm::isa<InstLoad>(Op0Def)) |
| 5673 return; |
| 5674 if (VMetadata->getLocalUseNode(Var0) != Context.getNode()) |
| 5675 return; |
| 5676 |
| 5677 auto *Var1 = llvm::dyn_cast<Variable>(Icmp->getSrc(1)); |
| 5678 if (Var1 != nullptr && VMetadata->isTracked(Var1)) { |
| 5679 auto *Op1Def = VMetadata->getFirstDefinitionSingleBlock(Var1); |
| 5680 if (Op1Def != nullptr && !VMetadata->isMultiBlock(Var1) && |
| 5681 llvm::isa<InstLoad>(Op1Def)) { |
| 5682 return; // Both are loads |
| 5683 } |
| 5684 } |
| 5685 Icmp->reverseConditionAndOperands(); |
| 5686 } |
| 5687 } |
| 5688 |
| 5689 template <typename TraitsType> |
5657 void TargetX86Base<TraitsType>::doAddressOptLoad() { | 5690 void TargetX86Base<TraitsType>::doAddressOptLoad() { |
5658 Inst *Instr = Context.getCur(); | 5691 Inst *Instr = Context.getCur(); |
5659 Operand *Addr = Instr->getSrc(0); | 5692 Operand *Addr = Instr->getSrc(0); |
5660 Variable *Dest = Instr->getDest(); | 5693 Variable *Dest = Instr->getDest(); |
5661 if (auto *OptAddr = computeAddressOpt(Instr, Dest->getType(), Addr)) { | 5694 if (auto *OptAddr = computeAddressOpt(Instr, Dest->getType(), Addr)) { |
5662 Instr->setDeleted(); | 5695 Instr->setDeleted(); |
5663 Context.insert<InstLoad>(Dest, OptAddr); | 5696 Context.insert<InstLoad>(Dest, OptAddr); |
5664 } | 5697 } |
5665 } | 5698 } |
5666 | 5699 |
(...skipping 2367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8034 emitGlobal(*Var, SectionSuffix); | 8067 emitGlobal(*Var, SectionSuffix); |
8035 } | 8068 } |
8036 } | 8069 } |
8037 } break; | 8070 } break; |
8038 } | 8071 } |
8039 } | 8072 } |
8040 } // end of namespace X86NAMESPACE | 8073 } // end of namespace X86NAMESPACE |
8041 } // end of namespace Ice | 8074 } // end of namespace Ice |
8042 | 8075 |
8043 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H | 8076 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H |
OLD | NEW |