| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 template <class MachineTraits> | 116 template <class MachineTraits> |
| 117 BoolFoldingEntry<MachineTraits>::BoolFoldingEntry(Inst *I) | 117 BoolFoldingEntry<MachineTraits>::BoolFoldingEntry(Inst *I) |
| 118 : Instr(I), IsComplex(BoolFolding<MachineTraits>::hasComplexLowering(I)) {} | 118 : Instr(I), IsComplex(BoolFolding<MachineTraits>::hasComplexLowering(I)) {} |
| 119 | 119 |
| 120 template <class MachineTraits> | 120 template <class MachineTraits> |
| 121 typename BoolFolding<MachineTraits>::BoolFoldingProducerKind | 121 typename BoolFolding<MachineTraits>::BoolFoldingProducerKind |
| 122 BoolFolding<MachineTraits>::getProducerKind(const Inst *Instr) { | 122 BoolFolding<MachineTraits>::getProducerKind(const Inst *Instr) { |
| 123 if (llvm::isa<InstIcmp>(Instr)) { | 123 if (llvm::isa<InstIcmp>(Instr)) { |
| 124 if (MachineTraits::Is64Bit || Instr->getSrc(0)->getType() != IceType_i64) | 124 if (MachineTraits::Is64Bit || Instr->getSrc(0)->getType() != IceType_i64) |
| 125 return PK_Icmp32; | 125 return PK_Icmp32; |
| 126 return PK_None; // TODO(stichnot): actually PK_Icmp64; | 126 return PK_Icmp64; |
| 127 } | 127 } |
| 128 return PK_None; // TODO(stichnot): remove this | 128 return PK_None; // TODO(stichnot): remove this |
| 129 | 129 |
| 130 if (llvm::isa<InstFcmp>(Instr)) | 130 if (llvm::isa<InstFcmp>(Instr)) |
| 131 return PK_Fcmp; | 131 return PK_Fcmp; |
| 132 if (auto *Cast = llvm::dyn_cast<InstCast>(Instr)) { | 132 if (auto *Cast = llvm::dyn_cast<InstCast>(Instr)) { |
| 133 switch (Cast->getCastKind()) { | 133 switch (Cast->getCastKind()) { |
| 134 default: | 134 default: |
| 135 return PK_None; | 135 return PK_None; |
| 136 case InstCast::Trunc: | 136 case InstCast::Trunc: |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 Producers[Var->getIndex()] = BoolFoldingEntry<MachineTraits>(&Instr); | 193 Producers[Var->getIndex()] = BoolFoldingEntry<MachineTraits>(&Instr); |
| 194 } | 194 } |
| 195 // Check each src variable against the map. | 195 // Check each src variable against the map. |
| 196 FOREACH_VAR_IN_INST(Var, Instr) { | 196 FOREACH_VAR_IN_INST(Var, Instr) { |
| 197 SizeT VarNum = Var->getIndex(); | 197 SizeT VarNum = Var->getIndex(); |
| 198 if (containsValid(VarNum)) { | 198 if (containsValid(VarNum)) { |
| 199 if (IndexOfVarOperandInInst(Var) != | 199 if (IndexOfVarOperandInInst(Var) != |
| 200 0 // All valid consumers use Var as the first source operand | 200 0 // All valid consumers use Var as the first source operand |
| 201 || | 201 || |
| 202 getConsumerKind(&Instr) == CK_None // must be white-listed | 202 getConsumerKind(&Instr) == CK_None // must be white-listed |
| 203 || (Producers[VarNum].IsComplex && // complex can't be multi-use | 203 || |
| 204 Producers[VarNum].NumUses > 0)) { | 204 (getConsumerKind(&Instr) != CK_Br && // Icmp64 only folds in branch |
| 205 getProducerKind(Producers[VarNum].Instr) != PK_Icmp32) || |
| 206 (Producers[VarNum].IsComplex && // complex can't be multi-use |
| 207 Producers[VarNum].NumUses > 0)) { |
| 205 setInvalid(VarNum); | 208 setInvalid(VarNum); |
| 206 continue; | 209 continue; |
| 207 } | 210 } |
| 208 ++Producers[VarNum].NumUses; | 211 ++Producers[VarNum].NumUses; |
| 209 if (Instr.isLastUse(Var)) { | 212 if (Instr.isLastUse(Var)) { |
| 210 Producers[VarNum].IsLiveOut = false; | 213 Producers[VarNum].IsLiveOut = false; |
| 211 } | 214 } |
| 212 } | 215 } |
| 213 } | 216 } |
| 214 } | 217 } |
| (...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1908 return; | 1911 return; |
| 1909 } | 1912 } |
| 1910 Operand *Cond = Inst->getCondition(); | 1913 Operand *Cond = Inst->getCondition(); |
| 1911 | 1914 |
| 1912 // Handle folding opportunities. | 1915 // Handle folding opportunities. |
| 1913 if (const class Inst *Producer = FoldingInfo.getProducerFor(Cond)) { | 1916 if (const class Inst *Producer = FoldingInfo.getProducerFor(Cond)) { |
| 1914 assert(Producer->isDeleted()); | 1917 assert(Producer->isDeleted()); |
| 1915 switch (BoolFolding::getProducerKind(Producer)) { | 1918 switch (BoolFolding::getProducerKind(Producer)) { |
| 1916 default: | 1919 default: |
| 1917 break; | 1920 break; |
| 1918 case BoolFolding::PK_Icmp32: { | 1921 case BoolFolding::PK_Icmp32: |
| 1919 // TODO(stichnot): Refactor similarities between this block and the | 1922 case BoolFolding::PK_Icmp64: { |
| 1920 // corresponding code in lowerIcmp(). | 1923 lowerIcmpAndBr(llvm::dyn_cast<InstIcmp>(Producer), Inst); |
| 1921 auto *Cmp = llvm::dyn_cast<InstIcmp>(Producer); | |
| 1922 Operand *Src0 = Producer->getSrc(0); | |
| 1923 Operand *Src1 = legalize(Producer->getSrc(1)); | |
| 1924 Operand *Src0RM = legalizeSrc0ForCmp(Src0, Src1); | |
| 1925 _cmp(Src0RM, Src1); | |
| 1926 _br(Traits::getIcmp32Mapping(Cmp->getCondition()), Inst->getTargetTrue(), | |
| 1927 Inst->getTargetFalse()); | |
| 1928 return; | 1924 return; |
| 1929 } | 1925 } |
| 1930 } | 1926 } |
| 1931 } | 1927 } |
| 1932 | 1928 |
| 1933 Operand *Src0 = legalize(Cond, Legal_Reg | Legal_Mem); | 1929 Operand *Src0 = legalize(Cond, Legal_Reg | Legal_Mem); |
| 1934 Constant *Zero = Ctx->getConstantZero(IceType_i32); | 1930 Constant *Zero = Ctx->getConstantZero(IceType_i32); |
| 1935 _cmp(Src0, Zero); | 1931 _cmp(Src0, Zero); |
| 1936 _br(Traits::Cond::Br_ne, Inst->getTargetTrue(), Inst->getTargetFalse()); | 1932 _br(Traits::Cond::Br_ne, Inst->getTargetTrue(), Inst->getTargetFalse()); |
| 1937 } | 1933 } |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2647 inline bool isZero(const Operand *Opnd) { | 2643 inline bool isZero(const Operand *Opnd) { |
| 2648 if (auto *C64 = llvm::dyn_cast<ConstantInteger64>(Opnd)) | 2644 if (auto *C64 = llvm::dyn_cast<ConstantInteger64>(Opnd)) |
| 2649 return C64->getValue() == 0; | 2645 return C64->getValue() == 0; |
| 2650 if (auto *C32 = llvm::dyn_cast<ConstantInteger32>(Opnd)) | 2646 if (auto *C32 = llvm::dyn_cast<ConstantInteger32>(Opnd)) |
| 2651 return C32->getValue() == 0; | 2647 return C32->getValue() == 0; |
| 2652 return false; | 2648 return false; |
| 2653 } | 2649 } |
| 2654 | 2650 |
| 2655 template <class Machine> | 2651 template <class Machine> |
| 2656 void TargetX86Base<Machine>::lowerIcmp(const InstIcmp *Inst) { | 2652 void TargetX86Base<Machine>::lowerIcmp(const InstIcmp *Inst) { |
| 2657 Operand *Src0 = legalize(Inst->getSrc(0)); | 2653 constexpr InstBr *Br = nullptr; |
| 2658 Operand *Src1 = legalize(Inst->getSrc(1)); | 2654 lowerIcmpAndBr(Inst, Br); |
| 2659 Variable *Dest = Inst->getDest(); | 2655 } |
| 2656 |
| 2657 template <class Machine> |
| 2658 void TargetX86Base<Machine>::lowerIcmpAndBr(const InstIcmp *Icmp, |
| 2659 const InstBr *Br) { |
| 2660 Operand *Src0 = legalize(Icmp->getSrc(0)); |
| 2661 Operand *Src1 = legalize(Icmp->getSrc(1)); |
| 2662 Variable *Dest = Icmp->getDest(); |
| 2660 | 2663 |
| 2661 if (isVectorType(Dest->getType())) { | 2664 if (isVectorType(Dest->getType())) { |
| 2665 if (Br) |
| 2666 llvm::report_fatal_error("vector compare/branch cannot be folded"); |
| 2662 Type Ty = Src0->getType(); | 2667 Type Ty = Src0->getType(); |
| 2663 // Promote i1 vectors to 128 bit integer vector types. | 2668 // Promote i1 vectors to 128 bit integer vector types. |
| 2664 if (typeElementType(Ty) == IceType_i1) { | 2669 if (typeElementType(Ty) == IceType_i1) { |
| 2665 Type NewTy = IceType_NUM; | 2670 Type NewTy = IceType_NUM; |
| 2666 switch (Ty) { | 2671 switch (Ty) { |
| 2667 default: | 2672 default: |
| 2668 llvm_unreachable("unexpected type"); | 2673 llvm_unreachable("unexpected type"); |
| 2669 break; | 2674 break; |
| 2670 case IceType_v4i1: | 2675 case IceType_v4i1: |
| 2671 NewTy = IceType_v4i32; | 2676 NewTy = IceType_v4i32; |
| 2672 break; | 2677 break; |
| 2673 case IceType_v8i1: | 2678 case IceType_v8i1: |
| 2674 NewTy = IceType_v8i16; | 2679 NewTy = IceType_v8i16; |
| 2675 break; | 2680 break; |
| 2676 case IceType_v16i1: | 2681 case IceType_v16i1: |
| 2677 NewTy = IceType_v16i8; | 2682 NewTy = IceType_v16i8; |
| 2678 break; | 2683 break; |
| 2679 } | 2684 } |
| 2680 Variable *NewSrc0 = Func->makeVariable(NewTy); | 2685 Variable *NewSrc0 = Func->makeVariable(NewTy); |
| 2681 Variable *NewSrc1 = Func->makeVariable(NewTy); | 2686 Variable *NewSrc1 = Func->makeVariable(NewTy); |
| 2682 lowerCast(InstCast::create(Func, InstCast::Sext, NewSrc0, Src0)); | 2687 lowerCast(InstCast::create(Func, InstCast::Sext, NewSrc0, Src0)); |
| 2683 lowerCast(InstCast::create(Func, InstCast::Sext, NewSrc1, Src1)); | 2688 lowerCast(InstCast::create(Func, InstCast::Sext, NewSrc1, Src1)); |
| 2684 Src0 = NewSrc0; | 2689 Src0 = NewSrc0; |
| 2685 Src1 = NewSrc1; | 2690 Src1 = NewSrc1; |
| 2686 Ty = NewTy; | 2691 Ty = NewTy; |
| 2687 } | 2692 } |
| 2688 | 2693 |
| 2689 InstIcmp::ICond Condition = Inst->getCondition(); | 2694 InstIcmp::ICond Condition = Icmp->getCondition(); |
| 2690 | 2695 |
| 2691 Operand *Src0RM = legalize(Src0, Legal_Reg | Legal_Mem); | 2696 Operand *Src0RM = legalize(Src0, Legal_Reg | Legal_Mem); |
| 2692 Operand *Src1RM = legalize(Src1, Legal_Reg | Legal_Mem); | 2697 Operand *Src1RM = legalize(Src1, Legal_Reg | Legal_Mem); |
| 2693 | 2698 |
| 2694 // SSE2 only has signed comparison operations. Transform unsigned inputs in | 2699 // SSE2 only has signed comparison operations. Transform unsigned inputs in |
| 2695 // a manner that allows for the use of signed comparison operations by | 2700 // a manner that allows for the use of signed comparison operations by |
| 2696 // flipping the high order bits. | 2701 // flipping the high order bits. |
| 2697 if (Condition == InstIcmp::Ugt || Condition == InstIcmp::Uge || | 2702 if (Condition == InstIcmp::Ugt || Condition == InstIcmp::Uge || |
| 2698 Condition == InstIcmp::Ult || Condition == InstIcmp::Ule) { | 2703 Condition == InstIcmp::Ult || Condition == InstIcmp::Ule) { |
| 2699 Variable *T0 = makeReg(Ty); | 2704 Variable *T0 = makeReg(Ty); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2761 _pxor(T, MinusOne); | 2766 _pxor(T, MinusOne); |
| 2762 } break; | 2767 } break; |
| 2763 } | 2768 } |
| 2764 | 2769 |
| 2765 _movp(Dest, T); | 2770 _movp(Dest, T); |
| 2766 eliminateNextVectorSextInstruction(Dest); | 2771 eliminateNextVectorSextInstruction(Dest); |
| 2767 return; | 2772 return; |
| 2768 } | 2773 } |
| 2769 | 2774 |
| 2770 if (!Traits::Is64Bit && Src0->getType() == IceType_i64) { | 2775 if (!Traits::Is64Bit && Src0->getType() == IceType_i64) { |
| 2771 lowerIcmp64(Inst); | 2776 lowerIcmp64(Icmp, Br); |
| 2772 return; | 2777 return; |
| 2773 } | 2778 } |
| 2774 | 2779 |
| 2775 // cmp b, c | 2780 // cmp b, c |
| 2776 if (isZero(Src1)) { | 2781 if (isZero(Src1)) { |
| 2777 switch (Inst->getCondition()) { | 2782 switch (Icmp->getCondition()) { |
| 2778 default: | 2783 default: |
| 2779 break; | 2784 break; |
| 2780 case InstIcmp::Uge: | 2785 case InstIcmp::Uge: |
| 2781 _mov(Dest, Ctx->getConstantInt(Dest->getType(), 1)); | 2786 movOrBr(true, Dest, Br); |
| 2782 return; | 2787 return; |
| 2783 case InstIcmp::Ult: | 2788 case InstIcmp::Ult: |
| 2784 _mov(Dest, Ctx->getConstantInt(Dest->getType(), 0)); | 2789 movOrBr(false, Dest, Br); |
| 2785 return; | 2790 return; |
| 2786 } | 2791 } |
| 2787 } | 2792 } |
| 2788 Operand *Src0RM = legalizeSrc0ForCmp(Src0, Src1); | 2793 Operand *Src0RM = legalizeSrc0ForCmp(Src0, Src1); |
| 2789 _cmp(Src0RM, Src1); | 2794 _cmp(Src0RM, Src1); |
| 2790 _setcc(Dest, Traits::getIcmp32Mapping(Inst->getCondition())); | 2795 setccOrBr(Traits::getIcmp32Mapping(Icmp->getCondition()), Dest, Br); |
| 2791 } | 2796 } |
| 2792 | 2797 |
| 2793 template <typename Machine> | 2798 template <typename Machine> |
| 2794 template <typename T> | 2799 template <typename T> |
| 2795 typename std::enable_if<!T::Is64Bit, void>::type | 2800 typename std::enable_if<!T::Is64Bit, void>::type |
| 2796 TargetX86Base<Machine>::lowerIcmp64(const InstIcmp *Inst) { | 2801 TargetX86Base<Machine>::lowerIcmp64(const InstIcmp *Icmp, const InstBr *Br) { |
| 2797 // a=icmp cond, b, c ==> cmp b,c; a=1; br cond,L1; FakeUse(a); a=0; L1: | 2802 // a=icmp cond, b, c ==> cmp b,c; a=1; br cond,L1; FakeUse(a); a=0; L1: |
| 2798 Operand *Src0 = legalize(Inst->getSrc(0)); | 2803 Operand *Src0 = legalize(Icmp->getSrc(0)); |
| 2799 Operand *Src1 = legalize(Inst->getSrc(1)); | 2804 Operand *Src1 = legalize(Icmp->getSrc(1)); |
| 2800 Variable *Dest = Inst->getDest(); | 2805 Variable *Dest = Icmp->getDest(); |
| 2801 InstIcmp::ICond Condition = Inst->getCondition(); | 2806 InstIcmp::ICond Condition = Icmp->getCondition(); |
| 2802 size_t Index = static_cast<size_t>(Condition); | 2807 size_t Index = static_cast<size_t>(Condition); |
| 2803 assert(Index < Traits::TableIcmp64Size); | 2808 assert(Index < Traits::TableIcmp64Size); |
| 2804 Constant *Zero = Ctx->getConstantZero(IceType_i32); | |
| 2805 Constant *One = Ctx->getConstantInt32(1); | |
| 2806 Operand *Src0LoRM = nullptr; | 2809 Operand *Src0LoRM = nullptr; |
| 2807 Operand *Src0HiRM = nullptr; | 2810 Operand *Src0HiRM = nullptr; |
| 2808 // Legalize the portions of Src0 that are going to be needed. | 2811 // Legalize the portions of Src0 that are going to be needed. |
| 2809 if (isZero(Src1)) { | 2812 if (isZero(Src1)) { |
| 2810 switch (Condition) { | 2813 switch (Condition) { |
| 2811 default: | 2814 default: |
| 2812 llvm_unreachable("unexpected condition"); | 2815 llvm_unreachable("unexpected condition"); |
| 2813 break; | 2816 break; |
| 2814 // These two are not optimized, so we fall through to the general case, | 2817 // These two are not optimized, so we fall through to the general case, |
| 2815 // which needs the upper and lower halves legalized. | 2818 // which needs the upper and lower halves legalized. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2844 Variable *Temp = nullptr; | 2847 Variable *Temp = nullptr; |
| 2845 switch (Condition) { | 2848 switch (Condition) { |
| 2846 default: | 2849 default: |
| 2847 llvm_unreachable("unexpected condition"); | 2850 llvm_unreachable("unexpected condition"); |
| 2848 break; | 2851 break; |
| 2849 case InstIcmp::Eq: | 2852 case InstIcmp::Eq: |
| 2850 case InstIcmp::Ule: | 2853 case InstIcmp::Ule: |
| 2851 _mov(Temp, Src0LoRM); | 2854 _mov(Temp, Src0LoRM); |
| 2852 _or(Temp, Src0HiRM); | 2855 _or(Temp, Src0HiRM); |
| 2853 Context.insert(InstFakeUse::create(Func, Temp)); | 2856 Context.insert(InstFakeUse::create(Func, Temp)); |
| 2854 _setcc(Dest, Traits::Cond::Br_e); | 2857 setccOrBr(Traits::Cond::Br_e, Dest, Br); |
| 2855 return; | 2858 return; |
| 2856 case InstIcmp::Ne: | 2859 case InstIcmp::Ne: |
| 2857 case InstIcmp::Ugt: | 2860 case InstIcmp::Ugt: |
| 2858 _mov(Temp, Src0LoRM); | 2861 _mov(Temp, Src0LoRM); |
| 2859 _or(Temp, Src0HiRM); | 2862 _or(Temp, Src0HiRM); |
| 2860 Context.insert(InstFakeUse::create(Func, Temp)); | 2863 Context.insert(InstFakeUse::create(Func, Temp)); |
| 2861 _setcc(Dest, Traits::Cond::Br_ne); | 2864 setccOrBr(Traits::Cond::Br_ne, Dest, Br); |
| 2862 return; | 2865 return; |
| 2863 case InstIcmp::Uge: | 2866 case InstIcmp::Uge: |
| 2864 _mov(Dest, Ctx->getConstantInt(Dest->getType(), 1)); | 2867 movOrBr(true, Dest, Br); |
| 2865 return; | 2868 return; |
| 2866 case InstIcmp::Ult: | 2869 case InstIcmp::Ult: |
| 2867 _mov(Dest, Ctx->getConstantInt(Dest->getType(), 0)); | 2870 movOrBr(false, Dest, Br); |
| 2868 return; | 2871 return; |
| 2869 case InstIcmp::Sgt: | 2872 case InstIcmp::Sgt: |
| 2870 break; | 2873 break; |
| 2871 case InstIcmp::Sge: | 2874 case InstIcmp::Sge: |
| 2872 _test(Src0HiRM, SignMask); | 2875 _test(Src0HiRM, SignMask); |
| 2873 _setcc(Dest, Traits::Cond::Br_e); | 2876 setccOrBr(Traits::Cond::Br_e, Dest, Br); |
| 2874 return; | 2877 return; |
| 2875 case InstIcmp::Slt: | 2878 case InstIcmp::Slt: |
| 2876 _test(Src0HiRM, SignMask); | 2879 _test(Src0HiRM, SignMask); |
| 2877 _setcc(Dest, Traits::Cond::Br_ne); | 2880 setccOrBr(Traits::Cond::Br_ne, Dest, Br); |
| 2878 return; | 2881 return; |
| 2879 case InstIcmp::Sle: | 2882 case InstIcmp::Sle: |
| 2880 break; | 2883 break; |
| 2881 } | 2884 } |
| 2882 } | 2885 } |
| 2883 // Handle general compares. | 2886 // Handle general compares. |
| 2884 Operand *Src1LoRI = legalize(loOperand(Src1), Legal_Reg | Legal_Imm); | 2887 Operand *Src1LoRI = legalize(loOperand(Src1), Legal_Reg | Legal_Imm); |
| 2885 Operand *Src1HiRI = legalize(hiOperand(Src1), Legal_Reg | Legal_Imm); | 2888 Operand *Src1HiRI = legalize(hiOperand(Src1), Legal_Reg | Legal_Imm); |
| 2886 typename Traits::Insts::Label *LabelFalse = | 2889 if (Br == nullptr) { |
| 2887 Traits::Insts::Label::create(Func, this); | 2890 Constant *Zero = Ctx->getConstantInt(Dest->getType(), 0); |
| 2888 typename Traits::Insts::Label *LabelTrue = | 2891 Constant *One = Ctx->getConstantInt(Dest->getType(), 1); |
| 2889 Traits::Insts::Label::create(Func, this); | 2892 typename Traits::Insts::Label *LabelFalse = |
| 2890 _mov(Dest, One); | 2893 Traits::Insts::Label::create(Func, this); |
| 2891 _cmp(Src0HiRM, Src1HiRI); | 2894 typename Traits::Insts::Label *LabelTrue = |
| 2892 if (Traits::TableIcmp64[Index].C1 != Traits::Cond::Br_None) | 2895 Traits::Insts::Label::create(Func, this); |
| 2893 _br(Traits::TableIcmp64[Index].C1, LabelTrue); | 2896 _mov(Dest, One); |
| 2894 if (Traits::TableIcmp64[Index].C2 != Traits::Cond::Br_None) | 2897 _cmp(Src0HiRM, Src1HiRI); |
| 2895 _br(Traits::TableIcmp64[Index].C2, LabelFalse); | 2898 if (Traits::TableIcmp64[Index].C1 != Traits::Cond::Br_None) |
| 2896 _cmp(Src0LoRM, Src1LoRI); | 2899 _br(Traits::TableIcmp64[Index].C1, LabelTrue); |
| 2897 _br(Traits::TableIcmp64[Index].C3, LabelTrue); | 2900 if (Traits::TableIcmp64[Index].C2 != Traits::Cond::Br_None) |
| 2898 Context.insert(LabelFalse); | 2901 _br(Traits::TableIcmp64[Index].C2, LabelFalse); |
| 2899 _mov_redefined(Dest, Zero); | 2902 _cmp(Src0LoRM, Src1LoRI); |
| 2900 Context.insert(LabelTrue); | 2903 _br(Traits::TableIcmp64[Index].C3, LabelTrue); |
| 2904 Context.insert(LabelFalse); |
| 2905 _mov_redefined(Dest, Zero); |
| 2906 Context.insert(LabelTrue); |
| 2907 } else { |
| 2908 _cmp(Src0HiRM, Src1HiRI); |
| 2909 if (Traits::TableIcmp64[Index].C1 != Traits::Cond::Br_None) |
| 2910 _br(Traits::TableIcmp64[Index].C1, Br->getTargetTrue()); |
| 2911 if (Traits::TableIcmp64[Index].C2 != Traits::Cond::Br_None) |
| 2912 _br(Traits::TableIcmp64[Index].C2, Br->getTargetFalse()); |
| 2913 _cmp(Src0LoRM, Src1LoRI); |
| 2914 _br(Traits::TableIcmp64[Index].C3, Br->getTargetTrue(), |
| 2915 Br->getTargetFalse()); |
| 2916 } |
| 2901 } | 2917 } |
| 2902 | 2918 |
| 2903 template <class Machine> | 2919 template <class Machine> |
| 2920 void TargetX86Base<Machine>::setccOrBr(typename Traits::Cond::BrCond Condition, |
| 2921 Variable *Dest, const InstBr *Br) { |
| 2922 if (Br == nullptr) { |
| 2923 _setcc(Dest, Condition); |
| 2924 } else { |
| 2925 _br(Condition, Br->getTargetTrue(), Br->getTargetFalse()); |
| 2926 } |
| 2927 } |
| 2928 |
| 2929 template <class Machine> |
| 2930 void TargetX86Base<Machine>::movOrBr(bool IcmpResult, Variable *Dest, |
| 2931 const InstBr *Br) { |
| 2932 if (Br == nullptr) { |
| 2933 _mov(Dest, Ctx->getConstantInt(Dest->getType(), (IcmpResult ? 1 : 0))); |
| 2934 } else { |
| 2935 // TODO(sehr,stichnot): This could be done with a single unconditional |
| 2936 // branch instruction, but subzero doesn't know how to handle the resulting |
| 2937 // control flow graph changes now. Make it do so to eliminate mov and cmp. |
| 2938 _mov(Dest, Ctx->getConstantInt(Dest->getType(), (IcmpResult ? 1 : 0))); |
| 2939 _cmp(Dest, Ctx->getConstantInt(Dest->getType(), 0)); |
| 2940 _br(Traits::Cond::Br_ne, Br->getTargetTrue(), Br->getTargetFalse()); |
| 2941 } |
| 2942 } |
| 2943 |
| 2944 template <class Machine> |
| 2904 void TargetX86Base<Machine>::lowerInsertElement(const InstInsertElement *Inst) { | 2945 void TargetX86Base<Machine>::lowerInsertElement(const InstInsertElement *Inst) { |
| 2905 Operand *SourceVectNotLegalized = Inst->getSrc(0); | 2946 Operand *SourceVectNotLegalized = Inst->getSrc(0); |
| 2906 Operand *ElementToInsertNotLegalized = Inst->getSrc(1); | 2947 Operand *ElementToInsertNotLegalized = Inst->getSrc(1); |
| 2907 ConstantInteger32 *ElementIndex = | 2948 ConstantInteger32 *ElementIndex = |
| 2908 llvm::dyn_cast<ConstantInteger32>(Inst->getSrc(2)); | 2949 llvm::dyn_cast<ConstantInteger32>(Inst->getSrc(2)); |
| 2909 // Only constant indices are allowed in PNaCl IR. | 2950 // Only constant indices are allowed in PNaCl IR. |
| 2910 assert(ElementIndex); | 2951 assert(ElementIndex); |
| 2911 unsigned Index = ElementIndex->getValue(); | 2952 unsigned Index = ElementIndex->getValue(); |
| 2912 assert(Index < typeNumElements(SourceVectNotLegalized->getType())); | 2953 assert(Index < typeNumElements(SourceVectNotLegalized->getType())); |
| 2913 | 2954 |
| (...skipping 2686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5600 } | 5641 } |
| 5601 // the offset is not eligible for blinding or pooling, return the original | 5642 // the offset is not eligible for blinding or pooling, return the original |
| 5602 // mem operand | 5643 // mem operand |
| 5603 return MemOperand; | 5644 return MemOperand; |
| 5604 } | 5645 } |
| 5605 | 5646 |
| 5606 } // end of namespace X86Internal | 5647 } // end of namespace X86Internal |
| 5607 } // end of namespace Ice | 5648 } // end of namespace Ice |
| 5608 | 5649 |
| 5609 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H | 5650 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H |
| OLD | NEW |