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 // This file implements the TargetLoweringARM32 class, which consists almost | 10 // This file implements the TargetLoweringARM32 class, which consists almost |
(...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1621 case Intrinsics::Trap: | 1621 case Intrinsics::Trap: |
1622 UnimplementedError(Func->getContext()->getFlags()); | 1622 UnimplementedError(Func->getContext()->getFlags()); |
1623 return; | 1623 return; |
1624 case Intrinsics::UnknownIntrinsic: | 1624 case Intrinsics::UnknownIntrinsic: |
1625 Func->setError("Should not be lowering UnknownIntrinsic"); | 1625 Func->setError("Should not be lowering UnknownIntrinsic"); |
1626 return; | 1626 return; |
1627 } | 1627 } |
1628 return; | 1628 return; |
1629 } | 1629 } |
1630 | 1630 |
1631 void TargetARM32::lowerLoad(const InstLoad *Inst) { | 1631 void TargetARM32::lowerLoad(const InstLoad *Load) { |
1632 (void)Inst; | 1632 // A Load instruction can be treated the same as an Assign |
1633 UnimplementedError(Func->getContext()->getFlags()); | 1633 // instruction, after the source operand is transformed into an |
| 1634 // OperandARM32Mem operand. |
| 1635 Type Ty = Load->getDest()->getType(); |
| 1636 Operand *Src0 = formMemoryOperand(Load->getSourceAddress(), Ty); |
| 1637 Variable *DestLoad = Load->getDest(); |
| 1638 |
| 1639 // TODO(jvoung): handled folding opportunities. Sign and zero extension |
| 1640 // can be folded into a load. |
| 1641 InstAssign *Assign = InstAssign::create(Func, DestLoad, Src0); |
| 1642 lowerAssign(Assign); |
1634 } | 1643 } |
1635 | 1644 |
1636 void TargetARM32::doAddressOptLoad() { | 1645 void TargetARM32::doAddressOptLoad() { |
1637 UnimplementedError(Func->getContext()->getFlags()); | 1646 UnimplementedError(Func->getContext()->getFlags()); |
1638 } | 1647 } |
1639 | 1648 |
1640 void TargetARM32::randomlyInsertNop(float Probability) { | 1649 void TargetARM32::randomlyInsertNop(float Probability) { |
1641 RandomNumberGeneratorWrapper RNG(Ctx->getRNG()); | 1650 RandomNumberGeneratorWrapper RNG(Ctx->getRNG()); |
1642 if (RNG.getTrueWithProbability(Probability)) { | 1651 if (RNG.getTrueWithProbability(Probability)) { |
1643 UnimplementedError(Func->getContext()->getFlags()); | 1652 UnimplementedError(Func->getContext()->getFlags()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1680 Variable *SP = Func->getTarget()->getPhysicalRegister(RegARM32::Reg_sp); | 1689 Variable *SP = Func->getTarget()->getPhysicalRegister(RegARM32::Reg_sp); |
1681 Context.insert(InstFakeUse::create(Func, SP)); | 1690 Context.insert(InstFakeUse::create(Func, SP)); |
1682 } | 1691 } |
1683 | 1692 |
1684 void TargetARM32::lowerSelect(const InstSelect *Inst) { | 1693 void TargetARM32::lowerSelect(const InstSelect *Inst) { |
1685 (void)Inst; | 1694 (void)Inst; |
1686 UnimplementedError(Func->getContext()->getFlags()); | 1695 UnimplementedError(Func->getContext()->getFlags()); |
1687 } | 1696 } |
1688 | 1697 |
1689 void TargetARM32::lowerStore(const InstStore *Inst) { | 1698 void TargetARM32::lowerStore(const InstStore *Inst) { |
1690 (void)Inst; | 1699 Operand *Value = Inst->getData(); |
1691 UnimplementedError(Func->getContext()->getFlags()); | 1700 Operand *Addr = Inst->getAddr(); |
| 1701 OperandARM32Mem *NewAddr = formMemoryOperand(Addr, Value->getType()); |
| 1702 Type Ty = NewAddr->getType(); |
| 1703 |
| 1704 if (Ty == IceType_i64) { |
| 1705 Variable *ValueHi = legalizeToVar(hiOperand(Value)); |
| 1706 Variable *ValueLo = legalizeToVar(loOperand(Value)); |
| 1707 _str(ValueHi, llvm::cast<OperandARM32Mem>(hiOperand(NewAddr))); |
| 1708 _str(ValueLo, llvm::cast<OperandARM32Mem>(loOperand(NewAddr))); |
| 1709 } else if (isVectorType(Ty)) { |
| 1710 UnimplementedError(Func->getContext()->getFlags()); |
| 1711 } else { |
| 1712 Variable *ValueR = legalizeToVar(Value); |
| 1713 _str(ValueR, NewAddr); |
| 1714 } |
1692 } | 1715 } |
1693 | 1716 |
1694 void TargetARM32::doAddressOptStore() { | 1717 void TargetARM32::doAddressOptStore() { |
1695 UnimplementedError(Func->getContext()->getFlags()); | 1718 UnimplementedError(Func->getContext()->getFlags()); |
1696 } | 1719 } |
1697 | 1720 |
1698 void TargetARM32::lowerSwitch(const InstSwitch *Inst) { | 1721 void TargetARM32::lowerSwitch(const InstSwitch *Inst) { |
1699 (void)Inst; | 1722 (void)Inst; |
1700 UnimplementedError(Func->getContext()->getFlags()); | 1723 UnimplementedError(Func->getContext()->getFlags()); |
1701 } | 1724 } |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1884 llvm_unreachable("Unhandled operand kind in legalize()"); | 1907 llvm_unreachable("Unhandled operand kind in legalize()"); |
1885 | 1908 |
1886 return From; | 1909 return From; |
1887 } | 1910 } |
1888 | 1911 |
1889 // Provide a trivial wrapper to legalize() for this common usage. | 1912 // Provide a trivial wrapper to legalize() for this common usage. |
1890 Variable *TargetARM32::legalizeToVar(Operand *From, int32_t RegNum) { | 1913 Variable *TargetARM32::legalizeToVar(Operand *From, int32_t RegNum) { |
1891 return llvm::cast<Variable>(legalize(From, Legal_Reg, RegNum)); | 1914 return llvm::cast<Variable>(legalize(From, Legal_Reg, RegNum)); |
1892 } | 1915 } |
1893 | 1916 |
| 1917 OperandARM32Mem *TargetARM32::formMemoryOperand(Operand *Operand, Type Ty) { |
| 1918 OperandARM32Mem *Mem = llvm::dyn_cast<OperandARM32Mem>(Operand); |
| 1919 // It may be the case that address mode optimization already creates |
| 1920 // an OperandARM32Mem, so in that case it wouldn't need another level |
| 1921 // of transformation. |
| 1922 if (Mem) { |
| 1923 return llvm::cast<OperandARM32Mem>(legalize(Mem)); |
| 1924 } |
| 1925 // If we didn't do address mode optimization, then we only |
| 1926 // have a base/offset to work with. ARM always requires a base |
| 1927 // register, so just use that to hold the operand. |
| 1928 Variable *Base = legalizeToVar(Operand); |
| 1929 return OperandARM32Mem::create( |
| 1930 Func, Ty, Base, |
| 1931 llvm::cast<ConstantInteger32>(Ctx->getConstantZero(IceType_i32))); |
| 1932 } |
| 1933 |
1894 Variable *TargetARM32::makeReg(Type Type, int32_t RegNum) { | 1934 Variable *TargetARM32::makeReg(Type Type, int32_t RegNum) { |
1895 // There aren't any 64-bit integer registers for ARM32. | 1935 // There aren't any 64-bit integer registers for ARM32. |
1896 assert(Type != IceType_i64); | 1936 assert(Type != IceType_i64); |
1897 Variable *Reg = Func->makeVariable(Type); | 1937 Variable *Reg = Func->makeVariable(Type); |
1898 if (RegNum == Variable::NoRegister) | 1938 if (RegNum == Variable::NoRegister) |
1899 Reg->setWeightInfinite(); | 1939 Reg->setWeightInfinite(); |
1900 else | 1940 else |
1901 Reg->setRegNum(RegNum); | 1941 Reg->setRegNum(RegNum); |
1902 return Reg; | 1942 return Reg; |
1903 } | 1943 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1986 } | 2026 } |
1987 } | 2027 } |
1988 | 2028 |
1989 void TargetDataARM32::lowerConstants() const { | 2029 void TargetDataARM32::lowerConstants() const { |
1990 if (Ctx->getFlags().getDisableTranslation()) | 2030 if (Ctx->getFlags().getDisableTranslation()) |
1991 return; | 2031 return; |
1992 UnimplementedError(Ctx->getFlags()); | 2032 UnimplementedError(Ctx->getFlags()); |
1993 } | 2033 } |
1994 | 2034 |
1995 } // end of namespace Ice | 2035 } // end of namespace Ice |
OLD | NEW |