Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 3 | #include "assembler_arm.h" |
| 4 | |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 5 | #include "logging.h" |
| 6 | #include "offsets.h" |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 7 | #include "thread.h" |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 8 | #include "utils.h" |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 9 | |
Carl Shapiro | 6b6b5f0 | 2011-06-21 15:05:09 -0700 | [diff] [blame] | 10 | namespace art { |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 11 | namespace arm { |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 12 | |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 13 | // Instruction encoding bits. |
| 14 | enum { |
| 15 | H = 1 << 5, // halfword (or byte) |
| 16 | L = 1 << 20, // load (or store) |
| 17 | S = 1 << 20, // set condition code (or leave unchanged) |
| 18 | W = 1 << 21, // writeback base register (or leave unchanged) |
| 19 | A = 1 << 21, // accumulate in multiply instruction (or not) |
| 20 | B = 1 << 22, // unsigned byte (or word) |
| 21 | N = 1 << 22, // long (or short) |
| 22 | U = 1 << 23, // positive (or negative) offset/index |
| 23 | P = 1 << 24, // offset/pre-indexed addressing (or post-indexed addressing) |
| 24 | I = 1 << 25, // immediate shifter operand (or not) |
| 25 | |
| 26 | B0 = 1, |
| 27 | B1 = 1 << 1, |
| 28 | B2 = 1 << 2, |
| 29 | B3 = 1 << 3, |
| 30 | B4 = 1 << 4, |
| 31 | B5 = 1 << 5, |
| 32 | B6 = 1 << 6, |
| 33 | B7 = 1 << 7, |
| 34 | B8 = 1 << 8, |
| 35 | B9 = 1 << 9, |
| 36 | B10 = 1 << 10, |
| 37 | B11 = 1 << 11, |
| 38 | B12 = 1 << 12, |
| 39 | B16 = 1 << 16, |
| 40 | B17 = 1 << 17, |
| 41 | B18 = 1 << 18, |
| 42 | B19 = 1 << 19, |
| 43 | B20 = 1 << 20, |
| 44 | B21 = 1 << 21, |
| 45 | B22 = 1 << 22, |
| 46 | B23 = 1 << 23, |
| 47 | B24 = 1 << 24, |
| 48 | B25 = 1 << 25, |
| 49 | B26 = 1 << 26, |
| 50 | B27 = 1 << 27, |
| 51 | |
| 52 | // Instruction bit masks. |
| 53 | RdMask = 15 << 12, // in str instruction |
| 54 | CondMask = 15 << 28, |
| 55 | CoprocessorMask = 15 << 8, |
| 56 | OpCodeMask = 15 << 21, // in data-processing instructions |
| 57 | Imm24Mask = (1 << 24) - 1, |
| 58 | Off12Mask = (1 << 12) - 1, |
| 59 | |
| 60 | // ldrex/strex register field encodings. |
| 61 | kLdExRnShift = 16, |
| 62 | kLdExRtShift = 12, |
| 63 | kStrExRnShift = 16, |
| 64 | kStrExRdShift = 12, |
| 65 | kStrExRtShift = 0, |
| 66 | }; |
| 67 | |
| 68 | |
Elliott Hughes | 1f359b0 | 2011-07-17 14:27:17 -0700 | [diff] [blame] | 69 | static const char* kRegisterNames[] = { |
| 70 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", |
| 71 | "fp", "ip", "sp", "lr", "pc" |
| 72 | }; |
| 73 | std::ostream& operator<<(std::ostream& os, const Register& rhs) { |
| 74 | if (rhs >= R0 && rhs <= PC) { |
| 75 | os << kRegisterNames[rhs]; |
| 76 | } else { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 77 | os << "Register[" << static_cast<int>(rhs) << "]"; |
Elliott Hughes | 1f359b0 | 2011-07-17 14:27:17 -0700 | [diff] [blame] | 78 | } |
| 79 | return os; |
| 80 | } |
| 81 | |
| 82 | |
| 83 | std::ostream& operator<<(std::ostream& os, const SRegister& rhs) { |
| 84 | if (rhs >= S0 && rhs < kNumberOfSRegisters) { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 85 | os << "s" << static_cast<int>(rhs); |
Elliott Hughes | 1f359b0 | 2011-07-17 14:27:17 -0700 | [diff] [blame] | 86 | } else { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 87 | os << "SRegister[" << static_cast<int>(rhs) << "]"; |
Elliott Hughes | 1f359b0 | 2011-07-17 14:27:17 -0700 | [diff] [blame] | 88 | } |
| 89 | return os; |
| 90 | } |
| 91 | |
| 92 | |
| 93 | std::ostream& operator<<(std::ostream& os, const DRegister& rhs) { |
| 94 | if (rhs >= D0 && rhs < kNumberOfDRegisters) { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 95 | os << "d" << static_cast<int>(rhs); |
Elliott Hughes | 1f359b0 | 2011-07-17 14:27:17 -0700 | [diff] [blame] | 96 | } else { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 97 | os << "DRegister[" << static_cast<int>(rhs) << "]"; |
Elliott Hughes | 1f359b0 | 2011-07-17 14:27:17 -0700 | [diff] [blame] | 98 | } |
| 99 | return os; |
| 100 | } |
| 101 | |
| 102 | |
| 103 | static const char* kConditionNames[] = { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 104 | "EQ", "NE", "CS", "CC", "MI", "PL", "VS", "VC", "HI", "LS", "GE", "LT", "GT", |
| 105 | "LE", "AL", |
Elliott Hughes | 1f359b0 | 2011-07-17 14:27:17 -0700 | [diff] [blame] | 106 | }; |
| 107 | std::ostream& operator<<(std::ostream& os, const Condition& rhs) { |
| 108 | if (rhs >= EQ && rhs <= AL) { |
| 109 | os << kConditionNames[rhs]; |
| 110 | } else { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 111 | os << "Condition[" << static_cast<int>(rhs) << "]"; |
Elliott Hughes | 1f359b0 | 2011-07-17 14:27:17 -0700 | [diff] [blame] | 112 | } |
| 113 | return os; |
| 114 | } |
| 115 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 116 | void ArmAssembler::Emit(int32_t value) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 117 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 118 | buffer_.Emit<int32_t>(value); |
| 119 | } |
| 120 | |
| 121 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 122 | void ArmAssembler::EmitType01(Condition cond, |
| 123 | int type, |
| 124 | Opcode opcode, |
| 125 | int set_cc, |
| 126 | Register rn, |
| 127 | Register rd, |
| 128 | ShifterOperand so) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 129 | CHECK_NE(rd, kNoRegister); |
| 130 | CHECK_NE(cond, kNoCondition); |
| 131 | int32_t encoding = static_cast<int32_t>(cond) << kConditionShift | |
| 132 | type << kTypeShift | |
| 133 | static_cast<int32_t>(opcode) << kOpcodeShift | |
| 134 | set_cc << kSShift | |
| 135 | static_cast<int32_t>(rn) << kRnShift | |
| 136 | static_cast<int32_t>(rd) << kRdShift | |
| 137 | so.encoding(); |
| 138 | Emit(encoding); |
| 139 | } |
| 140 | |
| 141 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 142 | void ArmAssembler::EmitType5(Condition cond, int offset, bool link) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 143 | CHECK_NE(cond, kNoCondition); |
| 144 | int32_t encoding = static_cast<int32_t>(cond) << kConditionShift | |
| 145 | 5 << kTypeShift | |
| 146 | (link ? 1 : 0) << kLinkShift; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 147 | Emit(ArmAssembler::EncodeBranchOffset(offset, encoding)); |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 151 | void ArmAssembler::EmitMemOp(Condition cond, |
| 152 | bool load, |
| 153 | bool byte, |
| 154 | Register rd, |
| 155 | Address ad) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 156 | CHECK_NE(rd, kNoRegister); |
| 157 | CHECK_NE(cond, kNoCondition); |
| 158 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 159 | B26 | |
| 160 | (load ? L : 0) | |
| 161 | (byte ? B : 0) | |
| 162 | (static_cast<int32_t>(rd) << kRdShift) | |
| 163 | ad.encoding(); |
| 164 | Emit(encoding); |
| 165 | } |
| 166 | |
| 167 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 168 | void ArmAssembler::EmitMemOpAddressMode3(Condition cond, |
| 169 | int32_t mode, |
| 170 | Register rd, |
| 171 | Address ad) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 172 | CHECK_NE(rd, kNoRegister); |
| 173 | CHECK_NE(cond, kNoCondition); |
| 174 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 175 | B22 | |
| 176 | mode | |
| 177 | (static_cast<int32_t>(rd) << kRdShift) | |
| 178 | ad.encoding3(); |
| 179 | Emit(encoding); |
| 180 | } |
| 181 | |
| 182 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 183 | void ArmAssembler::EmitMultiMemOp(Condition cond, |
| 184 | BlockAddressMode am, |
| 185 | bool load, |
| 186 | Register base, |
| 187 | RegList regs) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 188 | CHECK_NE(base, kNoRegister); |
| 189 | CHECK_NE(cond, kNoCondition); |
| 190 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 191 | B27 | |
| 192 | am | |
| 193 | (load ? L : 0) | |
| 194 | (static_cast<int32_t>(base) << kRnShift) | |
| 195 | regs; |
| 196 | Emit(encoding); |
| 197 | } |
| 198 | |
| 199 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 200 | void ArmAssembler::EmitShiftImmediate(Condition cond, |
| 201 | Shift opcode, |
| 202 | Register rd, |
| 203 | Register rm, |
| 204 | ShifterOperand so) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 205 | CHECK_NE(cond, kNoCondition); |
Elliott Hughes | 1f359b0 | 2011-07-17 14:27:17 -0700 | [diff] [blame] | 206 | CHECK_EQ(so.type(), 1U); |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 207 | int32_t encoding = static_cast<int32_t>(cond) << kConditionShift | |
| 208 | static_cast<int32_t>(MOV) << kOpcodeShift | |
| 209 | static_cast<int32_t>(rd) << kRdShift | |
| 210 | so.encoding() << kShiftImmShift | |
| 211 | static_cast<int32_t>(opcode) << kShiftShift | |
| 212 | static_cast<int32_t>(rm); |
| 213 | Emit(encoding); |
| 214 | } |
| 215 | |
| 216 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 217 | void ArmAssembler::EmitShiftRegister(Condition cond, |
| 218 | Shift opcode, |
| 219 | Register rd, |
| 220 | Register rm, |
| 221 | ShifterOperand so) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 222 | CHECK_NE(cond, kNoCondition); |
Elliott Hughes | 1f359b0 | 2011-07-17 14:27:17 -0700 | [diff] [blame] | 223 | CHECK_EQ(so.type(), 0U); |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 224 | int32_t encoding = static_cast<int32_t>(cond) << kConditionShift | |
| 225 | static_cast<int32_t>(MOV) << kOpcodeShift | |
| 226 | static_cast<int32_t>(rd) << kRdShift | |
| 227 | so.encoding() << kShiftRegisterShift | |
| 228 | static_cast<int32_t>(opcode) << kShiftShift | |
| 229 | B4 | |
| 230 | static_cast<int32_t>(rm); |
| 231 | Emit(encoding); |
| 232 | } |
| 233 | |
| 234 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 235 | void ArmAssembler::EmitBranch(Condition cond, Label* label, bool link) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 236 | if (label->IsBound()) { |
| 237 | EmitType5(cond, label->Position() - buffer_.Size(), link); |
| 238 | } else { |
| 239 | int position = buffer_.Size(); |
| 240 | // Use the offset field of the branch instruction for linking the sites. |
| 241 | EmitType5(cond, label->position_, link); |
| 242 | label->LinkTo(position); |
| 243 | } |
| 244 | } |
| 245 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 246 | void ArmAssembler::and_(Register rd, Register rn, ShifterOperand so, |
| 247 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 248 | EmitType01(cond, so.type(), AND, 0, rn, rd, so); |
| 249 | } |
| 250 | |
| 251 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 252 | void ArmAssembler::eor(Register rd, Register rn, ShifterOperand so, |
| 253 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 254 | EmitType01(cond, so.type(), EOR, 0, rn, rd, so); |
| 255 | } |
| 256 | |
| 257 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 258 | void ArmAssembler::sub(Register rd, Register rn, ShifterOperand so, |
| 259 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 260 | EmitType01(cond, so.type(), SUB, 0, rn, rd, so); |
| 261 | } |
| 262 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 263 | void ArmAssembler::rsb(Register rd, Register rn, ShifterOperand so, |
| 264 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 265 | EmitType01(cond, so.type(), RSB, 0, rn, rd, so); |
| 266 | } |
| 267 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 268 | void ArmAssembler::rsbs(Register rd, Register rn, ShifterOperand so, |
| 269 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 270 | EmitType01(cond, so.type(), RSB, 1, rn, rd, so); |
| 271 | } |
| 272 | |
| 273 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 274 | void ArmAssembler::add(Register rd, Register rn, ShifterOperand so, |
| 275 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 276 | EmitType01(cond, so.type(), ADD, 0, rn, rd, so); |
| 277 | } |
| 278 | |
| 279 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 280 | void ArmAssembler::adds(Register rd, Register rn, ShifterOperand so, |
| 281 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 282 | EmitType01(cond, so.type(), ADD, 1, rn, rd, so); |
| 283 | } |
| 284 | |
| 285 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 286 | void ArmAssembler::subs(Register rd, Register rn, ShifterOperand so, |
| 287 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 288 | EmitType01(cond, so.type(), SUB, 1, rn, rd, so); |
| 289 | } |
| 290 | |
| 291 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 292 | void ArmAssembler::adc(Register rd, Register rn, ShifterOperand so, |
| 293 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 294 | EmitType01(cond, so.type(), ADC, 0, rn, rd, so); |
| 295 | } |
| 296 | |
| 297 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 298 | void ArmAssembler::sbc(Register rd, Register rn, ShifterOperand so, |
| 299 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 300 | EmitType01(cond, so.type(), SBC, 0, rn, rd, so); |
| 301 | } |
| 302 | |
| 303 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 304 | void ArmAssembler::rsc(Register rd, Register rn, ShifterOperand so, |
| 305 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 306 | EmitType01(cond, so.type(), RSC, 0, rn, rd, so); |
| 307 | } |
| 308 | |
| 309 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 310 | void ArmAssembler::tst(Register rn, ShifterOperand so, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 311 | CHECK_NE(rn, PC); // Reserve tst pc instruction for exception handler marker. |
| 312 | EmitType01(cond, so.type(), TST, 1, rn, R0, so); |
| 313 | } |
| 314 | |
| 315 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 316 | void ArmAssembler::teq(Register rn, ShifterOperand so, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 317 | CHECK_NE(rn, PC); // Reserve teq pc instruction for exception handler marker. |
| 318 | EmitType01(cond, so.type(), TEQ, 1, rn, R0, so); |
| 319 | } |
| 320 | |
| 321 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 322 | void ArmAssembler::cmp(Register rn, ShifterOperand so, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 323 | EmitType01(cond, so.type(), CMP, 1, rn, R0, so); |
| 324 | } |
| 325 | |
| 326 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 327 | void ArmAssembler::cmn(Register rn, ShifterOperand so, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 328 | EmitType01(cond, so.type(), CMN, 1, rn, R0, so); |
| 329 | } |
| 330 | |
| 331 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 332 | void ArmAssembler::orr(Register rd, Register rn, |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 333 | ShifterOperand so, Condition cond) { |
| 334 | EmitType01(cond, so.type(), ORR, 0, rn, rd, so); |
| 335 | } |
| 336 | |
| 337 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 338 | void ArmAssembler::orrs(Register rd, Register rn, |
| 339 | ShifterOperand so, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 340 | EmitType01(cond, so.type(), ORR, 1, rn, rd, so); |
| 341 | } |
| 342 | |
| 343 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 344 | void ArmAssembler::mov(Register rd, ShifterOperand so, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 345 | EmitType01(cond, so.type(), MOV, 0, R0, rd, so); |
| 346 | } |
| 347 | |
| 348 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 349 | void ArmAssembler::movs(Register rd, ShifterOperand so, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 350 | EmitType01(cond, so.type(), MOV, 1, R0, rd, so); |
| 351 | } |
| 352 | |
| 353 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 354 | void ArmAssembler::bic(Register rd, Register rn, ShifterOperand so, |
| 355 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 356 | EmitType01(cond, so.type(), BIC, 0, rn, rd, so); |
| 357 | } |
| 358 | |
| 359 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 360 | void ArmAssembler::mvn(Register rd, ShifterOperand so, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 361 | EmitType01(cond, so.type(), MVN, 0, R0, rd, so); |
| 362 | } |
| 363 | |
| 364 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 365 | void ArmAssembler::mvns(Register rd, ShifterOperand so, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 366 | EmitType01(cond, so.type(), MVN, 1, R0, rd, so); |
| 367 | } |
| 368 | |
| 369 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 370 | void ArmAssembler::clz(Register rd, Register rm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 371 | CHECK_NE(rd, kNoRegister); |
| 372 | CHECK_NE(rm, kNoRegister); |
| 373 | CHECK_NE(cond, kNoCondition); |
| 374 | CHECK_NE(rd, PC); |
| 375 | CHECK_NE(rm, PC); |
| 376 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 377 | B24 | B22 | B21 | (0xf << 16) | |
| 378 | (static_cast<int32_t>(rd) << kRdShift) | |
| 379 | (0xf << 8) | B4 | static_cast<int32_t>(rm); |
| 380 | Emit(encoding); |
| 381 | } |
| 382 | |
| 383 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 384 | void ArmAssembler::movw(Register rd, uint16_t imm16, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 385 | CHECK_NE(cond, kNoCondition); |
| 386 | int32_t encoding = static_cast<int32_t>(cond) << kConditionShift | |
| 387 | B25 | B24 | ((imm16 >> 12) << 16) | |
| 388 | static_cast<int32_t>(rd) << kRdShift | (imm16 & 0xfff); |
| 389 | Emit(encoding); |
| 390 | } |
| 391 | |
| 392 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 393 | void ArmAssembler::movt(Register rd, uint16_t imm16, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 394 | CHECK_NE(cond, kNoCondition); |
| 395 | int32_t encoding = static_cast<int32_t>(cond) << kConditionShift | |
| 396 | B25 | B24 | B22 | ((imm16 >> 12) << 16) | |
| 397 | static_cast<int32_t>(rd) << kRdShift | (imm16 & 0xfff); |
| 398 | Emit(encoding); |
| 399 | } |
| 400 | |
| 401 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 402 | void ArmAssembler::EmitMulOp(Condition cond, int32_t opcode, |
| 403 | Register rd, Register rn, |
| 404 | Register rm, Register rs) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 405 | CHECK_NE(rd, kNoRegister); |
| 406 | CHECK_NE(rn, kNoRegister); |
| 407 | CHECK_NE(rm, kNoRegister); |
| 408 | CHECK_NE(rs, kNoRegister); |
| 409 | CHECK_NE(cond, kNoCondition); |
| 410 | int32_t encoding = opcode | |
| 411 | (static_cast<int32_t>(cond) << kConditionShift) | |
| 412 | (static_cast<int32_t>(rn) << kRnShift) | |
| 413 | (static_cast<int32_t>(rd) << kRdShift) | |
| 414 | (static_cast<int32_t>(rs) << kRsShift) | |
| 415 | B7 | B4 | |
| 416 | (static_cast<int32_t>(rm) << kRmShift); |
| 417 | Emit(encoding); |
| 418 | } |
| 419 | |
| 420 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 421 | void ArmAssembler::mul(Register rd, Register rn, Register rm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 422 | // Assembler registers rd, rn, rm are encoded as rn, rm, rs. |
| 423 | EmitMulOp(cond, 0, R0, rd, rn, rm); |
| 424 | } |
| 425 | |
| 426 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 427 | void ArmAssembler::mla(Register rd, Register rn, Register rm, Register ra, |
| 428 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 429 | // Assembler registers rd, rn, rm, ra are encoded as rn, rm, rs, rd. |
| 430 | EmitMulOp(cond, B21, ra, rd, rn, rm); |
| 431 | } |
| 432 | |
| 433 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 434 | void ArmAssembler::mls(Register rd, Register rn, Register rm, Register ra, |
| 435 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 436 | // Assembler registers rd, rn, rm, ra are encoded as rn, rm, rs, rd. |
| 437 | EmitMulOp(cond, B22 | B21, ra, rd, rn, rm); |
| 438 | } |
| 439 | |
| 440 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 441 | void ArmAssembler::umull(Register rd_lo, Register rd_hi, Register rn, |
| 442 | Register rm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 443 | // Assembler registers rd_lo, rd_hi, rn, rm are encoded as rd, rn, rm, rs. |
| 444 | EmitMulOp(cond, B23, rd_lo, rd_hi, rn, rm); |
| 445 | } |
| 446 | |
| 447 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 448 | void ArmAssembler::ldr(Register rd, Address ad, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 449 | EmitMemOp(cond, true, false, rd, ad); |
| 450 | } |
| 451 | |
| 452 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 453 | void ArmAssembler::str(Register rd, Address ad, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 454 | EmitMemOp(cond, false, false, rd, ad); |
| 455 | } |
| 456 | |
| 457 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 458 | void ArmAssembler::ldrb(Register rd, Address ad, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 459 | EmitMemOp(cond, true, true, rd, ad); |
| 460 | } |
| 461 | |
| 462 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 463 | void ArmAssembler::strb(Register rd, Address ad, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 464 | EmitMemOp(cond, false, true, rd, ad); |
| 465 | } |
| 466 | |
| 467 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 468 | void ArmAssembler::ldrh(Register rd, Address ad, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 469 | EmitMemOpAddressMode3(cond, L | B7 | H | B4, rd, ad); |
| 470 | } |
| 471 | |
| 472 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 473 | void ArmAssembler::strh(Register rd, Address ad, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 474 | EmitMemOpAddressMode3(cond, B7 | H | B4, rd, ad); |
| 475 | } |
| 476 | |
| 477 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 478 | void ArmAssembler::ldrsb(Register rd, Address ad, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 479 | EmitMemOpAddressMode3(cond, L | B7 | B6 | B4, rd, ad); |
| 480 | } |
| 481 | |
| 482 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 483 | void ArmAssembler::ldrsh(Register rd, Address ad, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 484 | EmitMemOpAddressMode3(cond, L | B7 | B6 | H | B4, rd, ad); |
| 485 | } |
| 486 | |
| 487 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 488 | void ArmAssembler::ldrd(Register rd, Address ad, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 489 | CHECK_EQ(rd % 2, 0); |
| 490 | EmitMemOpAddressMode3(cond, B7 | B6 | B4, rd, ad); |
| 491 | } |
| 492 | |
| 493 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 494 | void ArmAssembler::strd(Register rd, Address ad, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 495 | CHECK_EQ(rd % 2, 0); |
| 496 | EmitMemOpAddressMode3(cond, B7 | B6 | B5 | B4, rd, ad); |
| 497 | } |
| 498 | |
| 499 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 500 | void ArmAssembler::ldm(BlockAddressMode am, |
| 501 | Register base, |
| 502 | RegList regs, |
| 503 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 504 | EmitMultiMemOp(cond, am, true, base, regs); |
| 505 | } |
| 506 | |
| 507 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 508 | void ArmAssembler::stm(BlockAddressMode am, |
| 509 | Register base, |
| 510 | RegList regs, |
| 511 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 512 | EmitMultiMemOp(cond, am, false, base, regs); |
| 513 | } |
| 514 | |
| 515 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 516 | void ArmAssembler::ldrex(Register rt, Register rn, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 517 | CHECK_NE(rn, kNoRegister); |
| 518 | CHECK_NE(rt, kNoRegister); |
| 519 | CHECK_NE(cond, kNoCondition); |
| 520 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 521 | B24 | |
| 522 | B23 | |
| 523 | L | |
| 524 | (static_cast<int32_t>(rn) << kLdExRnShift) | |
| 525 | (static_cast<int32_t>(rt) << kLdExRtShift) | |
| 526 | B11 | B10 | B9 | B8 | B7 | B4 | B3 | B2 | B1 | B0; |
| 527 | Emit(encoding); |
| 528 | } |
| 529 | |
| 530 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 531 | void ArmAssembler::strex(Register rd, |
| 532 | Register rt, |
| 533 | Register rn, |
| 534 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 535 | CHECK_NE(rn, kNoRegister); |
| 536 | CHECK_NE(rd, kNoRegister); |
| 537 | CHECK_NE(rt, kNoRegister); |
| 538 | CHECK_NE(cond, kNoCondition); |
| 539 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 540 | B24 | |
| 541 | B23 | |
| 542 | (static_cast<int32_t>(rn) << kStrExRnShift) | |
| 543 | (static_cast<int32_t>(rd) << kStrExRdShift) | |
| 544 | B11 | B10 | B9 | B8 | B7 | B4 | |
| 545 | (static_cast<int32_t>(rt) << kStrExRtShift); |
| 546 | Emit(encoding); |
| 547 | } |
| 548 | |
| 549 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 550 | void ArmAssembler::clrex() { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 551 | int32_t encoding = (kSpecialCondition << kConditionShift) | |
| 552 | B26 | B24 | B22 | B21 | B20 | (0xff << 12) | B4 | 0xf; |
| 553 | Emit(encoding); |
| 554 | } |
| 555 | |
| 556 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 557 | void ArmAssembler::nop(Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 558 | CHECK_NE(cond, kNoCondition); |
| 559 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 560 | B25 | B24 | B21 | (0xf << 12); |
| 561 | Emit(encoding); |
| 562 | } |
| 563 | |
| 564 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 565 | void ArmAssembler::vmovsr(SRegister sn, Register rt, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 566 | CHECK_NE(sn, kNoSRegister); |
| 567 | CHECK_NE(rt, kNoRegister); |
| 568 | CHECK_NE(rt, SP); |
| 569 | CHECK_NE(rt, PC); |
| 570 | CHECK_NE(cond, kNoCondition); |
| 571 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 572 | B27 | B26 | B25 | |
| 573 | ((static_cast<int32_t>(sn) >> 1)*B16) | |
| 574 | (static_cast<int32_t>(rt)*B12) | B11 | B9 | |
| 575 | ((static_cast<int32_t>(sn) & 1)*B7) | B4; |
| 576 | Emit(encoding); |
| 577 | } |
| 578 | |
| 579 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 580 | void ArmAssembler::vmovrs(Register rt, SRegister sn, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 581 | CHECK_NE(sn, kNoSRegister); |
| 582 | CHECK_NE(rt, kNoRegister); |
| 583 | CHECK_NE(rt, SP); |
| 584 | CHECK_NE(rt, PC); |
| 585 | CHECK_NE(cond, kNoCondition); |
| 586 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 587 | B27 | B26 | B25 | B20 | |
| 588 | ((static_cast<int32_t>(sn) >> 1)*B16) | |
| 589 | (static_cast<int32_t>(rt)*B12) | B11 | B9 | |
| 590 | ((static_cast<int32_t>(sn) & 1)*B7) | B4; |
| 591 | Emit(encoding); |
| 592 | } |
| 593 | |
| 594 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 595 | void ArmAssembler::vmovsrr(SRegister sm, Register rt, Register rt2, |
| 596 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 597 | CHECK_NE(sm, kNoSRegister); |
| 598 | CHECK_NE(sm, S31); |
| 599 | CHECK_NE(rt, kNoRegister); |
| 600 | CHECK_NE(rt, SP); |
| 601 | CHECK_NE(rt, PC); |
| 602 | CHECK_NE(rt2, kNoRegister); |
| 603 | CHECK_NE(rt2, SP); |
| 604 | CHECK_NE(rt2, PC); |
| 605 | CHECK_NE(cond, kNoCondition); |
| 606 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 607 | B27 | B26 | B22 | |
| 608 | (static_cast<int32_t>(rt2)*B16) | |
| 609 | (static_cast<int32_t>(rt)*B12) | B11 | B9 | |
| 610 | ((static_cast<int32_t>(sm) & 1)*B5) | B4 | |
| 611 | (static_cast<int32_t>(sm) >> 1); |
| 612 | Emit(encoding); |
| 613 | } |
| 614 | |
| 615 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 616 | void ArmAssembler::vmovrrs(Register rt, Register rt2, SRegister sm, |
| 617 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 618 | CHECK_NE(sm, kNoSRegister); |
| 619 | CHECK_NE(sm, S31); |
| 620 | CHECK_NE(rt, kNoRegister); |
| 621 | CHECK_NE(rt, SP); |
| 622 | CHECK_NE(rt, PC); |
| 623 | CHECK_NE(rt2, kNoRegister); |
| 624 | CHECK_NE(rt2, SP); |
| 625 | CHECK_NE(rt2, PC); |
| 626 | CHECK_NE(rt, rt2); |
| 627 | CHECK_NE(cond, kNoCondition); |
| 628 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 629 | B27 | B26 | B22 | B20 | |
| 630 | (static_cast<int32_t>(rt2)*B16) | |
| 631 | (static_cast<int32_t>(rt)*B12) | B11 | B9 | |
| 632 | ((static_cast<int32_t>(sm) & 1)*B5) | B4 | |
| 633 | (static_cast<int32_t>(sm) >> 1); |
| 634 | Emit(encoding); |
| 635 | } |
| 636 | |
| 637 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 638 | void ArmAssembler::vmovdrr(DRegister dm, Register rt, Register rt2, |
| 639 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 640 | CHECK_NE(dm, kNoDRegister); |
| 641 | CHECK_NE(rt, kNoRegister); |
| 642 | CHECK_NE(rt, SP); |
| 643 | CHECK_NE(rt, PC); |
| 644 | CHECK_NE(rt2, kNoRegister); |
| 645 | CHECK_NE(rt2, SP); |
| 646 | CHECK_NE(rt2, PC); |
| 647 | CHECK_NE(cond, kNoCondition); |
| 648 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 649 | B27 | B26 | B22 | |
| 650 | (static_cast<int32_t>(rt2)*B16) | |
| 651 | (static_cast<int32_t>(rt)*B12) | B11 | B9 | B8 | |
| 652 | ((static_cast<int32_t>(dm) >> 4)*B5) | B4 | |
| 653 | (static_cast<int32_t>(dm) & 0xf); |
| 654 | Emit(encoding); |
| 655 | } |
| 656 | |
| 657 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 658 | void ArmAssembler::vmovrrd(Register rt, Register rt2, DRegister dm, |
| 659 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 660 | CHECK_NE(dm, kNoDRegister); |
| 661 | CHECK_NE(rt, kNoRegister); |
| 662 | CHECK_NE(rt, SP); |
| 663 | CHECK_NE(rt, PC); |
| 664 | CHECK_NE(rt2, kNoRegister); |
| 665 | CHECK_NE(rt2, SP); |
| 666 | CHECK_NE(rt2, PC); |
| 667 | CHECK_NE(rt, rt2); |
| 668 | CHECK_NE(cond, kNoCondition); |
| 669 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 670 | B27 | B26 | B22 | B20 | |
| 671 | (static_cast<int32_t>(rt2)*B16) | |
| 672 | (static_cast<int32_t>(rt)*B12) | B11 | B9 | B8 | |
| 673 | ((static_cast<int32_t>(dm) >> 4)*B5) | B4 | |
| 674 | (static_cast<int32_t>(dm) & 0xf); |
| 675 | Emit(encoding); |
| 676 | } |
| 677 | |
| 678 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 679 | void ArmAssembler::vldrs(SRegister sd, Address ad, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 680 | CHECK_NE(sd, kNoSRegister); |
| 681 | CHECK_NE(cond, kNoCondition); |
| 682 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 683 | B27 | B26 | B24 | B20 | |
| 684 | ((static_cast<int32_t>(sd) & 1)*B22) | |
| 685 | ((static_cast<int32_t>(sd) >> 1)*B12) | |
| 686 | B11 | B9 | ad.vencoding(); |
| 687 | Emit(encoding); |
| 688 | } |
| 689 | |
| 690 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 691 | void ArmAssembler::vstrs(SRegister sd, Address ad, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 692 | CHECK_NE(static_cast<Register>(ad.encoding_ & (0xf << kRnShift)), PC); |
| 693 | CHECK_NE(sd, kNoSRegister); |
| 694 | CHECK_NE(cond, kNoCondition); |
| 695 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 696 | B27 | B26 | B24 | |
| 697 | ((static_cast<int32_t>(sd) & 1)*B22) | |
| 698 | ((static_cast<int32_t>(sd) >> 1)*B12) | |
| 699 | B11 | B9 | ad.vencoding(); |
| 700 | Emit(encoding); |
| 701 | } |
| 702 | |
| 703 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 704 | void ArmAssembler::vldrd(DRegister dd, Address ad, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 705 | CHECK_NE(dd, kNoDRegister); |
| 706 | CHECK_NE(cond, kNoCondition); |
| 707 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 708 | B27 | B26 | B24 | B20 | |
| 709 | ((static_cast<int32_t>(dd) >> 4)*B22) | |
| 710 | ((static_cast<int32_t>(dd) & 0xf)*B12) | |
| 711 | B11 | B9 | B8 | ad.vencoding(); |
| 712 | Emit(encoding); |
| 713 | } |
| 714 | |
| 715 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 716 | void ArmAssembler::vstrd(DRegister dd, Address ad, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 717 | CHECK_NE(static_cast<Register>(ad.encoding_ & (0xf << kRnShift)), PC); |
| 718 | CHECK_NE(dd, kNoDRegister); |
| 719 | CHECK_NE(cond, kNoCondition); |
| 720 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 721 | B27 | B26 | B24 | |
| 722 | ((static_cast<int32_t>(dd) >> 4)*B22) | |
| 723 | ((static_cast<int32_t>(dd) & 0xf)*B12) | |
| 724 | B11 | B9 | B8 | ad.vencoding(); |
| 725 | Emit(encoding); |
| 726 | } |
| 727 | |
| 728 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 729 | void ArmAssembler::EmitVFPsss(Condition cond, int32_t opcode, |
| 730 | SRegister sd, SRegister sn, SRegister sm) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 731 | CHECK_NE(sd, kNoSRegister); |
| 732 | CHECK_NE(sn, kNoSRegister); |
| 733 | CHECK_NE(sm, kNoSRegister); |
| 734 | CHECK_NE(cond, kNoCondition); |
| 735 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 736 | B27 | B26 | B25 | B11 | B9 | opcode | |
| 737 | ((static_cast<int32_t>(sd) & 1)*B22) | |
| 738 | ((static_cast<int32_t>(sn) >> 1)*B16) | |
| 739 | ((static_cast<int32_t>(sd) >> 1)*B12) | |
| 740 | ((static_cast<int32_t>(sn) & 1)*B7) | |
| 741 | ((static_cast<int32_t>(sm) & 1)*B5) | |
| 742 | (static_cast<int32_t>(sm) >> 1); |
| 743 | Emit(encoding); |
| 744 | } |
| 745 | |
| 746 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 747 | void ArmAssembler::EmitVFPddd(Condition cond, int32_t opcode, |
| 748 | DRegister dd, DRegister dn, DRegister dm) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 749 | CHECK_NE(dd, kNoDRegister); |
| 750 | CHECK_NE(dn, kNoDRegister); |
| 751 | CHECK_NE(dm, kNoDRegister); |
| 752 | CHECK_NE(cond, kNoCondition); |
| 753 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 754 | B27 | B26 | B25 | B11 | B9 | B8 | opcode | |
| 755 | ((static_cast<int32_t>(dd) >> 4)*B22) | |
| 756 | ((static_cast<int32_t>(dn) & 0xf)*B16) | |
| 757 | ((static_cast<int32_t>(dd) & 0xf)*B12) | |
| 758 | ((static_cast<int32_t>(dn) >> 4)*B7) | |
| 759 | ((static_cast<int32_t>(dm) >> 4)*B5) | |
| 760 | (static_cast<int32_t>(dm) & 0xf); |
| 761 | Emit(encoding); |
| 762 | } |
| 763 | |
| 764 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 765 | void ArmAssembler::vmovs(SRegister sd, SRegister sm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 766 | EmitVFPsss(cond, B23 | B21 | B20 | B6, sd, S0, sm); |
| 767 | } |
| 768 | |
| 769 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 770 | void ArmAssembler::vmovd(DRegister dd, DRegister dm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 771 | EmitVFPddd(cond, B23 | B21 | B20 | B6, dd, D0, dm); |
| 772 | } |
| 773 | |
| 774 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 775 | bool ArmAssembler::vmovs(SRegister sd, float s_imm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 776 | uint32_t imm32 = bit_cast<uint32_t, float>(s_imm); |
| 777 | if (((imm32 & ((1 << 19) - 1)) == 0) && |
| 778 | ((((imm32 >> 25) & ((1 << 6) - 1)) == (1 << 5)) || |
| 779 | (((imm32 >> 25) & ((1 << 6) - 1)) == ((1 << 5) -1)))) { |
| 780 | uint8_t imm8 = ((imm32 >> 31) << 7) | (((imm32 >> 29) & 1) << 6) | |
| 781 | ((imm32 >> 19) & ((1 << 6) -1)); |
| 782 | EmitVFPsss(cond, B23 | B21 | B20 | ((imm8 >> 4)*B16) | (imm8 & 0xf), |
| 783 | sd, S0, S0); |
| 784 | return true; |
| 785 | } |
| 786 | return false; |
| 787 | } |
| 788 | |
| 789 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 790 | bool ArmAssembler::vmovd(DRegister dd, double d_imm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 791 | uint64_t imm64 = bit_cast<uint64_t, double>(d_imm); |
| 792 | if (((imm64 & ((1LL << 48) - 1)) == 0) && |
| 793 | ((((imm64 >> 54) & ((1 << 9) - 1)) == (1 << 8)) || |
| 794 | (((imm64 >> 54) & ((1 << 9) - 1)) == ((1 << 8) -1)))) { |
| 795 | uint8_t imm8 = ((imm64 >> 63) << 7) | (((imm64 >> 61) & 1) << 6) | |
| 796 | ((imm64 >> 48) & ((1 << 6) -1)); |
| 797 | EmitVFPddd(cond, B23 | B21 | B20 | ((imm8 >> 4)*B16) | B8 | (imm8 & 0xf), |
| 798 | dd, D0, D0); |
| 799 | return true; |
| 800 | } |
| 801 | return false; |
| 802 | } |
| 803 | |
| 804 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 805 | void ArmAssembler::vadds(SRegister sd, SRegister sn, SRegister sm, |
| 806 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 807 | EmitVFPsss(cond, B21 | B20, sd, sn, sm); |
| 808 | } |
| 809 | |
| 810 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 811 | void ArmAssembler::vaddd(DRegister dd, DRegister dn, DRegister dm, |
| 812 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 813 | EmitVFPddd(cond, B21 | B20, dd, dn, dm); |
| 814 | } |
| 815 | |
| 816 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 817 | void ArmAssembler::vsubs(SRegister sd, SRegister sn, SRegister sm, |
| 818 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 819 | EmitVFPsss(cond, B21 | B20 | B6, sd, sn, sm); |
| 820 | } |
| 821 | |
| 822 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 823 | void ArmAssembler::vsubd(DRegister dd, DRegister dn, DRegister dm, |
| 824 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 825 | EmitVFPddd(cond, B21 | B20 | B6, dd, dn, dm); |
| 826 | } |
| 827 | |
| 828 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 829 | void ArmAssembler::vmuls(SRegister sd, SRegister sn, SRegister sm, |
| 830 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 831 | EmitVFPsss(cond, B21, sd, sn, sm); |
| 832 | } |
| 833 | |
| 834 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 835 | void ArmAssembler::vmuld(DRegister dd, DRegister dn, DRegister dm, |
| 836 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 837 | EmitVFPddd(cond, B21, dd, dn, dm); |
| 838 | } |
| 839 | |
| 840 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 841 | void ArmAssembler::vmlas(SRegister sd, SRegister sn, SRegister sm, |
| 842 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 843 | EmitVFPsss(cond, 0, sd, sn, sm); |
| 844 | } |
| 845 | |
| 846 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 847 | void ArmAssembler::vmlad(DRegister dd, DRegister dn, DRegister dm, |
| 848 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 849 | EmitVFPddd(cond, 0, dd, dn, dm); |
| 850 | } |
| 851 | |
| 852 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 853 | void ArmAssembler::vmlss(SRegister sd, SRegister sn, SRegister sm, |
| 854 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 855 | EmitVFPsss(cond, B6, sd, sn, sm); |
| 856 | } |
| 857 | |
| 858 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 859 | void ArmAssembler::vmlsd(DRegister dd, DRegister dn, DRegister dm, |
| 860 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 861 | EmitVFPddd(cond, B6, dd, dn, dm); |
| 862 | } |
| 863 | |
| 864 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 865 | void ArmAssembler::vdivs(SRegister sd, SRegister sn, SRegister sm, |
| 866 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 867 | EmitVFPsss(cond, B23, sd, sn, sm); |
| 868 | } |
| 869 | |
| 870 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 871 | void ArmAssembler::vdivd(DRegister dd, DRegister dn, DRegister dm, |
| 872 | Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 873 | EmitVFPddd(cond, B23, dd, dn, dm); |
| 874 | } |
| 875 | |
| 876 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 877 | void ArmAssembler::vabss(SRegister sd, SRegister sm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 878 | EmitVFPsss(cond, B23 | B21 | B20 | B7 | B6, sd, S0, sm); |
| 879 | } |
| 880 | |
| 881 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 882 | void ArmAssembler::vabsd(DRegister dd, DRegister dm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 883 | EmitVFPddd(cond, B23 | B21 | B20 | B7 | B6, dd, D0, dm); |
| 884 | } |
| 885 | |
| 886 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 887 | void ArmAssembler::vnegs(SRegister sd, SRegister sm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 888 | EmitVFPsss(cond, B23 | B21 | B20 | B16 | B6, sd, S0, sm); |
| 889 | } |
| 890 | |
| 891 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 892 | void ArmAssembler::vnegd(DRegister dd, DRegister dm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 893 | EmitVFPddd(cond, B23 | B21 | B20 | B16 | B6, dd, D0, dm); |
| 894 | } |
| 895 | |
| 896 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 897 | void ArmAssembler::vsqrts(SRegister sd, SRegister sm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 898 | EmitVFPsss(cond, B23 | B21 | B20 | B16 | B7 | B6, sd, S0, sm); |
| 899 | } |
| 900 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 901 | void ArmAssembler::vsqrtd(DRegister dd, DRegister dm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 902 | EmitVFPddd(cond, B23 | B21 | B20 | B16 | B7 | B6, dd, D0, dm); |
| 903 | } |
| 904 | |
| 905 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 906 | void ArmAssembler::EmitVFPsd(Condition cond, int32_t opcode, |
| 907 | SRegister sd, DRegister dm) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 908 | CHECK_NE(sd, kNoSRegister); |
| 909 | CHECK_NE(dm, kNoDRegister); |
| 910 | CHECK_NE(cond, kNoCondition); |
| 911 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 912 | B27 | B26 | B25 | B11 | B9 | opcode | |
| 913 | ((static_cast<int32_t>(sd) & 1)*B22) | |
| 914 | ((static_cast<int32_t>(sd) >> 1)*B12) | |
| 915 | ((static_cast<int32_t>(dm) >> 4)*B5) | |
| 916 | (static_cast<int32_t>(dm) & 0xf); |
| 917 | Emit(encoding); |
| 918 | } |
| 919 | |
| 920 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 921 | void ArmAssembler::EmitVFPds(Condition cond, int32_t opcode, |
| 922 | DRegister dd, SRegister sm) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 923 | CHECK_NE(dd, kNoDRegister); |
| 924 | CHECK_NE(sm, kNoSRegister); |
| 925 | CHECK_NE(cond, kNoCondition); |
| 926 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 927 | B27 | B26 | B25 | B11 | B9 | opcode | |
| 928 | ((static_cast<int32_t>(dd) >> 4)*B22) | |
| 929 | ((static_cast<int32_t>(dd) & 0xf)*B12) | |
| 930 | ((static_cast<int32_t>(sm) & 1)*B5) | |
| 931 | (static_cast<int32_t>(sm) >> 1); |
| 932 | Emit(encoding); |
| 933 | } |
| 934 | |
| 935 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 936 | void ArmAssembler::vcvtsd(SRegister sd, DRegister dm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 937 | EmitVFPsd(cond, B23 | B21 | B20 | B18 | B17 | B16 | B8 | B7 | B6, sd, dm); |
| 938 | } |
| 939 | |
| 940 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 941 | void ArmAssembler::vcvtds(DRegister dd, SRegister sm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 942 | EmitVFPds(cond, B23 | B21 | B20 | B18 | B17 | B16 | B7 | B6, dd, sm); |
| 943 | } |
| 944 | |
| 945 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 946 | void ArmAssembler::vcvtis(SRegister sd, SRegister sm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 947 | EmitVFPsss(cond, B23 | B21 | B20 | B19 | B18 | B16 | B7 | B6, sd, S0, sm); |
| 948 | } |
| 949 | |
| 950 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 951 | void ArmAssembler::vcvtid(SRegister sd, DRegister dm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 952 | EmitVFPsd(cond, B23 | B21 | B20 | B19 | B18 | B16 | B8 | B7 | B6, sd, dm); |
| 953 | } |
| 954 | |
| 955 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 956 | void ArmAssembler::vcvtsi(SRegister sd, SRegister sm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 957 | EmitVFPsss(cond, B23 | B21 | B20 | B19 | B7 | B6, sd, S0, sm); |
| 958 | } |
| 959 | |
| 960 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 961 | void ArmAssembler::vcvtdi(DRegister dd, SRegister sm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 962 | EmitVFPds(cond, B23 | B21 | B20 | B19 | B8 | B7 | B6, dd, sm); |
| 963 | } |
| 964 | |
| 965 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 966 | void ArmAssembler::vcvtus(SRegister sd, SRegister sm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 967 | EmitVFPsss(cond, B23 | B21 | B20 | B19 | B18 | B7 | B6, sd, S0, sm); |
| 968 | } |
| 969 | |
| 970 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 971 | void ArmAssembler::vcvtud(SRegister sd, DRegister dm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 972 | EmitVFPsd(cond, B23 | B21 | B20 | B19 | B18 | B8 | B7 | B6, sd, dm); |
| 973 | } |
| 974 | |
| 975 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 976 | void ArmAssembler::vcvtsu(SRegister sd, SRegister sm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 977 | EmitVFPsss(cond, B23 | B21 | B20 | B19 | B6, sd, S0, sm); |
| 978 | } |
| 979 | |
| 980 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 981 | void ArmAssembler::vcvtdu(DRegister dd, SRegister sm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 982 | EmitVFPds(cond, B23 | B21 | B20 | B19 | B8 | B6, dd, sm); |
| 983 | } |
| 984 | |
| 985 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 986 | void ArmAssembler::vcmps(SRegister sd, SRegister sm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 987 | EmitVFPsss(cond, B23 | B21 | B20 | B18 | B6, sd, S0, sm); |
| 988 | } |
| 989 | |
| 990 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 991 | void ArmAssembler::vcmpd(DRegister dd, DRegister dm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 992 | EmitVFPddd(cond, B23 | B21 | B20 | B18 | B6, dd, D0, dm); |
| 993 | } |
| 994 | |
| 995 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 996 | void ArmAssembler::vcmpsz(SRegister sd, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 997 | EmitVFPsss(cond, B23 | B21 | B20 | B18 | B16 | B6, sd, S0, S0); |
| 998 | } |
| 999 | |
| 1000 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1001 | void ArmAssembler::vcmpdz(DRegister dd, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 1002 | EmitVFPddd(cond, B23 | B21 | B20 | B18 | B16 | B6, dd, D0, D0); |
| 1003 | } |
| 1004 | |
| 1005 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1006 | void ArmAssembler::vmstat(Condition cond) { // VMRS APSR_nzcv, FPSCR |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 1007 | CHECK_NE(cond, kNoCondition); |
| 1008 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 1009 | B27 | B26 | B25 | B23 | B22 | B21 | B20 | B16 | |
| 1010 | (static_cast<int32_t>(PC)*B12) | |
| 1011 | B11 | B9 | B4; |
| 1012 | Emit(encoding); |
| 1013 | } |
| 1014 | |
| 1015 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1016 | void ArmAssembler::svc(uint32_t imm24) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 1017 | CHECK(IsUint(24, imm24)); |
| 1018 | int32_t encoding = (AL << kConditionShift) | B27 | B26 | B25 | B24 | imm24; |
| 1019 | Emit(encoding); |
| 1020 | } |
| 1021 | |
| 1022 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1023 | void ArmAssembler::bkpt(uint16_t imm16) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 1024 | int32_t encoding = (AL << kConditionShift) | B24 | B21 | |
| 1025 | ((imm16 >> 4) << 8) | B6 | B5 | B4 | (imm16 & 0xf); |
| 1026 | Emit(encoding); |
| 1027 | } |
| 1028 | |
| 1029 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1030 | void ArmAssembler::b(Label* label, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 1031 | EmitBranch(cond, label, false); |
| 1032 | } |
| 1033 | |
| 1034 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1035 | void ArmAssembler::bl(Label* label, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 1036 | EmitBranch(cond, label, true); |
| 1037 | } |
| 1038 | |
| 1039 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1040 | void ArmAssembler::blx(Register rm, Condition cond) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 1041 | CHECK_NE(rm, kNoRegister); |
| 1042 | CHECK_NE(cond, kNoCondition); |
| 1043 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 1044 | B24 | B21 | (0xfff << 8) | B5 | B4 | |
| 1045 | (static_cast<int32_t>(rm) << kRmShift); |
| 1046 | Emit(encoding); |
| 1047 | } |
| 1048 | |
Ian Rogers | ae67599 | 2011-10-09 17:10:22 -0700 | [diff] [blame] | 1049 | void ArmAssembler::bx(Register rm, Condition cond) { |
| 1050 | CHECK_NE(rm, kNoRegister); |
| 1051 | CHECK_NE(cond, kNoCondition); |
| 1052 | int32_t encoding = (static_cast<int32_t>(cond) << kConditionShift) | |
| 1053 | B24 | B21 | (0xfff << 8) | B4 | |
| 1054 | (static_cast<int32_t>(rm) << kRmShift); |
| 1055 | Emit(encoding); |
| 1056 | } |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 1057 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1058 | void ArmAssembler::MarkExceptionHandler(Label* label) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 1059 | EmitType01(AL, 1, TST, 1, PC, R0, ShifterOperand(0)); |
| 1060 | Label l; |
| 1061 | b(&l); |
| 1062 | EmitBranch(AL, label, false); |
| 1063 | Bind(&l); |
| 1064 | } |
| 1065 | |
| 1066 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1067 | void ArmAssembler::Bind(Label* label) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 1068 | CHECK(!label->IsBound()); |
| 1069 | int bound_pc = buffer_.Size(); |
| 1070 | while (label->IsLinked()) { |
| 1071 | int32_t position = label->Position(); |
| 1072 | int32_t next = buffer_.Load<int32_t>(position); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1073 | int32_t encoded = ArmAssembler::EncodeBranchOffset(bound_pc - position, next); |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 1074 | buffer_.Store<int32_t>(position, encoded); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1075 | label->position_ = ArmAssembler::DecodeBranchOffset(next); |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 1076 | } |
| 1077 | label->BindTo(bound_pc); |
| 1078 | } |
| 1079 | |
| 1080 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1081 | void ArmAssembler::EncodeUint32InTstInstructions(uint32_t data) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 1082 | // TODO: Consider using movw ip, <16 bits>. |
| 1083 | while (!IsUint(8, data)) { |
| 1084 | tst(R0, ShifterOperand(data & 0xFF), VS); |
| 1085 | data >>= 8; |
| 1086 | } |
| 1087 | tst(R0, ShifterOperand(data), MI); |
| 1088 | } |
| 1089 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1090 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1091 | int32_t ArmAssembler::EncodeBranchOffset(int offset, int32_t inst) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 1092 | // The offset is off by 8 due to the way the ARM CPUs read PC. |
| 1093 | offset -= 8; |
Elliott Hughes | 06b37d9 | 2011-10-16 11:51:29 -0700 | [diff] [blame] | 1094 | CHECK_ALIGNED(offset, 4); |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 1095 | CHECK(IsInt(CountOneBits(kBranchOffsetMask), offset)); |
| 1096 | |
| 1097 | // Properly preserve only the bits supported in the instruction. |
| 1098 | offset >>= 2; |
| 1099 | offset &= kBranchOffsetMask; |
| 1100 | return (inst & ~kBranchOffsetMask) | offset; |
| 1101 | } |
| 1102 | |
| 1103 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1104 | int ArmAssembler::DecodeBranchOffset(int32_t inst) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 1105 | // Sign-extend, left-shift by 2, then add 8. |
| 1106 | return ((((inst & kBranchOffsetMask) << 8) >> 6) + 8); |
| 1107 | } |
| 1108 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1109 | void ArmAssembler::AddConstant(Register rd, int32_t value, Condition cond) { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1110 | AddConstant(rd, rd, value, cond); |
| 1111 | } |
| 1112 | |
| 1113 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1114 | void ArmAssembler::AddConstant(Register rd, Register rn, int32_t value, |
| 1115 | Condition cond) { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1116 | if (value == 0) { |
| 1117 | if (rd != rn) { |
| 1118 | mov(rd, ShifterOperand(rn), cond); |
| 1119 | } |
| 1120 | return; |
| 1121 | } |
| 1122 | // We prefer to select the shorter code sequence rather than selecting add for |
| 1123 | // positive values and sub for negatives ones, which would slightly improve |
| 1124 | // the readability of generated code for some constants. |
| 1125 | ShifterOperand shifter_op; |
| 1126 | if (ShifterOperand::CanHold(value, &shifter_op)) { |
| 1127 | add(rd, rn, shifter_op, cond); |
| 1128 | } else if (ShifterOperand::CanHold(-value, &shifter_op)) { |
| 1129 | sub(rd, rn, shifter_op, cond); |
| 1130 | } else { |
| 1131 | CHECK(rn != IP); |
| 1132 | if (ShifterOperand::CanHold(~value, &shifter_op)) { |
| 1133 | mvn(IP, shifter_op, cond); |
| 1134 | add(rd, rn, ShifterOperand(IP), cond); |
| 1135 | } else if (ShifterOperand::CanHold(~(-value), &shifter_op)) { |
| 1136 | mvn(IP, shifter_op, cond); |
| 1137 | sub(rd, rn, ShifterOperand(IP), cond); |
| 1138 | } else { |
| 1139 | movw(IP, Low16Bits(value), cond); |
| 1140 | uint16_t value_high = High16Bits(value); |
| 1141 | if (value_high != 0) { |
| 1142 | movt(IP, value_high, cond); |
| 1143 | } |
| 1144 | add(rd, rn, ShifterOperand(IP), cond); |
| 1145 | } |
| 1146 | } |
| 1147 | } |
| 1148 | |
| 1149 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1150 | void ArmAssembler::AddConstantSetFlags(Register rd, Register rn, int32_t value, |
| 1151 | Condition cond) { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1152 | ShifterOperand shifter_op; |
| 1153 | if (ShifterOperand::CanHold(value, &shifter_op)) { |
| 1154 | adds(rd, rn, shifter_op, cond); |
| 1155 | } else if (ShifterOperand::CanHold(-value, &shifter_op)) { |
| 1156 | subs(rd, rn, shifter_op, cond); |
| 1157 | } else { |
| 1158 | CHECK(rn != IP); |
| 1159 | if (ShifterOperand::CanHold(~value, &shifter_op)) { |
| 1160 | mvn(IP, shifter_op, cond); |
| 1161 | adds(rd, rn, ShifterOperand(IP), cond); |
| 1162 | } else if (ShifterOperand::CanHold(~(-value), &shifter_op)) { |
| 1163 | mvn(IP, shifter_op, cond); |
| 1164 | subs(rd, rn, ShifterOperand(IP), cond); |
| 1165 | } else { |
| 1166 | movw(IP, Low16Bits(value), cond); |
| 1167 | uint16_t value_high = High16Bits(value); |
| 1168 | if (value_high != 0) { |
| 1169 | movt(IP, value_high, cond); |
| 1170 | } |
| 1171 | adds(rd, rn, ShifterOperand(IP), cond); |
| 1172 | } |
| 1173 | } |
| 1174 | } |
| 1175 | |
| 1176 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1177 | void ArmAssembler::LoadImmediate(Register rd, int32_t value, Condition cond) { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1178 | ShifterOperand shifter_op; |
| 1179 | if (ShifterOperand::CanHold(value, &shifter_op)) { |
| 1180 | mov(rd, shifter_op, cond); |
| 1181 | } else if (ShifterOperand::CanHold(~value, &shifter_op)) { |
| 1182 | mvn(rd, shifter_op, cond); |
| 1183 | } else { |
| 1184 | movw(rd, Low16Bits(value), cond); |
| 1185 | uint16_t value_high = High16Bits(value); |
| 1186 | if (value_high != 0) { |
| 1187 | movt(rd, value_high, cond); |
| 1188 | } |
| 1189 | } |
| 1190 | } |
| 1191 | |
| 1192 | |
| 1193 | bool Address::CanHoldLoadOffset(LoadOperandType type, int offset) { |
| 1194 | switch (type) { |
| 1195 | case kLoadSignedByte: |
| 1196 | case kLoadSignedHalfword: |
| 1197 | case kLoadUnsignedHalfword: |
| 1198 | case kLoadWordPair: |
| 1199 | return IsAbsoluteUint(8, offset); // Addressing mode 3. |
| 1200 | case kLoadUnsignedByte: |
| 1201 | case kLoadWord: |
| 1202 | return IsAbsoluteUint(12, offset); // Addressing mode 2. |
| 1203 | case kLoadSWord: |
| 1204 | case kLoadDWord: |
| 1205 | return IsAbsoluteUint(10, offset); // VFP addressing mode. |
| 1206 | default: |
| 1207 | LOG(FATAL) << "UNREACHABLE"; |
| 1208 | return false; |
| 1209 | } |
| 1210 | } |
| 1211 | |
| 1212 | |
| 1213 | bool Address::CanHoldStoreOffset(StoreOperandType type, int offset) { |
| 1214 | switch (type) { |
| 1215 | case kStoreHalfword: |
| 1216 | case kStoreWordPair: |
| 1217 | return IsAbsoluteUint(8, offset); // Addressing mode 3. |
| 1218 | case kStoreByte: |
| 1219 | case kStoreWord: |
| 1220 | return IsAbsoluteUint(12, offset); // Addressing mode 2. |
| 1221 | case kStoreSWord: |
| 1222 | case kStoreDWord: |
| 1223 | return IsAbsoluteUint(10, offset); // VFP addressing mode. |
| 1224 | default: |
| 1225 | LOG(FATAL) << "UNREACHABLE"; |
| 1226 | return false; |
| 1227 | } |
| 1228 | } |
| 1229 | |
| 1230 | |
| 1231 | // Implementation note: this method must emit at most one instruction when |
| 1232 | // Address::CanHoldLoadOffset. |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1233 | void ArmAssembler::LoadFromOffset(LoadOperandType type, |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1234 | Register reg, |
| 1235 | Register base, |
| 1236 | int32_t offset, |
| 1237 | Condition cond) { |
| 1238 | if (!Address::CanHoldLoadOffset(type, offset)) { |
| 1239 | CHECK(base != IP); |
| 1240 | LoadImmediate(IP, offset, cond); |
| 1241 | add(IP, IP, ShifterOperand(base), cond); |
| 1242 | base = IP; |
| 1243 | offset = 0; |
| 1244 | } |
| 1245 | CHECK(Address::CanHoldLoadOffset(type, offset)); |
| 1246 | switch (type) { |
| 1247 | case kLoadSignedByte: |
| 1248 | ldrsb(reg, Address(base, offset), cond); |
| 1249 | break; |
| 1250 | case kLoadUnsignedByte: |
| 1251 | ldrb(reg, Address(base, offset), cond); |
| 1252 | break; |
| 1253 | case kLoadSignedHalfword: |
| 1254 | ldrsh(reg, Address(base, offset), cond); |
| 1255 | break; |
| 1256 | case kLoadUnsignedHalfword: |
| 1257 | ldrh(reg, Address(base, offset), cond); |
| 1258 | break; |
| 1259 | case kLoadWord: |
| 1260 | ldr(reg, Address(base, offset), cond); |
| 1261 | break; |
| 1262 | case kLoadWordPair: |
| 1263 | ldrd(reg, Address(base, offset), cond); |
| 1264 | break; |
| 1265 | default: |
| 1266 | LOG(FATAL) << "UNREACHABLE"; |
| 1267 | } |
| 1268 | } |
| 1269 | |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1270 | // Implementation note: this method must emit at most one instruction when |
| 1271 | // Address::CanHoldLoadOffset, as expected by JIT::GuardedLoadFromOffset. |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1272 | void ArmAssembler::LoadSFromOffset(SRegister reg, |
| 1273 | Register base, |
| 1274 | int32_t offset, |
| 1275 | Condition cond) { |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1276 | if (!Address::CanHoldLoadOffset(kLoadSWord, offset)) { |
| 1277 | CHECK_NE(base, IP); |
| 1278 | LoadImmediate(IP, offset, cond); |
| 1279 | add(IP, IP, ShifterOperand(base), cond); |
| 1280 | base = IP; |
| 1281 | offset = 0; |
| 1282 | } |
| 1283 | CHECK(Address::CanHoldLoadOffset(kLoadSWord, offset)); |
| 1284 | vldrs(reg, Address(base, offset), cond); |
| 1285 | } |
| 1286 | |
| 1287 | // Implementation note: this method must emit at most one instruction when |
| 1288 | // Address::CanHoldLoadOffset, as expected by JIT::GuardedLoadFromOffset. |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1289 | void ArmAssembler::LoadDFromOffset(DRegister reg, |
| 1290 | Register base, |
| 1291 | int32_t offset, |
| 1292 | Condition cond) { |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1293 | if (!Address::CanHoldLoadOffset(kLoadDWord, offset)) { |
| 1294 | CHECK_NE(base, IP); |
| 1295 | LoadImmediate(IP, offset, cond); |
| 1296 | add(IP, IP, ShifterOperand(base), cond); |
| 1297 | base = IP; |
| 1298 | offset = 0; |
| 1299 | } |
| 1300 | CHECK(Address::CanHoldLoadOffset(kLoadDWord, offset)); |
| 1301 | vldrd(reg, Address(base, offset), cond); |
| 1302 | } |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1303 | |
| 1304 | // Implementation note: this method must emit at most one instruction when |
| 1305 | // Address::CanHoldStoreOffset. |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1306 | void ArmAssembler::StoreToOffset(StoreOperandType type, |
| 1307 | Register reg, |
| 1308 | Register base, |
| 1309 | int32_t offset, |
| 1310 | Condition cond) { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1311 | if (!Address::CanHoldStoreOffset(type, offset)) { |
| 1312 | CHECK(reg != IP); |
| 1313 | CHECK(base != IP); |
| 1314 | LoadImmediate(IP, offset, cond); |
| 1315 | add(IP, IP, ShifterOperand(base), cond); |
| 1316 | base = IP; |
| 1317 | offset = 0; |
| 1318 | } |
| 1319 | CHECK(Address::CanHoldStoreOffset(type, offset)); |
| 1320 | switch (type) { |
| 1321 | case kStoreByte: |
| 1322 | strb(reg, Address(base, offset), cond); |
| 1323 | break; |
| 1324 | case kStoreHalfword: |
| 1325 | strh(reg, Address(base, offset), cond); |
| 1326 | break; |
| 1327 | case kStoreWord: |
| 1328 | str(reg, Address(base, offset), cond); |
| 1329 | break; |
| 1330 | case kStoreWordPair: |
| 1331 | strd(reg, Address(base, offset), cond); |
| 1332 | break; |
| 1333 | default: |
| 1334 | LOG(FATAL) << "UNREACHABLE"; |
| 1335 | } |
| 1336 | } |
| 1337 | |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1338 | // Implementation note: this method must emit at most one instruction when |
| 1339 | // Address::CanHoldStoreOffset, as expected by JIT::GuardedStoreToOffset. |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1340 | void ArmAssembler::StoreSToOffset(SRegister reg, |
| 1341 | Register base, |
| 1342 | int32_t offset, |
| 1343 | Condition cond) { |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1344 | if (!Address::CanHoldStoreOffset(kStoreSWord, offset)) { |
| 1345 | CHECK_NE(base, IP); |
| 1346 | LoadImmediate(IP, offset, cond); |
| 1347 | add(IP, IP, ShifterOperand(base), cond); |
| 1348 | base = IP; |
| 1349 | offset = 0; |
| 1350 | } |
| 1351 | CHECK(Address::CanHoldStoreOffset(kStoreSWord, offset)); |
| 1352 | vstrs(reg, Address(base, offset), cond); |
| 1353 | } |
| 1354 | |
| 1355 | // Implementation note: this method must emit at most one instruction when |
| 1356 | // Address::CanHoldStoreOffset, as expected by JIT::GuardedStoreSToOffset. |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1357 | void ArmAssembler::StoreDToOffset(DRegister reg, |
| 1358 | Register base, |
| 1359 | int32_t offset, |
| 1360 | Condition cond) { |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1361 | if (!Address::CanHoldStoreOffset(kStoreDWord, offset)) { |
| 1362 | CHECK_NE(base, IP); |
| 1363 | LoadImmediate(IP, offset, cond); |
| 1364 | add(IP, IP, ShifterOperand(base), cond); |
| 1365 | base = IP; |
| 1366 | offset = 0; |
| 1367 | } |
| 1368 | CHECK(Address::CanHoldStoreOffset(kStoreDWord, offset)); |
| 1369 | vstrd(reg, Address(base, offset), cond); |
| 1370 | } |
| 1371 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1372 | void ArmAssembler::Push(Register rd, Condition cond) { |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1373 | str(rd, Address(SP, -kRegisterSize, Address::PreIndex), cond); |
| 1374 | } |
| 1375 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1376 | void ArmAssembler::Pop(Register rd, Condition cond) { |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1377 | ldr(rd, Address(SP, kRegisterSize, Address::PostIndex), cond); |
| 1378 | } |
| 1379 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1380 | void ArmAssembler::PushList(RegList regs, Condition cond) { |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1381 | stm(DB_W, SP, regs, cond); |
| 1382 | } |
| 1383 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1384 | void ArmAssembler::PopList(RegList regs, Condition cond) { |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1385 | ldm(IA_W, SP, regs, cond); |
| 1386 | } |
| 1387 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1388 | void ArmAssembler::Mov(Register rd, Register rm, Condition cond) { |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1389 | if (rd != rm) { |
| 1390 | mov(rd, ShifterOperand(rm), cond); |
| 1391 | } |
| 1392 | } |
| 1393 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1394 | void ArmAssembler::Lsl(Register rd, Register rm, uint32_t shift_imm, |
| 1395 | Condition cond) { |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1396 | CHECK_NE(shift_imm, 0u); // Do not use Lsl if no shift is wanted. |
| 1397 | mov(rd, ShifterOperand(rm, LSL, shift_imm), cond); |
| 1398 | } |
| 1399 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1400 | void ArmAssembler::Lsr(Register rd, Register rm, uint32_t shift_imm, |
| 1401 | Condition cond) { |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1402 | CHECK_NE(shift_imm, 0u); // Do not use Lsr if no shift is wanted. |
| 1403 | if (shift_imm == 32) shift_imm = 0; // Comply to UAL syntax. |
| 1404 | mov(rd, ShifterOperand(rm, LSR, shift_imm), cond); |
| 1405 | } |
| 1406 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1407 | void ArmAssembler::Asr(Register rd, Register rm, uint32_t shift_imm, |
| 1408 | Condition cond) { |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1409 | CHECK_NE(shift_imm, 0u); // Do not use Asr if no shift is wanted. |
| 1410 | if (shift_imm == 32) shift_imm = 0; // Comply to UAL syntax. |
| 1411 | mov(rd, ShifterOperand(rm, ASR, shift_imm), cond); |
| 1412 | } |
| 1413 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1414 | void ArmAssembler::Ror(Register rd, Register rm, uint32_t shift_imm, |
| 1415 | Condition cond) { |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1416 | CHECK_NE(shift_imm, 0u); // Use Rrx instruction. |
| 1417 | mov(rd, ShifterOperand(rm, ROR, shift_imm), cond); |
| 1418 | } |
| 1419 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1420 | void ArmAssembler::Rrx(Register rd, Register rm, Condition cond) { |
Carl Shapiro | 9b9ba28 | 2011-08-14 15:30:39 -0700 | [diff] [blame] | 1421 | mov(rd, ShifterOperand(rm, ROR, 0), cond); |
| 1422 | } |
| 1423 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1424 | void ArmAssembler::BuildFrame(size_t frame_size, ManagedRegister method_reg, |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1425 | const std::vector<ManagedRegister>& callee_save_regs) { |
Elliott Hughes | 06b37d9 | 2011-10-16 11:51:29 -0700 | [diff] [blame] | 1426 | CHECK_ALIGNED(frame_size, kStackAlignment); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1427 | CHECK_EQ(R0, method_reg.AsArm().AsCoreRegister()); |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1428 | |
| 1429 | // Push callee saves and link register |
| 1430 | RegList push_list = 1 << LR; |
| 1431 | size_t pushed_values = 1; |
| 1432 | for (size_t i = 0; i < callee_save_regs.size(); i++) { |
| 1433 | Register reg = callee_save_regs.at(i).AsArm().AsCoreRegister(); |
| 1434 | push_list |= 1 << reg; |
| 1435 | pushed_values++; |
Ian Rogers | 0d666d8 | 2011-08-14 16:03:46 -0700 | [diff] [blame] | 1436 | } |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1437 | PushList(push_list); |
| 1438 | |
| 1439 | // Increase frame to required size |
| 1440 | CHECK_GT(frame_size, pushed_values * kPointerSize); // Must be at least space to push Method* |
| 1441 | size_t adjust = frame_size - (pushed_values * kPointerSize); |
| 1442 | IncreaseFrameSize(adjust); |
| 1443 | |
| 1444 | // Write out Method* |
| 1445 | StoreToOffset(kStoreWord, R0, SP, 0); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1446 | } |
| 1447 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1448 | void ArmAssembler::RemoveFrame(size_t frame_size, |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1449 | const std::vector<ManagedRegister>& callee_save_regs) { |
Elliott Hughes | 06b37d9 | 2011-10-16 11:51:29 -0700 | [diff] [blame] | 1450 | CHECK_ALIGNED(frame_size, kStackAlignment); |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1451 | // Compute callee saves to pop and PC |
| 1452 | RegList pop_list = 1 << PC; |
| 1453 | size_t pop_values = 1; |
| 1454 | for (size_t i = 0; i < callee_save_regs.size(); i++) { |
| 1455 | Register reg = callee_save_regs.at(i).AsArm().AsCoreRegister(); |
| 1456 | pop_list |= 1 << reg; |
| 1457 | pop_values++; |
Ian Rogers | 0d666d8 | 2011-08-14 16:03:46 -0700 | [diff] [blame] | 1458 | } |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1459 | |
| 1460 | // Decrease frame to start of callee saves |
| 1461 | CHECK_GT(frame_size, pop_values * kPointerSize); |
| 1462 | size_t adjust = frame_size - (pop_values * kPointerSize); |
| 1463 | DecreaseFrameSize(adjust); |
| 1464 | |
| 1465 | // Pop callee saves and PC |
| 1466 | PopList(pop_list); |
Ian Rogers | 0d666d8 | 2011-08-14 16:03:46 -0700 | [diff] [blame] | 1467 | } |
| 1468 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1469 | void ArmAssembler::IncreaseFrameSize(size_t adjust) { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1470 | AddConstant(SP, -adjust); |
| 1471 | } |
| 1472 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1473 | void ArmAssembler::DecreaseFrameSize(size_t adjust) { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1474 | AddConstant(SP, adjust); |
| 1475 | } |
| 1476 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1477 | void ArmAssembler::Store(FrameOffset dest, ManagedRegister msrc, size_t size) { |
| 1478 | ArmManagedRegister src = msrc.AsArm(); |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1479 | if (src.IsNoRegister()) { |
| 1480 | CHECK_EQ(0u, size); |
| 1481 | } else if (src.IsCoreRegister()) { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1482 | CHECK_EQ(4u, size); |
| 1483 | StoreToOffset(kStoreWord, src.AsCoreRegister(), SP, dest.Int32Value()); |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1484 | } else if (src.IsRegisterPair()) { |
| 1485 | CHECK_EQ(8u, size); |
| 1486 | StoreToOffset(kStoreWord, src.AsRegisterPairLow(), SP, dest.Int32Value()); |
| 1487 | StoreToOffset(kStoreWord, src.AsRegisterPairHigh(), |
| 1488 | SP, dest.Int32Value() + 4); |
| 1489 | } else if (src.IsSRegister()) { |
| 1490 | StoreSToOffset(src.AsSRegister(), SP, dest.Int32Value()); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1491 | } else { |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1492 | CHECK(src.IsDRegister()); |
| 1493 | StoreDToOffset(src.AsDRegister(), SP, dest.Int32Value()); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1494 | } |
| 1495 | } |
| 1496 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1497 | void ArmAssembler::StoreRef(FrameOffset dest, ManagedRegister msrc) { |
| 1498 | ArmManagedRegister src = msrc.AsArm(); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1499 | CHECK(src.IsCoreRegister()); |
| 1500 | StoreToOffset(kStoreWord, src.AsCoreRegister(), SP, dest.Int32Value()); |
| 1501 | } |
| 1502 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1503 | void ArmAssembler::StoreRawPtr(FrameOffset dest, ManagedRegister msrc) { |
| 1504 | ArmManagedRegister src = msrc.AsArm(); |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 1505 | CHECK(src.IsCoreRegister()); |
| 1506 | StoreToOffset(kStoreWord, src.AsCoreRegister(), SP, dest.Int32Value()); |
| 1507 | } |
| 1508 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1509 | void ArmAssembler::StoreSpanning(FrameOffset dest, ManagedRegister msrc, |
| 1510 | FrameOffset in_off, ManagedRegister mscratch) { |
| 1511 | ArmManagedRegister src = msrc.AsArm(); |
| 1512 | ArmManagedRegister scratch = mscratch.AsArm(); |
Ian Rogers | 7a99c11 | 2011-09-07 12:48:27 -0700 | [diff] [blame] | 1513 | StoreToOffset(kStoreWord, src.AsCoreRegister(), SP, dest.Int32Value()); |
| 1514 | LoadFromOffset(kLoadWord, scratch.AsCoreRegister(), SP, in_off.Int32Value()); |
| 1515 | StoreToOffset(kStoreWord, scratch.AsCoreRegister(), SP, dest.Int32Value() + 4); |
| 1516 | } |
| 1517 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1518 | void ArmAssembler::CopyRef(FrameOffset dest, FrameOffset src, |
| 1519 | ManagedRegister mscratch) { |
| 1520 | ArmManagedRegister scratch = mscratch.AsArm(); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1521 | LoadFromOffset(kLoadWord, scratch.AsCoreRegister(), SP, src.Int32Value()); |
| 1522 | StoreToOffset(kStoreWord, scratch.AsCoreRegister(), SP, dest.Int32Value()); |
| 1523 | } |
| 1524 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1525 | void ArmAssembler::LoadRef(ManagedRegister mdest, ManagedRegister base, |
| 1526 | MemberOffset offs) { |
| 1527 | ArmManagedRegister dest = mdest.AsArm(); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1528 | CHECK(dest.IsCoreRegister() && dest.IsCoreRegister()); |
| 1529 | LoadFromOffset(kLoadWord, dest.AsCoreRegister(), |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1530 | base.AsArm().AsCoreRegister(), offs.Int32Value()); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1531 | } |
| 1532 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1533 | void ArmAssembler::LoadRef(ManagedRegister mdest, FrameOffset src) { |
| 1534 | ArmManagedRegister dest = mdest.AsArm(); |
Elliott Hughes | 362f9bc | 2011-10-17 18:56:41 -0700 | [diff] [blame] | 1535 | CHECK(dest.IsCoreRegister()); |
| 1536 | LoadFromOffset(kLoadWord, dest.AsCoreRegister(), SP, src.Int32Value()); |
| 1537 | } |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1538 | |
| 1539 | void ArmAssembler::LoadRawPtr(ManagedRegister mdest, ManagedRegister base, |
Ian Rogers | a04d397 | 2011-08-17 11:33:44 -0700 | [diff] [blame] | 1540 | Offset offs) { |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1541 | ArmManagedRegister dest = mdest.AsArm(); |
Ian Rogers | a04d397 | 2011-08-17 11:33:44 -0700 | [diff] [blame] | 1542 | CHECK(dest.IsCoreRegister() && dest.IsCoreRegister()); |
| 1543 | LoadFromOffset(kLoadWord, dest.AsCoreRegister(), |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1544 | base.AsArm().AsCoreRegister(), offs.Int32Value()); |
Ian Rogers | a04d397 | 2011-08-17 11:33:44 -0700 | [diff] [blame] | 1545 | } |
| 1546 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1547 | void ArmAssembler::StoreImmediateToFrame(FrameOffset dest, uint32_t imm, |
| 1548 | ManagedRegister mscratch) { |
| 1549 | ArmManagedRegister scratch = mscratch.AsArm(); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1550 | CHECK(scratch.IsCoreRegister()); |
| 1551 | LoadImmediate(scratch.AsCoreRegister(), imm); |
| 1552 | StoreToOffset(kStoreWord, scratch.AsCoreRegister(), SP, dest.Int32Value()); |
| 1553 | } |
| 1554 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1555 | void ArmAssembler::StoreImmediateToThread(ThreadOffset dest, uint32_t imm, |
| 1556 | ManagedRegister mscratch) { |
| 1557 | ArmManagedRegister scratch = mscratch.AsArm(); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1558 | CHECK(scratch.IsCoreRegister()); |
| 1559 | LoadImmediate(scratch.AsCoreRegister(), imm); |
| 1560 | StoreToOffset(kStoreWord, scratch.AsCoreRegister(), TR, dest.Int32Value()); |
| 1561 | } |
| 1562 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1563 | void ArmAssembler::Load(ManagedRegister mdest, FrameOffset src, size_t size) { |
| 1564 | ArmManagedRegister dest = mdest.AsArm(); |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1565 | if (dest.IsNoRegister()) { |
| 1566 | CHECK_EQ(0u, size); |
| 1567 | } else if (dest.IsCoreRegister()) { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1568 | CHECK_EQ(4u, size); |
| 1569 | LoadFromOffset(kLoadWord, dest.AsCoreRegister(), SP, src.Int32Value()); |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1570 | } else if (dest.IsRegisterPair()) { |
| 1571 | CHECK_EQ(8u, size); |
| 1572 | LoadFromOffset(kLoadWord, dest.AsRegisterPairLow(), SP, src.Int32Value()); |
Ian Rogers | 5a7a74a | 2011-09-26 16:32:29 -0700 | [diff] [blame] | 1573 | LoadFromOffset(kLoadWord, dest.AsRegisterPairHigh(), SP, src.Int32Value() + 4); |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1574 | } else if (dest.IsSRegister()) { |
| 1575 | LoadSFromOffset(dest.AsSRegister(), SP, src.Int32Value()); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1576 | } else { |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1577 | CHECK(dest.IsDRegister()); |
| 1578 | LoadDFromOffset(dest.AsDRegister(), SP, src.Int32Value()); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1579 | } |
| 1580 | } |
| 1581 | |
Ian Rogers | 5a7a74a | 2011-09-26 16:32:29 -0700 | [diff] [blame] | 1582 | void ArmAssembler::Load(ManagedRegister mdest, ThreadOffset src, size_t size) { |
| 1583 | ArmManagedRegister dest = mdest.AsArm(); |
| 1584 | if (dest.IsNoRegister()) { |
| 1585 | CHECK_EQ(0u, size); |
| 1586 | } else if (dest.IsCoreRegister()) { |
| 1587 | CHECK_EQ(4u, size); |
| 1588 | LoadFromOffset(kLoadWord, dest.AsCoreRegister(), TR, src.Int32Value()); |
| 1589 | } else if (dest.IsRegisterPair()) { |
| 1590 | CHECK_EQ(8u, size); |
| 1591 | LoadFromOffset(kLoadWord, dest.AsRegisterPairLow(), TR, src.Int32Value()); |
| 1592 | LoadFromOffset(kLoadWord, dest.AsRegisterPairHigh(), TR, src.Int32Value() + 4); |
| 1593 | } else if (dest.IsSRegister()) { |
| 1594 | LoadSFromOffset(dest.AsSRegister(), TR, src.Int32Value()); |
| 1595 | } else { |
| 1596 | CHECK(dest.IsDRegister()); |
| 1597 | LoadDFromOffset(dest.AsDRegister(), TR, src.Int32Value()); |
| 1598 | } |
| 1599 | } |
| 1600 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1601 | void ArmAssembler::LoadRawPtrFromThread(ManagedRegister mdest, |
| 1602 | ThreadOffset offs) { |
| 1603 | ArmManagedRegister dest = mdest.AsArm(); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1604 | CHECK(dest.IsCoreRegister()); |
| 1605 | LoadFromOffset(kLoadWord, dest.AsCoreRegister(), |
| 1606 | TR, offs.Int32Value()); |
| 1607 | } |
| 1608 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1609 | void ArmAssembler::CopyRawPtrFromThread(FrameOffset fr_offs, |
| 1610 | ThreadOffset thr_offs, |
| 1611 | ManagedRegister mscratch) { |
| 1612 | ArmManagedRegister scratch = mscratch.AsArm(); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1613 | CHECK(scratch.IsCoreRegister()); |
| 1614 | LoadFromOffset(kLoadWord, scratch.AsCoreRegister(), |
| 1615 | TR, thr_offs.Int32Value()); |
| 1616 | StoreToOffset(kStoreWord, scratch.AsCoreRegister(), |
| 1617 | SP, fr_offs.Int32Value()); |
| 1618 | } |
| 1619 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1620 | void ArmAssembler::CopyRawPtrToThread(ThreadOffset thr_offs, |
| 1621 | FrameOffset fr_offs, |
| 1622 | ManagedRegister mscratch) { |
| 1623 | ArmManagedRegister scratch = mscratch.AsArm(); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1624 | CHECK(scratch.IsCoreRegister()); |
| 1625 | LoadFromOffset(kLoadWord, scratch.AsCoreRegister(), |
| 1626 | SP, fr_offs.Int32Value()); |
| 1627 | StoreToOffset(kStoreWord, scratch.AsCoreRegister(), |
| 1628 | TR, thr_offs.Int32Value()); |
| 1629 | } |
| 1630 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1631 | void ArmAssembler::StoreStackOffsetToThread(ThreadOffset thr_offs, |
| 1632 | FrameOffset fr_offs, |
| 1633 | ManagedRegister mscratch) { |
| 1634 | ArmManagedRegister scratch = mscratch.AsArm(); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1635 | CHECK(scratch.IsCoreRegister()); |
| 1636 | AddConstant(scratch.AsCoreRegister(), SP, fr_offs.Int32Value(), AL); |
| 1637 | StoreToOffset(kStoreWord, scratch.AsCoreRegister(), |
| 1638 | TR, thr_offs.Int32Value()); |
| 1639 | } |
| 1640 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1641 | void ArmAssembler::StoreStackPointerToThread(ThreadOffset thr_offs) { |
Ian Rogers | 45a76cb | 2011-07-21 22:00:15 -0700 | [diff] [blame] | 1642 | StoreToOffset(kStoreWord, SP, TR, thr_offs.Int32Value()); |
| 1643 | } |
| 1644 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1645 | void ArmAssembler::Move(ManagedRegister mdest, ManagedRegister msrc) { |
| 1646 | ArmManagedRegister dest = mdest.AsArm(); |
| 1647 | ArmManagedRegister src = msrc.AsArm(); |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1648 | if (!dest.Equals(src)) { |
| 1649 | if (dest.IsCoreRegister()) { |
| 1650 | CHECK(src.IsCoreRegister()); |
| 1651 | mov(dest.AsCoreRegister(), ShifterOperand(src.AsCoreRegister())); |
Ian Rogers | 7a99c11 | 2011-09-07 12:48:27 -0700 | [diff] [blame] | 1652 | } else if (dest.IsDRegister()) { |
| 1653 | CHECK(src.IsDRegister()); |
| 1654 | vmovd(dest.AsDRegister(), src.AsDRegister()); |
| 1655 | } else if (dest.IsSRegister()) { |
| 1656 | CHECK(src.IsSRegister()); |
| 1657 | vmovs(dest.AsSRegister(), src.AsSRegister()); |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1658 | } else { |
Ian Rogers | 7a99c11 | 2011-09-07 12:48:27 -0700 | [diff] [blame] | 1659 | CHECK(dest.IsRegisterPair()); |
| 1660 | CHECK(src.IsRegisterPair()); |
| 1661 | // Ensure that the first move doesn't clobber the input of the second |
| 1662 | if (src.AsRegisterPairHigh() != dest.AsRegisterPairLow()) { |
| 1663 | mov(dest.AsRegisterPairLow(), ShifterOperand(src.AsRegisterPairLow())); |
| 1664 | mov(dest.AsRegisterPairHigh(), ShifterOperand(src.AsRegisterPairHigh())); |
| 1665 | } else { |
| 1666 | mov(dest.AsRegisterPairHigh(), ShifterOperand(src.AsRegisterPairHigh())); |
| 1667 | mov(dest.AsRegisterPairLow(), ShifterOperand(src.AsRegisterPairLow())); |
| 1668 | } |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1669 | } |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1670 | } |
| 1671 | } |
| 1672 | |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 1673 | void ArmAssembler::Copy(FrameOffset dest, FrameOffset src, ManagedRegister mscratch, size_t size) { |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1674 | ArmManagedRegister scratch = mscratch.AsArm(); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1675 | CHECK(scratch.IsCoreRegister()); |
Shih-wei Liao | 5381cf9 | 2011-07-27 00:28:04 -0700 | [diff] [blame] | 1676 | CHECK(size == 4 || size == 8); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1677 | if (size == 4) { |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 1678 | LoadFromOffset(kLoadWord, scratch.AsCoreRegister(), SP, src.Int32Value()); |
| 1679 | StoreToOffset(kStoreWord, scratch.AsCoreRegister(), SP, dest.Int32Value()); |
Shih-wei Liao | 5381cf9 | 2011-07-27 00:28:04 -0700 | [diff] [blame] | 1680 | } else if (size == 8) { |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 1681 | LoadFromOffset(kLoadWord, scratch.AsCoreRegister(), SP, src.Int32Value()); |
| 1682 | StoreToOffset(kStoreWord, scratch.AsCoreRegister(), SP, dest.Int32Value()); |
| 1683 | LoadFromOffset(kLoadWord, scratch.AsCoreRegister(), SP, src.Int32Value() + 4); |
| 1684 | StoreToOffset(kStoreWord, scratch.AsCoreRegister(), SP, dest.Int32Value() + 4); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1685 | } |
| 1686 | } |
| 1687 | |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 1688 | void ArmAssembler::Copy(FrameOffset dest, ManagedRegister src_base, Offset src_offset, |
| 1689 | ManagedRegister mscratch, size_t size) { |
| 1690 | Register scratch = mscratch.AsArm().AsCoreRegister(); |
| 1691 | CHECK_EQ(size, 4u); |
| 1692 | LoadFromOffset(kLoadWord, scratch, src_base.AsArm().AsCoreRegister(), src_offset.Int32Value()); |
| 1693 | StoreToOffset(kStoreWord, scratch, SP, dest.Int32Value()); |
| 1694 | } |
| 1695 | |
Ian Rogers | 5a7a74a | 2011-09-26 16:32:29 -0700 | [diff] [blame] | 1696 | void ArmAssembler::Copy(ManagedRegister dest_base, Offset dest_offset, FrameOffset src, |
| 1697 | ManagedRegister mscratch, size_t size) { |
| 1698 | Register scratch = mscratch.AsArm().AsCoreRegister(); |
| 1699 | CHECK_EQ(size, 4u); |
| 1700 | LoadFromOffset(kLoadWord, scratch, SP, src.Int32Value()); |
| 1701 | StoreToOffset(kStoreWord, scratch, dest_base.AsArm().AsCoreRegister(), dest_offset.Int32Value()); |
| 1702 | } |
| 1703 | |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 1704 | void ArmAssembler::Copy(FrameOffset dest, FrameOffset src_base, Offset src_offset, |
| 1705 | ManagedRegister mscratch, size_t size) { |
| 1706 | UNIMPLEMENTED(FATAL); |
| 1707 | } |
| 1708 | |
Ian Rogers | 5a7a74a | 2011-09-26 16:32:29 -0700 | [diff] [blame] | 1709 | void ArmAssembler::Copy(ManagedRegister dest, Offset dest_offset, |
| 1710 | ManagedRegister src, Offset src_offset, |
| 1711 | ManagedRegister mscratch, size_t size) { |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 1712 | CHECK_EQ(size, 4u); |
Ian Rogers | 5a7a74a | 2011-09-26 16:32:29 -0700 | [diff] [blame] | 1713 | Register scratch = mscratch.AsArm().AsCoreRegister(); |
| 1714 | LoadFromOffset(kLoadWord, scratch, src.AsArm().AsCoreRegister(), src_offset.Int32Value()); |
| 1715 | StoreToOffset(kStoreWord, scratch, dest.AsArm().AsCoreRegister(), dest_offset.Int32Value()); |
| 1716 | } |
| 1717 | |
| 1718 | void ArmAssembler::Copy(FrameOffset dest, Offset dest_offset, FrameOffset src, Offset src_offset, |
| 1719 | ManagedRegister scratch, size_t size) { |
| 1720 | UNIMPLEMENTED(FATAL); |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 1721 | } |
| 1722 | |
| 1723 | |
Ian Rogers | e5de95b | 2011-09-18 20:31:38 -0700 | [diff] [blame] | 1724 | void ArmAssembler::MemoryBarrier(ManagedRegister mscratch) { |
| 1725 | #if ANDROID_SMP != 0 |
| 1726 | #if defined(__ARM_HAVE_DMB) |
| 1727 | int32_t encoding = 0xf57ff05f; // dmb |
| 1728 | Emit(encoding); |
| 1729 | #elif defined(__ARM_HAVE_LDREX_STREX) |
| 1730 | CHECK(mscratch.AsArm().AsCoreRegister() == R12); |
| 1731 | LoadImmediate(R12, 0); |
| 1732 | int32_t encoding = 0xee07cfba; // mcr p15, 0, r12, c7, c10, 5 |
| 1733 | Emit(encoding); |
| 1734 | #else |
| 1735 | CHECK(mscratch.AsArm().AsCoreRegister() == R12); |
| 1736 | LoadImmediate(R12, 0xffff0fa0); // kuser_memory_barrier |
| 1737 | blx(R12); |
| 1738 | #endif |
| 1739 | #endif |
| 1740 | } |
| 1741 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1742 | void ArmAssembler::CreateSirtEntry(ManagedRegister mout_reg, |
| 1743 | FrameOffset sirt_offset, |
| 1744 | ManagedRegister min_reg, bool null_allowed) { |
| 1745 | ArmManagedRegister out_reg = mout_reg.AsArm(); |
| 1746 | ArmManagedRegister in_reg = min_reg.AsArm(); |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1747 | CHECK(in_reg.IsNoRegister() || in_reg.IsCoreRegister()); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1748 | CHECK(out_reg.IsCoreRegister()); |
| 1749 | if (null_allowed) { |
Ian Rogers | 408f79a | 2011-08-23 18:22:33 -0700 | [diff] [blame] | 1750 | // Null values get a SIRT entry value of 0. Otherwise, the SIRT entry is |
| 1751 | // the address in the SIRT holding the reference. |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1752 | // e.g. out_reg = (handle == 0) ? 0 : (SP+handle_offset) |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1753 | if (in_reg.IsNoRegister()) { |
| 1754 | LoadFromOffset(kLoadWord, out_reg.AsCoreRegister(), |
Ian Rogers | 408f79a | 2011-08-23 18:22:33 -0700 | [diff] [blame] | 1755 | SP, sirt_offset.Int32Value()); |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1756 | in_reg = out_reg; |
| 1757 | } |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1758 | cmp(in_reg.AsCoreRegister(), ShifterOperand(0)); |
| 1759 | if (!out_reg.Equals(in_reg)) { |
| 1760 | LoadImmediate(out_reg.AsCoreRegister(), 0, EQ); |
| 1761 | } |
Ian Rogers | 408f79a | 2011-08-23 18:22:33 -0700 | [diff] [blame] | 1762 | AddConstant(out_reg.AsCoreRegister(), SP, sirt_offset.Int32Value(), NE); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1763 | } else { |
Ian Rogers | 408f79a | 2011-08-23 18:22:33 -0700 | [diff] [blame] | 1764 | AddConstant(out_reg.AsCoreRegister(), SP, sirt_offset.Int32Value(), AL); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1765 | } |
| 1766 | } |
| 1767 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1768 | void ArmAssembler::CreateSirtEntry(FrameOffset out_off, |
| 1769 | FrameOffset sirt_offset, |
| 1770 | ManagedRegister mscratch, |
| 1771 | bool null_allowed) { |
| 1772 | ArmManagedRegister scratch = mscratch.AsArm(); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1773 | CHECK(scratch.IsCoreRegister()); |
| 1774 | if (null_allowed) { |
| 1775 | LoadFromOffset(kLoadWord, scratch.AsCoreRegister(), SP, |
Ian Rogers | 408f79a | 2011-08-23 18:22:33 -0700 | [diff] [blame] | 1776 | sirt_offset.Int32Value()); |
| 1777 | // Null values get a SIRT entry value of 0. Otherwise, the sirt entry is |
| 1778 | // the address in the SIRT holding the reference. |
| 1779 | // e.g. scratch = (scratch == 0) ? 0 : (SP+sirt_offset) |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1780 | cmp(scratch.AsCoreRegister(), ShifterOperand(0)); |
Ian Rogers | 408f79a | 2011-08-23 18:22:33 -0700 | [diff] [blame] | 1781 | AddConstant(scratch.AsCoreRegister(), SP, sirt_offset.Int32Value(), NE); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1782 | } else { |
Ian Rogers | 408f79a | 2011-08-23 18:22:33 -0700 | [diff] [blame] | 1783 | AddConstant(scratch.AsCoreRegister(), SP, sirt_offset.Int32Value(), AL); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1784 | } |
| 1785 | StoreToOffset(kStoreWord, scratch.AsCoreRegister(), SP, out_off.Int32Value()); |
| 1786 | } |
| 1787 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1788 | void ArmAssembler::LoadReferenceFromSirt(ManagedRegister mout_reg, |
| 1789 | ManagedRegister min_reg) { |
| 1790 | ArmManagedRegister out_reg = mout_reg.AsArm(); |
| 1791 | ArmManagedRegister in_reg = min_reg.AsArm(); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1792 | CHECK(out_reg.IsCoreRegister()); |
| 1793 | CHECK(in_reg.IsCoreRegister()); |
| 1794 | Label null_arg; |
| 1795 | if (!out_reg.Equals(in_reg)) { |
| 1796 | LoadImmediate(out_reg.AsCoreRegister(), 0, EQ); |
| 1797 | } |
| 1798 | cmp(in_reg.AsCoreRegister(), ShifterOperand(0)); |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame] | 1799 | LoadFromOffset(kLoadWord, out_reg.AsCoreRegister(), |
| 1800 | in_reg.AsCoreRegister(), 0, NE); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1801 | } |
| 1802 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1803 | void ArmAssembler::VerifyObject(ManagedRegister src, bool could_be_null) { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1804 | // TODO: not validating references |
| 1805 | } |
| 1806 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1807 | void ArmAssembler::VerifyObject(FrameOffset src, bool could_be_null) { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1808 | // TODO: not validating references |
| 1809 | } |
| 1810 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1811 | void ArmAssembler::Call(ManagedRegister mbase, Offset offset, |
| 1812 | ManagedRegister mscratch) { |
| 1813 | ArmManagedRegister base = mbase.AsArm(); |
| 1814 | ArmManagedRegister scratch = mscratch.AsArm(); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1815 | CHECK(base.IsCoreRegister()); |
| 1816 | CHECK(scratch.IsCoreRegister()); |
| 1817 | LoadFromOffset(kLoadWord, scratch.AsCoreRegister(), |
| 1818 | base.AsCoreRegister(), offset.Int32Value()); |
| 1819 | blx(scratch.AsCoreRegister()); |
| 1820 | // TODO: place reference map on call |
| 1821 | } |
| 1822 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1823 | void ArmAssembler::Call(FrameOffset base, Offset offset, |
| 1824 | ManagedRegister mscratch) { |
| 1825 | ArmManagedRegister scratch = mscratch.AsArm(); |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1826 | CHECK(scratch.IsCoreRegister()); |
| 1827 | // Call *(*(SP + base) + offset) |
| 1828 | LoadFromOffset(kLoadWord, scratch.AsCoreRegister(), |
| 1829 | SP, base.Int32Value()); |
| 1830 | LoadFromOffset(kLoadWord, scratch.AsCoreRegister(), |
| 1831 | scratch.AsCoreRegister(), offset.Int32Value()); |
| 1832 | blx(scratch.AsCoreRegister()); |
| 1833 | // TODO: place reference map on call |
| 1834 | } |
| 1835 | |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1836 | void ArmAssembler::Call(ThreadOffset offset, ManagedRegister scratch) { |
| 1837 | UNIMPLEMENTED(FATAL); |
| 1838 | } |
| 1839 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1840 | void ArmAssembler::GetCurrentThread(ManagedRegister tr) { |
| 1841 | mov(tr.AsArm().AsCoreRegister(), ShifterOperand(TR)); |
Shih-wei Liao | 668512a | 2011-09-01 14:18:34 -0700 | [diff] [blame] | 1842 | } |
| 1843 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1844 | void ArmAssembler::GetCurrentThread(FrameOffset offset, |
| 1845 | ManagedRegister scratch) { |
Shih-wei Liao | 668512a | 2011-09-01 14:18:34 -0700 | [diff] [blame] | 1846 | StoreToOffset(kStoreWord, TR, SP, offset.Int32Value(), AL); |
| 1847 | } |
| 1848 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1849 | void ArmAssembler::SuspendPoll(ManagedRegister mscratch, |
| 1850 | ManagedRegister return_reg, |
| 1851 | FrameOffset return_save_location, |
| 1852 | size_t return_size) { |
| 1853 | ArmManagedRegister scratch = mscratch.AsArm(); |
| 1854 | ArmSuspendCountSlowPath* slow = |
| 1855 | new ArmSuspendCountSlowPath(return_reg.AsArm(), return_save_location, |
| 1856 | return_size); |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1857 | buffer_.EnqueueSlowPath(slow); |
| 1858 | LoadFromOffset(kLoadWord, scratch.AsCoreRegister(), |
| 1859 | TR, Thread::SuspendCountOffset().Int32Value()); |
| 1860 | cmp(scratch.AsCoreRegister(), ShifterOperand(0)); |
| 1861 | b(slow->Entry(), NE); |
| 1862 | Bind(slow->Continuation()); |
| 1863 | } |
| 1864 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1865 | void ArmSuspendCountSlowPath::Emit(Assembler* sasm) { |
| 1866 | ArmAssembler* sp_asm = down_cast<ArmAssembler*>(sasm); |
| 1867 | #define __ sp_asm-> |
| 1868 | __ Bind(&entry_); |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1869 | // Save return value |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1870 | __ Store(return_save_location_, return_register_, return_size_); |
Ian Rogers | e5de95b | 2011-09-18 20:31:38 -0700 | [diff] [blame] | 1871 | // Pass thread as argument |
| 1872 | __ mov(R0, ShifterOperand(TR)); |
| 1873 | __ LoadFromOffset(kLoadWord, R12, TR, OFFSETOF_MEMBER(Thread, pCheckSuspendFromCode)); |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1874 | // Note: assume that link register will be spilled/filled on method entry/exit |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1875 | __ blx(R12); |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1876 | // Reload return value |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1877 | __ Load(return_register_, return_save_location_, return_size_); |
| 1878 | __ b(&continuation_); |
| 1879 | #undef __ |
Ian Rogers | 45a76cb | 2011-07-21 22:00:15 -0700 | [diff] [blame] | 1880 | } |
| 1881 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1882 | void ArmAssembler::ExceptionPoll(ManagedRegister mscratch) { |
| 1883 | ArmManagedRegister scratch = mscratch.AsArm(); |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1884 | ArmExceptionSlowPath* slow = new ArmExceptionSlowPath(scratch); |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1885 | buffer_.EnqueueSlowPath(slow); |
| 1886 | LoadFromOffset(kLoadWord, scratch.AsCoreRegister(), |
| 1887 | TR, Thread::ExceptionOffset().Int32Value()); |
| 1888 | cmp(scratch.AsCoreRegister(), ShifterOperand(0)); |
| 1889 | b(slow->Entry(), NE); |
Carl Shapiro | e2d373e | 2011-07-25 15:20:06 -0700 | [diff] [blame] | 1890 | } |
| 1891 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1892 | void ArmExceptionSlowPath::Emit(Assembler* sasm) { |
| 1893 | ArmAssembler* sp_asm = down_cast<ArmAssembler*>(sasm); |
| 1894 | #define __ sp_asm-> |
| 1895 | __ Bind(&entry_); |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1896 | |
| 1897 | // Pass exception object as argument |
| 1898 | // Don't care about preserving R0 as this call won't return |
| 1899 | __ mov(R0, ShifterOperand(scratch_.AsCoreRegister())); |
| 1900 | // Set up call to Thread::Current()->pDeliverException |
| 1901 | __ LoadFromOffset(kLoadWord, R12, TR, OFFSETOF_MEMBER(Thread, pDeliverException)); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1902 | __ blx(R12); |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1903 | // Call never returns |
| 1904 | __ bkpt(0); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1905 | #undef __ |
Ian Rogers | 45a76cb | 2011-07-21 22:00:15 -0700 | [diff] [blame] | 1906 | } |
| 1907 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 1908 | } // namespace arm |
Carl Shapiro | 6b6b5f0 | 2011-06-21 15:05:09 -0700 | [diff] [blame] | 1909 | } // namespace art |