| OLD | NEW |
| 1 //===- subzero/src/IceAssemblerARM32.cpp - Assembler for ARM32 --*- C++ -*-===// | 1 //===- subzero/src/IceAssemblerARM32.cpp - Assembler for ARM32 --*- C++ -*-===// |
| 2 // | 2 // |
| 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 4 // for details. All rights reserved. Use of this source code is governed by a | 4 // for details. All rights reserved. Use of this source code is governed by a |
| 5 // BSD-style license that can be found in the LICENSE file. | 5 // BSD-style license that can be found in the LICENSE file. |
| 6 // | 6 // |
| 7 // Modified by the Subzero authors. | 7 // Modified by the Subzero authors. |
| 8 // | 8 // |
| 9 //===----------------------------------------------------------------------===// | 9 //===----------------------------------------------------------------------===// |
| 10 // | 10 // |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 OpEncodingMemEx | 196 OpEncodingMemEx |
| 197 }; | 197 }; |
| 198 | 198 |
| 199 IValueT getEncodedGPRegNum(const Variable *Var) { | 199 IValueT getEncodedGPRegNum(const Variable *Var) { |
| 200 int32_t Reg = Var->getRegNum(); | 200 int32_t Reg = Var->getRegNum(); |
| 201 return llvm::isa<Variable64On32>(Var) ? RegARM32::getI64PairFirstGPRNum(Reg) | 201 return llvm::isa<Variable64On32>(Var) ? RegARM32::getI64PairFirstGPRNum(Reg) |
| 202 : RegARM32::getEncodedGPR(Reg); | 202 : RegARM32::getEncodedGPR(Reg); |
| 203 } | 203 } |
| 204 | 204 |
| 205 IValueT getEncodedSRegNum(const Variable *Var) { | 205 IValueT getEncodedSRegNum(const Variable *Var) { |
| 206 assert(Var->hasReg()); | |
| 207 assert(RegARM32::isEncodedSReg(Var->getRegNum())); | 206 assert(RegARM32::isEncodedSReg(Var->getRegNum())); |
| 208 return RegARM32::getEncodedSReg(Var->getRegNum()); | 207 return RegARM32::getEncodedSReg(Var->getRegNum()); |
| 209 } | 208 } |
| 210 | 209 |
| 211 // The way an operand is encoded into a sequence of bits in functions | 210 // The way an operand is encoded into a sequence of bits in functions |
| 212 // encodeOperand and encodeAddress below. | 211 // encodeOperand and encodeAddress below. |
| 213 enum EncodedOperand { | 212 enum EncodedOperand { |
| 214 // Unable to encode, value left undefined. | 213 // Unable to encode, value left undefined. |
| 215 CantEncode = 0, | 214 CantEncode = 0, |
| 216 // Value is register found. | 215 // Value is register found. |
| (...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 // orr{s}<c> <Rd>, <Rn>, #<RotatedImm8> | 1680 // orr{s}<c> <Rd>, <Rn>, #<RotatedImm8> |
| 1682 // | 1681 // |
| 1683 // cccc0001100snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, | 1682 // cccc0001100snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, |
| 1684 // s=SetFlags and iiiiiiiiiiii=Src1Value defining RotatedImm8. | 1683 // s=SetFlags and iiiiiiiiiiii=Src1Value defining RotatedImm8. |
| 1685 constexpr const char *OrrName = "orr"; | 1684 constexpr const char *OrrName = "orr"; |
| 1686 constexpr IValueT OrrOpcode = B3 | B2; // i.e. 1100 | 1685 constexpr IValueT OrrOpcode = B3 | B2; // i.e. 1100 |
| 1687 emitType01(Cond, OrrOpcode, OpRd, OpRn, OpSrc1, SetFlags, RdIsPcAndSetFlags, | 1686 emitType01(Cond, OrrOpcode, OpRd, OpRn, OpSrc1, SetFlags, RdIsPcAndSetFlags, |
| 1688 OrrName); | 1687 OrrName); |
| 1689 } | 1688 } |
| 1690 | 1689 |
| 1691 void AssemblerARM32::pop(const Operand *OpRt, CondARM32::Cond Cond) { | 1690 void AssemblerARM32::pop(const Variable *OpRt, CondARM32::Cond Cond) { |
| 1692 // POP - ARM section A8.8.132, encoding A2: | 1691 // POP - ARM section A8.8.132, encoding A2: |
| 1693 // pop<c> {Rt} | 1692 // pop<c> {Rt} |
| 1694 // | 1693 // |
| 1695 // cccc010010011101dddd000000000100 where dddd=Rt and cccc=Cond. | 1694 // cccc010010011101dddd000000000100 where dddd=Rt and cccc=Cond. |
| 1696 constexpr const char *Pop = "pop"; | 1695 constexpr const char *Pop = "pop"; |
| 1697 IValueT Rt = encodeRegister(OpRt, "Rt", Pop); | 1696 const IValueT Rt = encodeRegister(OpRt, "Rt", Pop); |
| 1698 verifyRegsNotEq(Rt, "Rt", RegARM32::Encoded_Reg_sp, "sp", Pop); | 1697 verifyRegsNotEq(Rt, "Rt", RegARM32::Encoded_Reg_sp, "sp", Pop); |
| 1699 // Same as load instruction. | 1698 // Same as load instruction. |
| 1700 constexpr bool IsLoad = true; | 1699 constexpr bool IsLoad = true; |
| 1701 constexpr bool IsByte = false; | 1700 constexpr bool IsByte = false; |
| 1702 IValueT Address = encodeImmRegOffset(RegARM32::Encoded_Reg_sp, kWordSize, | 1701 IValueT Address = encodeImmRegOffset(RegARM32::Encoded_Reg_sp, kWordSize, |
| 1703 OperandARM32Mem::PostIndex); | 1702 OperandARM32Mem::PostIndex); |
| 1704 emitMemOp(Cond, kInstTypeMemImmediate, IsLoad, IsByte, Rt, Address, Pop); | 1703 emitMemOp(Cond, kInstTypeMemImmediate, IsLoad, IsByte, Rt, Address, Pop); |
| 1705 } | 1704 } |
| 1706 | 1705 |
| 1707 void AssemblerARM32::popList(const IValueT Registers, CondARM32::Cond Cond) { | 1706 void AssemblerARM32::popList(const IValueT Registers, CondARM32::Cond Cond) { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2002 void AssemblerARM32::uxt(const Operand *OpRd, const Operand *OpSrc0, | 2001 void AssemblerARM32::uxt(const Operand *OpRd, const Operand *OpSrc0, |
| 2003 CondARM32::Cond Cond) { | 2002 CondARM32::Cond Cond) { |
| 2004 constexpr const char *UxtName = "uxt"; | 2003 constexpr const char *UxtName = "uxt"; |
| 2005 constexpr IValueT UxtOpcode = B26 | B25 | B23 | B22 | B21; | 2004 constexpr IValueT UxtOpcode = B26 | B25 | B23 | B22 | B21; |
| 2006 emitSignExtend(Cond, UxtOpcode, OpRd, OpSrc0, UxtName); | 2005 emitSignExtend(Cond, UxtOpcode, OpRd, OpSrc0, UxtName); |
| 2007 } | 2006 } |
| 2008 | 2007 |
| 2009 void AssemblerARM32::emitVStackOp(CondARM32::Cond Cond, IValueT Opcode, | 2008 void AssemblerARM32::emitVStackOp(CondARM32::Cond Cond, IValueT Opcode, |
| 2010 const Variable *OpBaseReg, | 2009 const Variable *OpBaseReg, |
| 2011 SizeT NumConsecRegs, const char *InstName) { | 2010 SizeT NumConsecRegs, const char *InstName) { |
| 2012 | |
| 2013 const IValueT BaseReg = getEncodedSRegNum(OpBaseReg); | 2011 const IValueT BaseReg = getEncodedSRegNum(OpBaseReg); |
| 2014 const IValueT DLastBit = mask(BaseReg, 0, 1); // Last bit of base register. | 2012 const IValueT DLastBit = mask(BaseReg, 0, 1); // Last bit of base register. |
| 2015 const IValueT Rd = mask(BaseReg, 1, 4); // Top 4 bits of base register. | 2013 const IValueT Rd = mask(BaseReg, 1, 4); // Top 4 bits of base register. |
| 2016 assert(0 < NumConsecRegs); | 2014 assert(0 < NumConsecRegs); |
| 2017 (void)VpushVpopMaxConsecRegs; | 2015 (void)VpushVpopMaxConsecRegs; |
| 2018 assert(NumConsecRegs <= VpushVpopMaxConsecRegs); | 2016 assert(NumConsecRegs <= VpushVpopMaxConsecRegs); |
| 2019 assert((BaseReg + NumConsecRegs) <= RegARM32::getNumSRegs()); | 2017 assert((BaseReg + NumConsecRegs) <= RegARM32::getNumSRegs()); |
| 2020 verifyCondDefined(Cond, InstName); | 2018 verifyCondDefined(Cond, InstName); |
| 2021 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | 2019 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
| 2022 const IValueT Encoding = Opcode | (Cond << kConditionShift) | DLastBit | | 2020 const IValueT Encoding = Opcode | (Cond << kConditionShift) | DLastBit | |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2051 // cccc11010D101101dddd1010iiiiiiii where cccc=Cond, ddddD=BaseReg, and | 2049 // cccc11010D101101dddd1010iiiiiiii where cccc=Cond, ddddD=BaseReg, and |
| 2052 // iiiiiiii=NumConsecRegs. | 2050 // iiiiiiii=NumConsecRegs. |
| 2053 constexpr const char *VpushName = "vpush"; | 2051 constexpr const char *VpushName = "vpush"; |
| 2054 constexpr IValueT VpushOpcode = | 2052 constexpr IValueT VpushOpcode = |
| 2055 B27 | B26 | B24 | B21 | B19 | B18 | B16 | B11 | B9; | 2053 B27 | B26 | B24 | B21 | B19 | B18 | B16 | B11 | B9; |
| 2056 emitVStackOp(Cond, VpushOpcode, OpBaseReg, NumConsecRegs, VpushName); | 2054 emitVStackOp(Cond, VpushOpcode, OpBaseReg, NumConsecRegs, VpushName); |
| 2057 } | 2055 } |
| 2058 | 2056 |
| 2059 } // end of namespace ARM32 | 2057 } // end of namespace ARM32 |
| 2060 } // end of namespace Ice | 2058 } // end of namespace Ice |
| OLD | NEW |