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 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 // ldrb<c> <Rt>, [<Rn>], +-<Rm>{, <shift>} | 1115 // ldrb<c> <Rt>, [<Rn>], +-<Rm>{, <shift>} |
1116 // | 1116 // |
1117 // cccc011pu0w1nnnnttttiiiiiss0mmmm where cccc=Cond, tttt=Rt, U=1 if +, pu0b | 1117 // cccc011pu0w1nnnnttttiiiiiss0mmmm where cccc=Cond, tttt=Rt, U=1 if +, pu0b |
1118 // is a BlockAddr, and pu0w0nnnn0000iiiiiss0mmmm=Address. | 1118 // is a BlockAddr, and pu0w0nnnn0000iiiiiss0mmmm=Address. |
1119 constexpr bool IsByte = false; | 1119 constexpr bool IsByte = false; |
1120 return emitMemOp(Cond, IsLoad, IsByte, Rt, OpAddress, TInfo, LdrName); | 1120 return emitMemOp(Cond, IsLoad, IsByte, Rt, OpAddress, TInfo, LdrName); |
1121 } | 1121 } |
1122 } | 1122 } |
1123 } | 1123 } |
1124 | 1124 |
| 1125 void AssemblerARM32::emitShift(const CondARM32::Cond Cond, |
| 1126 const OperandARM32::ShiftKind Shift, |
| 1127 const Operand *OpRd, const Operand *OpRm, |
| 1128 const Operand *OpSrc1, const bool SetFlags, |
| 1129 const char *InstName) { |
| 1130 constexpr IValueT ShiftOpcode = B3 | B2 | B0; // 1101 |
| 1131 IValueT Rd = encodeRegister(OpRd, "Rd", InstName); |
| 1132 IValueT Rm = encodeRegister(OpRm, "Rm", InstName); |
| 1133 IValueT Value; |
| 1134 switch (encodeOperand(OpSrc1, Value)) { |
| 1135 default: |
| 1136 llvm::report_fatal_error(std::string(InstName) + |
| 1137 ": Last operand not understood"); |
| 1138 case EncodedAsShiftImm5: { |
| 1139 // XXX (immediate) |
| 1140 // xxx{s}<c> <Rd>, <Rm>, #imm5 |
| 1141 // |
| 1142 // cccc0001101s0000ddddiiiii000mmmm where cccc=Cond, s=SetFlags, dddd=Rd, |
| 1143 // iiiii=imm5, and mmmm=Rm. |
| 1144 constexpr IValueT Rn = 0; // Rn field is not used. |
| 1145 Value = Value | (Rm << kRmShift) | (Shift << kShiftShift); |
| 1146 emitType01(Cond, kInstTypeDataRegShift, ShiftOpcode, SetFlags, Rn, Rd, |
| 1147 Value, RdIsPcAndSetFlags, InstName); |
| 1148 return; |
| 1149 } |
| 1150 case EncodedAsRegister: { |
| 1151 // XXX (register) |
| 1152 // xxx{S}<c> <Rd>, <Rm>, <Rs> |
| 1153 // |
| 1154 // cccc0001101s0000ddddssss0001mmmm where cccc=Cond, s=SetFlags, dddd=Rd, |
| 1155 // mmmm=Rm, and ssss=Rs. |
| 1156 constexpr IValueT Rn = 0; // Rn field is not used. |
| 1157 IValueT Rs = encodeRegister(OpSrc1, "Rs", InstName); |
| 1158 verifyRegNotPc(Rd, "Rd", InstName); |
| 1159 verifyRegNotPc(Rm, "Rm", InstName); |
| 1160 verifyRegNotPc(Rs, "Rs", InstName); |
| 1161 emitType01(Cond, kInstTypeDataRegShift, ShiftOpcode, SetFlags, Rn, Rd, |
| 1162 encodeShiftRotateReg(Rm, Shift, Rs), NoChecks, InstName); |
| 1163 return; |
| 1164 } |
| 1165 } |
| 1166 } |
| 1167 |
1125 void AssemblerARM32::lsl(const Operand *OpRd, const Operand *OpRm, | 1168 void AssemblerARM32::lsl(const Operand *OpRd, const Operand *OpRm, |
1126 const Operand *OpSrc1, bool SetFlags, | 1169 const Operand *OpSrc1, bool SetFlags, |
1127 CondARM32::Cond Cond) { | 1170 CondARM32::Cond Cond) { |
1128 constexpr const char *LslName = "lsl"; | 1171 constexpr const char *LslName = "lsl"; |
1129 IValueT Rd = encodeRegister(OpRd, "Rd", LslName); | 1172 emitShift(Cond, OperandARM32::LSL, OpRd, OpRm, OpSrc1, SetFlags, LslName); |
1130 IValueT Rm = encodeRegister(OpRm, "Rm", LslName); | 1173 } |
1131 IValueT Value; | 1174 |
1132 switch (encodeOperand(OpSrc1, Value)) { | 1175 void AssemblerARM32::lsr(const Operand *OpRd, const Operand *OpRm, |
1133 default: | 1176 const Operand *OpSrc1, bool SetFlags, |
1134 llvm::report_fatal_error(std::string(LslName) + | 1177 CondARM32::Cond Cond) { |
1135 ": Last operand not understood"); | 1178 constexpr const char *LsrName = "lsr"; |
1136 case EncodedAsShiftImm5: { | 1179 emitShift(Cond, OperandARM32::LSR, OpRd, OpRm, OpSrc1, SetFlags, LsrName); |
1137 // LSL (immediate) - ARM section A8.8.94, encoding A1: | |
1138 // lsl{s}<c> <Rd>, <Rm>, #imm5 | |
1139 // | |
1140 // cccc0001101s0000ddddiiiii000mmmm where cccc=Cond, s=SetFlags, dddd=Rd, | |
1141 // iiiii=imm5, and mmmm=Rm. | |
1142 constexpr IValueT LslOpcode = B3 | B2 | B0; // 1101 | |
1143 constexpr IValueT Rn = 0; // Rn field is not used. | |
1144 Value = Value | (Rm << kRmShift); | |
1145 emitType01(Cond, kInstTypeDataRegShift, LslOpcode, SetFlags, Rn, Rd, Value, | |
1146 RdIsPcAndSetFlags, LslName); | |
1147 return; | |
1148 } | |
1149 case EncodedAsRegister: { | |
1150 // LSL (register) - ARM section A8.8.95, encoding A1: | |
1151 // lsl{S}<c> <Rd>, <Rm>, <Rs> | |
1152 // | |
1153 // cccc0001101s0000ddddssss0001mmmm where cccc=Cond, s=SetFlags, dddd=Rd, | |
1154 // mmmm=Rm, and ssss=Rs. | |
1155 constexpr IValueT LslOpcode = B3 | B2 | B0; // 1101 | |
1156 constexpr IValueT Rn = 0; // Rn field is not used. | |
1157 IValueT Rs = encodeRegister(OpSrc1, "Rs", LslName); | |
1158 verifyRegNotPc(Rd, "Rd", LslName); | |
1159 verifyRegNotPc(Rm, "Rm", LslName); | |
1160 verifyRegNotPc(Rs, "Rs", LslName); | |
1161 emitType01(Cond, kInstTypeDataRegShift, LslOpcode, SetFlags, Rn, Rd, | |
1162 encodeShiftRotateReg(Rm, OperandARM32::kNoShift, Rs), NoChecks, | |
1163 LslName); | |
1164 return; | |
1165 } | |
1166 } | |
1167 } | 1180 } |
1168 | 1181 |
1169 void AssemblerARM32::mov(const Operand *OpRd, const Operand *OpSrc, | 1182 void AssemblerARM32::mov(const Operand *OpRd, const Operand *OpSrc, |
1170 CondARM32::Cond Cond) { | 1183 CondARM32::Cond Cond) { |
1171 // MOV (register) - ARM section A8.8.104, encoding A1: | 1184 // MOV (register) - ARM section A8.8.104, encoding A1: |
1172 // mov{S}<c> <Rd>, <Rn> | 1185 // mov{S}<c> <Rd>, <Rn> |
1173 // | 1186 // |
1174 // cccc0001101s0000dddd00000000mmmm where cccc=Cond, s=SetFlags, dddd=Rd, | 1187 // cccc0001101s0000dddd00000000mmmm where cccc=Cond, s=SetFlags, dddd=Rd, |
1175 // and nnnn=Rn. | 1188 // and nnnn=Rn. |
1176 // | 1189 // |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1610 // rr defined (RotationValue) rotate. | 1623 // rr defined (RotationValue) rotate. |
1611 constexpr IValueT UxtOpcode = B26 | B25 | B23 | B22 | B21 | B20; | 1624 constexpr IValueT UxtOpcode = B26 | B25 | B23 | B22 | B21 | B20; |
1612 emitUxt(Cond, UxtOpcode, Rd, Rn, Rm, Rotation, UxtName); | 1625 emitUxt(Cond, UxtOpcode, Rd, Rn, Rm, Rotation, UxtName); |
1613 return; | 1626 return; |
1614 } | 1627 } |
1615 } | 1628 } |
1616 } | 1629 } |
1617 | 1630 |
1618 } // end of namespace ARM32 | 1631 } // end of namespace ARM32 |
1619 } // end of namespace Ice | 1632 } // end of namespace Ice |
OLD | NEW |