| 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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 // assembler. | 747 // assembler. |
| 748 IValueT Rd; | 748 IValueT Rd; |
| 749 if (decodeOperand(OpRd, Rd) != DecodedAsRegister) | 749 if (decodeOperand(OpRd, Rd) != DecodedAsRegister) |
| 750 return setNeedsTextFixup(); | 750 return setNeedsTextFixup(); |
| 751 constexpr bool SetFlags = false; | 751 constexpr bool SetFlags = false; |
| 752 constexpr IValueT Rn = 0; | 752 constexpr IValueT Rn = 0; |
| 753 constexpr IValueT Mov = B3 | B2 | B0; // 1101. | 753 constexpr IValueT Mov = B3 | B2 | B0; // 1101. |
| 754 emitType01(Mov, Rd, Rn, OpSrc, SetFlags, Cond); | 754 emitType01(Mov, Rd, Rn, OpSrc, SetFlags, Cond); |
| 755 } | 755 } |
| 756 | 756 |
| 757 void AssemblerARM32::emitMovw(IValueT Opcode, IValueT Rd, IValueT Imm16, |
| 758 bool SetFlags, CondARM32::Cond Cond) { |
| 759 if (!isConditionDefined(Cond) || !Utils::IsAbsoluteUint(16, Imm16)) |
| 760 return setNeedsTextFixup(); |
| 761 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
| 762 const IValueT Encoding = encodeCondition(Cond) << kConditionShift | Opcode | |
| 763 (encodeBool(SetFlags) << kSShift) | |
| 764 ((Imm16 >> 12) << 16) | Rd << kRdShift | |
| 765 (Imm16 & 0xfff); |
| 766 emitInst(Encoding); |
| 767 } |
| 768 |
| 757 void AssemblerARM32::movw(const Operand *OpRd, const Operand *OpSrc, | 769 void AssemblerARM32::movw(const Operand *OpRd, const Operand *OpSrc, |
| 758 CondARM32::Cond Cond) { | 770 CondARM32::Cond Cond) { |
| 759 IValueT Rd; | 771 IValueT Rd; |
| 760 if (decodeOperand(OpRd, Rd) != DecodedAsRegister) | 772 if (decodeOperand(OpRd, Rd) != DecodedAsRegister) |
| 761 return setNeedsTextFixup(); | 773 return setNeedsTextFixup(); |
| 762 auto *Src = llvm::dyn_cast<ConstantRelocatable>(OpSrc); | 774 if (const auto *Src = llvm::dyn_cast<ConstantRelocatable>(OpSrc)) { |
| 763 if (Src == nullptr) | 775 // MOVW (immediate) - ARM section A8.8.102, encoding A2: |
| 776 // movw<c> <Rd>, #<imm16> |
| 777 // |
| 778 // cccc00110000iiiiddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, and |
| 779 // iiiiiiiiiiiiiiii=imm16. |
| 780 if (!isConditionDefined(Cond)) |
| 781 // Conditions of rule violated. |
| 782 return setNeedsTextFixup(); |
| 783 // Use 0 for the lower 16 bits of the relocatable, and add a fixup to |
| 784 // install the correct bits. |
| 785 constexpr bool IsMovW = true; |
| 786 emitFixup(createMoveFixup(IsMovW, Src)); |
| 787 constexpr IValueT Imm16 = 0; |
| 788 constexpr bool SetFlags = false; |
| 789 emitMovw(B25 | B24, Rd, Imm16, SetFlags, Cond); |
| 790 return; |
| 791 } |
| 792 IValueT ConstVal; |
| 793 if (decodeOperand(OpSrc, ConstVal) != DecodedAsConstI32) |
| 764 return setNeedsTextFixup(); | 794 return setNeedsTextFixup(); |
| 765 // MOVW (immediate) - ARM section A8.8.102, encoding A2: | 795 // TODO(kschimpf): Determine if we want to handle rotated immediate 8 values |
| 766 // movw<c> <Rd>, #<imm16> | 796 // to handle cases where the constant is greater than 16 bits (encoding A1 |
| 797 // below). For now, handle using encoding A2. |
| 798 constexpr bool SetFlags = 0; |
| 799 emitMovw(B25 | B24, Rd, ConstVal, SetFlags, Cond); |
| 800 return; |
| 801 |
| 802 // MOVW (immediate) - ARM section A8.8.102, encoding A1: |
| 803 // movw<c> <Rd>, #<RotatedImm8> |
| 767 // | 804 // |
| 768 // cccc00110000iiiiddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, and | 805 // cccc0011101s0000ddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, s=SetFlags=0, |
| 769 // iiiiiiiiiiiiiiii=imm16. | 806 // and iiiiiiiiiiii is a shift-rotated value defining RotatedImm8. |
| 770 if (!isConditionDefined(Cond)) | |
| 771 // Conditions of rule violated. | |
| 772 return setNeedsTextFixup(); | |
| 773 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | |
| 774 // Use 0 for the lower 16 bits of the relocatable, and add a fixup to | |
| 775 // install the correct bits. | |
| 776 constexpr bool IsMovW = true; | |
| 777 emitFixup(createMoveFixup(IsMovW, Src)); | |
| 778 constexpr IValueT Imm16 = 0; | |
| 779 const IValueT Encoding = encodeCondition(Cond) << kConditionShift | B25 | | |
| 780 B24 | ((Imm16 >> 12) << 16) | Rd << kRdShift | | |
| 781 (Imm16 & 0xfff); | |
| 782 emitInst(Encoding); | |
| 783 } | 807 } |
| 784 | 808 |
| 785 void AssemblerARM32::movt(const Operand *OpRd, const Operand *OpSrc, | 809 void AssemblerARM32::movt(const Operand *OpRd, const Operand *OpSrc, |
| 786 CondARM32::Cond Cond) { | 810 CondARM32::Cond Cond) { |
| 787 IValueT Rd; | 811 IValueT Rd; |
| 788 if (decodeOperand(OpRd, Rd) != DecodedAsRegister) | 812 if (decodeOperand(OpRd, Rd) != DecodedAsRegister) |
| 789 return setNeedsTextFixup(); | 813 return setNeedsTextFixup(); |
| 790 auto *Src = llvm::dyn_cast<ConstantRelocatable>(OpSrc); | 814 auto *Src = llvm::dyn_cast<ConstantRelocatable>(OpSrc); |
| 791 if (Src == nullptr) | 815 if (Src == nullptr) |
| 792 return setNeedsTextFixup(); | 816 return setNeedsTextFixup(); |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 if (RdHi == RegARM32::Encoded_Reg_pc || RdLo == RegARM32::Encoded_Reg_pc || | 1121 if (RdHi == RegARM32::Encoded_Reg_pc || RdLo == RegARM32::Encoded_Reg_pc || |
| 1098 Rn == RegARM32::Encoded_Reg_pc || Rm == RegARM32::Encoded_Reg_pc || | 1122 Rn == RegARM32::Encoded_Reg_pc || Rm == RegARM32::Encoded_Reg_pc || |
| 1099 RdHi == RdLo) | 1123 RdHi == RdLo) |
| 1100 llvm::report_fatal_error("Umull instruction unpredictable on pc"); | 1124 llvm::report_fatal_error("Umull instruction unpredictable on pc"); |
| 1101 constexpr bool SetFlags = false; | 1125 constexpr bool SetFlags = false; |
| 1102 emitMulOp(Cond, B23, RdLo, RdHi, Rn, Rm, SetFlags); | 1126 emitMulOp(Cond, B23, RdLo, RdHi, Rn, Rm, SetFlags); |
| 1103 } | 1127 } |
| 1104 | 1128 |
| 1105 } // end of namespace ARM32 | 1129 } // end of namespace ARM32 |
| 1106 } // end of namespace Ice | 1130 } // end of namespace Ice |
| OLD | NEW |