OLD | NEW |
1 //===- subzero/src/IceTargetLoweringARM32.cpp - ARM32 lowering ------------===// | 1 //===- subzero/src/IceTargetLoweringARM32.cpp - ARM32 lowering ------------===// |
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 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 | 1293 |
1294 void TargetARM32::div0Check(Type Ty, Operand *SrcLo, Operand *SrcHi) { | 1294 void TargetARM32::div0Check(Type Ty, Operand *SrcLo, Operand *SrcHi) { |
1295 if (isGuaranteedNonzeroInt(SrcLo) || isGuaranteedNonzeroInt(SrcHi)) | 1295 if (isGuaranteedNonzeroInt(SrcLo) || isGuaranteedNonzeroInt(SrcHi)) |
1296 return; | 1296 return; |
1297 Variable *SrcLoReg = legalizeToReg(SrcLo); | 1297 Variable *SrcLoReg = legalizeToReg(SrcLo); |
1298 switch (Ty) { | 1298 switch (Ty) { |
1299 default: | 1299 default: |
1300 llvm::report_fatal_error("Unexpected type"); | 1300 llvm::report_fatal_error("Unexpected type"); |
1301 case IceType_i8: | 1301 case IceType_i8: |
1302 case IceType_i16: { | 1302 case IceType_i16: { |
1303 Operand *ShAmtF = | 1303 Operand *ShAmtImm = shAmtImm(32 - getScalarIntBitWidth(Ty)); |
1304 legalize(Ctx->getConstantInt32(32 - getScalarIntBitWidth(Ty)), | |
1305 Legal_Reg | Legal_Flex); | |
1306 Variable *T = makeReg(IceType_i32); | 1304 Variable *T = makeReg(IceType_i32); |
1307 _lsls(T, SrcLoReg, ShAmtF); | 1305 _lsls(T, SrcLoReg, ShAmtImm); |
1308 Context.insert(InstFakeUse::create(Func, T)); | 1306 Context.insert(InstFakeUse::create(Func, T)); |
1309 } break; | 1307 } break; |
1310 case IceType_i32: { | 1308 case IceType_i32: { |
1311 _tst(SrcLoReg, SrcLoReg); | 1309 _tst(SrcLoReg, SrcLoReg); |
1312 break; | 1310 break; |
1313 } | 1311 } |
1314 case IceType_i64: { | 1312 case IceType_i64: { |
1315 Variable *T = makeReg(IceType_i32); | 1313 Variable *T = makeReg(IceType_i32); |
1316 _orrs(T, SrcLoReg, legalize(SrcHi, Legal_Reg | Legal_Flex)); | 1314 _orrs(T, SrcLoReg, legalize(SrcHi, Legal_Reg | Legal_Flex)); |
1317 // T isn't going to be used, but we need the side-effect of setting flags | 1315 // T isn't going to be used, but we need the side-effect of setting flags |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1447 } | 1445 } |
1448 | 1446 |
1449 Operand *src1RF(TargetARM32 *Target) const { | 1447 Operand *src1RF(TargetARM32 *Target) const { |
1450 return legalizeToRegOrFlex(Target, Src1); | 1448 return legalizeToRegOrFlex(Target, Src1); |
1451 } | 1449 } |
1452 | 1450 |
1453 Variable *unswappedSrc1R(TargetARM32 *Target) const { | 1451 Variable *unswappedSrc1R(TargetARM32 *Target) const { |
1454 return legalizeToReg(Target, Swapped ? Src0 : Src1); | 1452 return legalizeToReg(Target, Swapped ? Src0 : Src1); |
1455 } | 1453 } |
1456 | 1454 |
1457 Operand *unswappedSrc1RF(TargetARM32 *Target) const { | |
1458 return legalizeToRegOrFlex(Target, Swapped ? Src0 : Src1); | |
1459 } | |
1460 | |
1461 protected: | 1455 protected: |
1462 Operand *const Src0; | 1456 Operand *const Src0; |
1463 Operand *const Src1; | 1457 Operand *const Src1; |
1464 const bool Swapped; | 1458 const bool Swapped; |
1465 | 1459 |
1466 static Variable *legalizeToReg(TargetARM32 *Target, Operand *Src) { | 1460 static Variable *legalizeToReg(TargetARM32 *Target, Operand *Src) { |
1467 return Target->legalizeToReg(Src); | 1461 return Target->legalizeToReg(Src); |
1468 } | 1462 } |
1469 | 1463 |
1470 static Operand *legalizeToRegOrFlex(TargetARM32 *Target, Operand *Src) { | 1464 static Operand *legalizeToRegOrFlex(TargetARM32 *Target, Operand *Src) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1515 using DoubleOperands = NumericOperands<ConstantDouble>; | 1509 using DoubleOperands = NumericOperands<ConstantDouble>; |
1516 | 1510 |
1517 class Int32Operands : public NumericOperands<ConstantInteger32> { | 1511 class Int32Operands : public NumericOperands<ConstantInteger32> { |
1518 Int32Operands() = delete; | 1512 Int32Operands() = delete; |
1519 Int32Operands(const Int32Operands &) = delete; | 1513 Int32Operands(const Int32Operands &) = delete; |
1520 Int32Operands &operator=(const Int32Operands &) = delete; | 1514 Int32Operands &operator=(const Int32Operands &) = delete; |
1521 | 1515 |
1522 public: | 1516 public: |
1523 Int32Operands(Operand *S0, Operand *S1) : NumericOperands(S0, S1) {} | 1517 Int32Operands(Operand *S0, Operand *S1) : NumericOperands(S0, S1) {} |
1524 | 1518 |
| 1519 Operand *unswappedSrc1RShAmtImm(TargetARM32 *Target) const { |
| 1520 if (!swappedOperands() && hasConstOperand()) { |
| 1521 return Target->shAmtImm(getConstantValue() & 0x1F); |
| 1522 } |
| 1523 return legalizeToReg(Target, Swapped ? Src0 : Src1); |
| 1524 } |
| 1525 |
1525 bool immediateIsFlexEncodable() const { | 1526 bool immediateIsFlexEncodable() const { |
1526 uint32_t Rotate, Imm8; | 1527 uint32_t Rotate, Imm8; |
1527 return OperandARM32FlexImm::canHoldImm(getConstantValue(), &Rotate, &Imm8); | 1528 return OperandARM32FlexImm::canHoldImm(getConstantValue(), &Rotate, &Imm8); |
1528 } | 1529 } |
1529 | 1530 |
1530 bool negatedImmediateIsFlexEncodable() const { | 1531 bool negatedImmediateIsFlexEncodable() const { |
1531 uint32_t Rotate, Imm8; | 1532 uint32_t Rotate, Imm8; |
1532 return OperandARM32FlexImm::canHoldImm( | 1533 return OperandARM32FlexImm::canHoldImm( |
1533 -static_cast<int32_t>(getConstantValue()), &Rotate, &Imm8); | 1534 -static_cast<int32_t>(getConstantValue()), &Rotate, &Imm8); |
1534 } | 1535 } |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1731 if (ShAmtImm == 0) { | 1732 if (ShAmtImm == 0) { |
1732 _mov(DestLo, Src0RLo); | 1733 _mov(DestLo, Src0RLo); |
1733 _mov(DestHi, SrcsHi.src0R(this)); | 1734 _mov(DestHi, SrcsHi.src0R(this)); |
1734 return; | 1735 return; |
1735 } | 1736 } |
1736 | 1737 |
1737 if (ShAmtImm >= 32) { | 1738 if (ShAmtImm >= 32) { |
1738 if (ShAmtImm == 32) { | 1739 if (ShAmtImm == 32) { |
1739 _mov(DestHi, Src0RLo); | 1740 _mov(DestHi, Src0RLo); |
1740 } else { | 1741 } else { |
1741 Operand *ShAmtOp = legalize(Ctx->getConstantInt32(ShAmtImm - 32), | 1742 Operand *ShAmtOp = shAmtImm(ShAmtImm - 32); |
1742 Legal_Reg | Legal_Flex); | |
1743 _lsl(T_Hi, Src0RLo, ShAmtOp); | 1743 _lsl(T_Hi, Src0RLo, ShAmtOp); |
1744 _mov(DestHi, T_Hi); | 1744 _mov(DestHi, T_Hi); |
1745 } | 1745 } |
1746 | 1746 |
1747 Operand *_0 = | 1747 Operand *_0 = |
1748 legalize(Ctx->getConstantZero(IceType_i32), Legal_Reg | Legal_Flex); | 1748 legalize(Ctx->getConstantZero(IceType_i32), Legal_Reg | Legal_Flex); |
1749 _mov(T_Lo, _0); | 1749 _mov(T_Lo, _0); |
1750 _mov(DestLo, T_Lo); | 1750 _mov(DestLo, T_Lo); |
1751 return; | 1751 return; |
1752 } | 1752 } |
1753 | 1753 |
1754 Variable *Src0RHi = SrcsHi.src0R(this); | 1754 Variable *Src0RHi = SrcsHi.src0R(this); |
1755 Operand *ShAmtOp = | 1755 Operand *ShAmtOp = shAmtImm(ShAmtImm); |
1756 legalize(Ctx->getConstantInt32(ShAmtImm), Legal_Reg | Legal_Flex); | 1756 Operand *ComplShAmtOp = shAmtImm(32 - ShAmtImm); |
1757 Operand *ComplShAmtOp = legalize(Ctx->getConstantInt32(32 - ShAmtImm), | |
1758 Legal_Reg | Legal_Flex); | |
1759 _lsl(T_Hi, Src0RHi, ShAmtOp); | 1757 _lsl(T_Hi, Src0RHi, ShAmtOp); |
1760 _orr(T_Hi, T_Hi, | 1758 _orr(T_Hi, T_Hi, |
1761 OperandARM32FlexReg::create(Func, IceType_i32, Src0RLo, | 1759 OperandARM32FlexReg::create(Func, IceType_i32, Src0RLo, |
1762 OperandARM32::LSR, ComplShAmtOp)); | 1760 OperandARM32::LSR, ComplShAmtOp)); |
1763 _mov(DestHi, T_Hi); | 1761 _mov(DestHi, T_Hi); |
1764 | 1762 |
1765 _lsl(T_Lo, Src0RLo, ShAmtOp); | 1763 _lsl(T_Lo, Src0RLo, ShAmtOp); |
1766 _mov(DestLo, T_Lo); | 1764 _mov(DestLo, T_Lo); |
1767 return; | 1765 return; |
1768 } | 1766 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1821 _mov(DestLo, TA_Lo); | 1819 _mov(DestLo, TA_Lo); |
1822 _mov(DestHi, TA_Hi); | 1820 _mov(DestHi, TA_Hi); |
1823 return; | 1821 return; |
1824 } | 1822 } |
1825 case InstArithmetic::Lshr: | 1823 case InstArithmetic::Lshr: |
1826 case InstArithmetic::Ashr: { | 1824 case InstArithmetic::Ashr: { |
1827 const bool ASR = Op == InstArithmetic::Ashr; | 1825 const bool ASR = Op == InstArithmetic::Ashr; |
1828 if (!SrcsLo.swappedOperands() && SrcsLo.hasConstOperand()) { | 1826 if (!SrcsLo.swappedOperands() && SrcsLo.hasConstOperand()) { |
1829 Variable *Src0RHi = SrcsHi.src0R(this); | 1827 Variable *Src0RHi = SrcsHi.src0R(this); |
1830 // Truncating the ShAmt to [0, 63] because that's what ARM does anyway. | 1828 // Truncating the ShAmt to [0, 63] because that's what ARM does anyway. |
1831 const int32_t ShAmtImm = SrcsLo.getConstantValue() & 0x3F; | 1829 const int32_t ShAmt = SrcsLo.getConstantValue() & 0x3F; |
1832 if (ShAmtImm == 0) { | 1830 if (ShAmt == 0) { |
1833 _mov(DestHi, Src0RHi); | 1831 _mov(DestHi, Src0RHi); |
1834 _mov(DestLo, SrcsLo.src0R(this)); | 1832 _mov(DestLo, SrcsLo.src0R(this)); |
1835 return; | 1833 return; |
1836 } | 1834 } |
1837 | 1835 |
1838 if (ShAmtImm >= 32) { | 1836 if (ShAmt >= 32) { |
1839 if (ShAmtImm == 32) { | 1837 if (ShAmt == 32) { |
1840 _mov(DestLo, Src0RHi); | 1838 _mov(DestLo, Src0RHi); |
1841 } else { | 1839 } else { |
1842 Operand *ShAmtOp = legalize(Ctx->getConstantInt32(ShAmtImm - 32), | 1840 Operand *ShAmtImm = shAmtImm(ShAmt - 32); |
1843 Legal_Reg | Legal_Flex); | |
1844 if (ASR) { | 1841 if (ASR) { |
1845 _asr(T_Lo, Src0RHi, ShAmtOp); | 1842 _asr(T_Lo, Src0RHi, ShAmtImm); |
1846 } else { | 1843 } else { |
1847 _lsr(T_Lo, Src0RHi, ShAmtOp); | 1844 _lsr(T_Lo, Src0RHi, ShAmtImm); |
1848 } | 1845 } |
1849 _mov(DestLo, T_Lo); | 1846 _mov(DestLo, T_Lo); |
1850 } | 1847 } |
1851 | 1848 |
1852 if (ASR) { | 1849 if (ASR) { |
1853 Operand *_31 = legalize(Ctx->getConstantZero(IceType_i32), | 1850 Operand *_31 = shAmtImm(31); |
1854 Legal_Reg | Legal_Flex); | |
1855 _asr(T_Hi, Src0RHi, _31); | 1851 _asr(T_Hi, Src0RHi, _31); |
1856 } else { | 1852 } else { |
1857 Operand *_0 = legalize(Ctx->getConstantZero(IceType_i32), | 1853 Operand *_0 = legalize(Ctx->getConstantZero(IceType_i32), |
1858 Legal_Reg | Legal_Flex); | 1854 Legal_Reg | Legal_Flex); |
1859 _mov(T_Hi, _0); | 1855 _mov(T_Hi, _0); |
1860 } | 1856 } |
1861 _mov(DestHi, T_Hi); | 1857 _mov(DestHi, T_Hi); |
1862 return; | 1858 return; |
1863 } | 1859 } |
1864 | 1860 |
1865 Variable *Src0RLo = SrcsLo.src0R(this); | 1861 Variable *Src0RLo = SrcsLo.src0R(this); |
1866 Operand *ShAmtOp = | 1862 Operand *ShAmtImm = shAmtImm(ShAmt); |
1867 legalize(Ctx->getConstantInt32(ShAmtImm), Legal_Reg | Legal_Flex); | 1863 Operand *ComplShAmtImm = shAmtImm(32 - ShAmt); |
1868 Operand *ComplShAmtOp = legalize(Ctx->getConstantInt32(32 - ShAmtImm), | 1864 _lsr(T_Lo, Src0RLo, ShAmtImm); |
1869 Legal_Reg | Legal_Flex); | |
1870 _lsr(T_Lo, Src0RLo, ShAmtOp); | |
1871 _orr(T_Lo, T_Lo, | 1865 _orr(T_Lo, T_Lo, |
1872 OperandARM32FlexReg::create(Func, IceType_i32, Src0RHi, | 1866 OperandARM32FlexReg::create(Func, IceType_i32, Src0RHi, |
1873 OperandARM32::LSL, ComplShAmtOp)); | 1867 OperandARM32::LSL, ComplShAmtImm)); |
1874 _mov(DestLo, T_Lo); | 1868 _mov(DestLo, T_Lo); |
1875 | 1869 |
1876 if (ASR) { | 1870 if (ASR) { |
1877 _asr(T_Hi, Src0RHi, ShAmtOp); | 1871 _asr(T_Hi, Src0RHi, ShAmtImm); |
1878 } else { | 1872 } else { |
1879 _lsr(T_Hi, Src0RHi, ShAmtOp); | 1873 _lsr(T_Hi, Src0RHi, ShAmtImm); |
1880 } | 1874 } |
1881 _mov(DestHi, T_Hi); | 1875 _mov(DestHi, T_Hi); |
1882 return; | 1876 return; |
1883 } | 1877 } |
1884 | 1878 |
1885 // a=b>>c | 1879 // a=b>>c |
1886 // pnacl-llc does: | 1880 // pnacl-llc does: |
1887 // mov t_b.lo, b.lo | 1881 // mov t_b.lo, b.lo |
1888 // mov t_b.hi, b.hi | 1882 // mov t_b.hi, b.hi |
1889 // mov t_c.lo, c.lo | 1883 // mov t_c.lo, c.lo |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2144 } | 2138 } |
2145 case InstArithmetic::Mul: { | 2139 case InstArithmetic::Mul: { |
2146 Variable *Src0R = Srcs.unswappedSrc0R(this); | 2140 Variable *Src0R = Srcs.unswappedSrc0R(this); |
2147 Variable *Src1R = Srcs.unswappedSrc1R(this); | 2141 Variable *Src1R = Srcs.unswappedSrc1R(this); |
2148 _mul(T, Src0R, Src1R); | 2142 _mul(T, Src0R, Src1R); |
2149 _mov(Dest, T); | 2143 _mov(Dest, T); |
2150 return; | 2144 return; |
2151 } | 2145 } |
2152 case InstArithmetic::Shl: { | 2146 case InstArithmetic::Shl: { |
2153 Variable *Src0R = Srcs.unswappedSrc0R(this); | 2147 Variable *Src0R = Srcs.unswappedSrc0R(this); |
2154 Operand *Src1R = Srcs.unswappedSrc1RF(this); | 2148 Operand *Src1R = Srcs.unswappedSrc1RShAmtImm(this); |
2155 _lsl(T, Src0R, Src1R); | 2149 _lsl(T, Src0R, Src1R); |
2156 _mov(Dest, T); | 2150 _mov(Dest, T); |
2157 return; | 2151 return; |
2158 } | 2152 } |
2159 case InstArithmetic::Lshr: { | 2153 case InstArithmetic::Lshr: { |
2160 Variable *Src0R = Srcs.unswappedSrc0R(this); | 2154 Variable *Src0R = Srcs.unswappedSrc0R(this); |
2161 if (Dest->getType() != IceType_i32) { | 2155 if (Dest->getType() != IceType_i32) { |
2162 _uxt(Src0R, Src0R); | 2156 _uxt(Src0R, Src0R); |
2163 } | 2157 } |
2164 _lsr(T, Src0R, Srcs.unswappedSrc1RF(this)); | 2158 _lsr(T, Src0R, Srcs.unswappedSrc1RShAmtImm(this)); |
2165 _mov(Dest, T); | 2159 _mov(Dest, T); |
2166 return; | 2160 return; |
2167 } | 2161 } |
2168 case InstArithmetic::Ashr: { | 2162 case InstArithmetic::Ashr: { |
2169 Variable *Src0R = Srcs.unswappedSrc0R(this); | 2163 Variable *Src0R = Srcs.unswappedSrc0R(this); |
2170 if (Dest->getType() != IceType_i32) { | 2164 if (Dest->getType() != IceType_i32) { |
2171 _sxt(Src0R, Src0R); | 2165 _sxt(Src0R, Src0R); |
2172 } | 2166 } |
2173 _asr(T, Src0R, Srcs.unswappedSrc1RF(this)); | 2167 _asr(T, Src0R, Srcs.unswappedSrc1RShAmtImm(this)); |
2174 _mov(Dest, T); | 2168 _mov(Dest, T); |
2175 return; | 2169 return; |
2176 } | 2170 } |
2177 case InstArithmetic::Udiv: | 2171 case InstArithmetic::Udiv: |
2178 case InstArithmetic::Sdiv: | 2172 case InstArithmetic::Sdiv: |
2179 case InstArithmetic::Urem: | 2173 case InstArithmetic::Urem: |
2180 case InstArithmetic::Srem: | 2174 case InstArithmetic::Srem: |
2181 llvm::report_fatal_error( | 2175 llvm::report_fatal_error( |
2182 "Integer div/rem should have been handled earlier."); | 2176 "Integer div/rem should have been handled earlier."); |
2183 return; | 2177 return; |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3178 | 3172 |
3179 TargetARM32::CondWhenTrue | 3173 TargetARM32::CondWhenTrue |
3180 TargetARM32::lowerInt8AndInt16IcmpCond(InstIcmp::ICond Condition, Operand *Src0, | 3174 TargetARM32::lowerInt8AndInt16IcmpCond(InstIcmp::ICond Condition, Operand *Src0, |
3181 Operand *Src1) { | 3175 Operand *Src1) { |
3182 Int32Operands Srcs(Src0, Src1); | 3176 Int32Operands Srcs(Src0, Src1); |
3183 const int32_t ShAmt = 32 - getScalarIntBitWidth(Src0->getType()); | 3177 const int32_t ShAmt = 32 - getScalarIntBitWidth(Src0->getType()); |
3184 assert(ShAmt >= 0); | 3178 assert(ShAmt >= 0); |
3185 | 3179 |
3186 if (!Srcs.hasConstOperand()) { | 3180 if (!Srcs.hasConstOperand()) { |
3187 Variable *Src0R = makeReg(IceType_i32); | 3181 Variable *Src0R = makeReg(IceType_i32); |
3188 Operand *ShAmtF = | 3182 Operand *ShAmtImm = shAmtImm(ShAmt); |
3189 legalize(Ctx->getConstantInt32(ShAmt), Legal_Reg | Legal_Flex); | 3183 _lsl(Src0R, legalizeToReg(Src0), ShAmtImm); |
3190 _lsl(Src0R, legalizeToReg(Src0), ShAmtF); | |
3191 | 3184 |
3192 Variable *Src1R = legalizeToReg(Src1); | 3185 Variable *Src1R = legalizeToReg(Src1); |
3193 OperandARM32FlexReg *Src1F = OperandARM32FlexReg::create( | 3186 OperandARM32FlexReg *Src1F = OperandARM32FlexReg::create( |
3194 Func, IceType_i32, Src1R, OperandARM32::LSL, ShAmtF); | 3187 Func, IceType_i32, Src1R, OperandARM32::LSL, ShAmtImm); |
3195 _cmp(Src0R, Src1F); | 3188 _cmp(Src0R, Src1F); |
3196 return CondWhenTrue(getIcmp32Mapping(Condition)); | 3189 return CondWhenTrue(getIcmp32Mapping(Condition)); |
3197 } | 3190 } |
3198 | 3191 |
3199 const int32_t Value = Srcs.getConstantValue(); | 3192 const int32_t Value = Srcs.getConstantValue(); |
3200 if ((Condition == InstIcmp::Eq || Condition == InstIcmp::Ne) && Value == 0) { | 3193 if ((Condition == InstIcmp::Eq || Condition == InstIcmp::Ne) && Value == 0) { |
3201 Operand *ShAmtOp = Ctx->getConstantInt32(ShAmt); | 3194 Operand *ShAmtImm = shAmtImm(ShAmt); |
3202 Variable *T = makeReg(IceType_i32); | 3195 Variable *T = makeReg(IceType_i32); |
3203 _lsls(T, Srcs.src0R(this), ShAmtOp); | 3196 _lsls(T, Srcs.src0R(this), ShAmtImm); |
3204 Context.insert(InstFakeUse::create(Func, T)); | 3197 Context.insert(InstFakeUse::create(Func, T)); |
3205 return CondWhenTrue(getIcmp32Mapping(Condition)); | 3198 return CondWhenTrue(getIcmp32Mapping(Condition)); |
3206 } | 3199 } |
3207 | 3200 |
3208 Variable *ConstR = makeReg(IceType_i32); | 3201 Variable *ConstR = makeReg(IceType_i32); |
3209 _mov(ConstR, | 3202 _mov(ConstR, |
3210 legalize(Ctx->getConstantInt32(Value << ShAmt), Legal_Reg | Legal_Flex)); | 3203 legalize(Ctx->getConstantInt32(Value << ShAmt), Legal_Reg | Legal_Flex)); |
3211 Operand *NonConstF = OperandARM32FlexReg::create( | 3204 Operand *NonConstF = OperandARM32FlexReg::create( |
3212 Func, IceType_i32, Srcs.src0R(this), OperandARM32::LSL, | 3205 Func, IceType_i32, Srcs.src0R(this), OperandARM32::LSL, |
3213 Ctx->getConstantInt32(ShAmt)); | 3206 Ctx->getConstantInt32(ShAmt)); |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3770 _rev(T_Lo, Val_Lo); | 3763 _rev(T_Lo, Val_Lo); |
3771 _rev(T_Hi, Val_Hi); | 3764 _rev(T_Hi, Val_Hi); |
3772 _mov(DestLo, T_Hi); | 3765 _mov(DestLo, T_Hi); |
3773 _mov(DestHi, T_Lo); | 3766 _mov(DestHi, T_Lo); |
3774 } else { | 3767 } else { |
3775 assert(Ty == IceType_i32 || Ty == IceType_i16); | 3768 assert(Ty == IceType_i32 || Ty == IceType_i16); |
3776 Variable *ValR = legalizeToReg(Val); | 3769 Variable *ValR = legalizeToReg(Val); |
3777 Variable *T = makeReg(Ty); | 3770 Variable *T = makeReg(Ty); |
3778 _rev(T, ValR); | 3771 _rev(T, ValR); |
3779 if (Val->getType() == IceType_i16) { | 3772 if (Val->getType() == IceType_i16) { |
3780 Operand *Sixteen = | 3773 Operand *_16 = shAmtImm(16); |
3781 legalize(Ctx->getConstantInt32(16), Legal_Reg | Legal_Flex); | 3774 _lsr(T, T, _16); |
3782 _lsr(T, T, Sixteen); | |
3783 } | 3775 } |
3784 _mov(Dest, T); | 3776 _mov(Dest, T); |
3785 } | 3777 } |
3786 return; | 3778 return; |
3787 } | 3779 } |
3788 case Intrinsics::Ctpop: { | 3780 case Intrinsics::Ctpop: { |
3789 Operand *Val = Instr->getArg(0); | 3781 Operand *Val = Instr->getArg(0); |
3790 InstCall *Call = makeHelperCall(isInt32Asserting32Or64(Val->getType()) | 3782 InstCall *Call = makeHelperCall(isInt32Asserting32Or64(Val->getType()) |
3791 ? H_call_ctpop_i32 | 3783 ? H_call_ctpop_i32 |
3792 : H_call_ctpop_i64, | 3784 : H_call_ctpop_i64, |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4566 return; | 4558 return; |
4567 } | 4559 } |
4568 | 4560 |
4569 Variable *Src0Var = legalizeToReg(Src0); | 4561 Variable *Src0Var = legalizeToReg(Src0); |
4570 // If Src0 is not an i32, we left shift it -- see the icmp lowering for the | 4562 // If Src0 is not an i32, we left shift it -- see the icmp lowering for the |
4571 // reason. | 4563 // reason. |
4572 assert(Src0Var->mustHaveReg()); | 4564 assert(Src0Var->mustHaveReg()); |
4573 const size_t ShiftAmt = 32 - getScalarIntBitWidth(Src0->getType()); | 4565 const size_t ShiftAmt = 32 - getScalarIntBitWidth(Src0->getType()); |
4574 assert(ShiftAmt < 32); | 4566 assert(ShiftAmt < 32); |
4575 if (ShiftAmt > 0) { | 4567 if (ShiftAmt > 0) { |
4576 Operand *ShiftConst = Ctx->getConstantInt32(ShiftAmt); | 4568 Operand *ShAmtImm = shAmtImm(ShiftAmt); |
4577 Variable *T = makeReg(IceType_i32); | 4569 Variable *T = makeReg(IceType_i32); |
4578 _lsl(T, Src0Var, ShiftConst); | 4570 _lsl(T, Src0Var, ShAmtImm); |
4579 Src0Var = T; | 4571 Src0Var = T; |
4580 } | 4572 } |
4581 | 4573 |
4582 for (SizeT I = 0; I < NumCases; ++I) { | 4574 for (SizeT I = 0; I < NumCases; ++I) { |
4583 Operand *Value = Ctx->getConstantInt32(Inst->getValue(I) << ShiftAmt); | 4575 Operand *Value = Ctx->getConstantInt32(Inst->getValue(I) << ShiftAmt); |
4584 Value = legalize(Value, Legal_Reg | Legal_Flex); | 4576 Value = legalize(Value, Legal_Reg | Legal_Flex); |
4585 _cmp(Src0Var, Value); | 4577 _cmp(Src0Var, Value); |
4586 _br(Inst->getLabel(I), CondARM32::EQ); | 4578 _br(Inst->getLabel(I), CondARM32::EQ); |
4587 } | 4579 } |
4588 _br(Inst->getLabelDefault()); | 4580 _br(Inst->getLabelDefault()); |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5420 // Technically R9 is used for TLS with Sandboxing, and we reserve it. | 5412 // Technically R9 is used for TLS with Sandboxing, and we reserve it. |
5421 // However, for compatibility with current NaCl LLVM, don't claim that. | 5413 // However, for compatibility with current NaCl LLVM, don't claim that. |
5422 Str << ".eabi_attribute 14, 3 @ Tag_ABI_PCS_R9_use: Not used\n"; | 5414 Str << ".eabi_attribute 14, 3 @ Tag_ABI_PCS_R9_use: Not used\n"; |
5423 } | 5415 } |
5424 | 5416 |
5425 llvm::SmallBitVector TargetARM32::TypeToRegisterSet[IceType_NUM]; | 5417 llvm::SmallBitVector TargetARM32::TypeToRegisterSet[IceType_NUM]; |
5426 llvm::SmallBitVector TargetARM32::RegisterAliases[RegARM32::Reg_NUM]; | 5418 llvm::SmallBitVector TargetARM32::RegisterAliases[RegARM32::Reg_NUM]; |
5427 llvm::SmallBitVector TargetARM32::ScratchRegs; | 5419 llvm::SmallBitVector TargetARM32::ScratchRegs; |
5428 | 5420 |
5429 } // end of namespace Ice | 5421 } // end of namespace Ice |
OLD | NEW |