Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 16 | |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 17 | #ifndef ART_COMPILER_UTILS_ARM_ASSEMBLER_ARM_H_ |
| 18 | #define ART_COMPILER_UTILS_ARM_ASSEMBLER_ARM_H_ |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 19 | |
Vladimir Marko | cf93a5c | 2015-06-16 11:33:24 +0000 | [diff] [blame] | 20 | #include <type_traits> |
Elliott Hughes | 07ed66b | 2012-12-12 18:34:25 -0800 | [diff] [blame] | 21 | #include <vector> |
| 22 | |
Vladimir Marko | 80afd02 | 2015-05-19 18:08:00 +0100 | [diff] [blame] | 23 | #include "base/bit_utils.h" |
Elliott Hughes | 07ed66b | 2012-12-12 18:34:25 -0800 | [diff] [blame] | 24 | #include "base/logging.h" |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 25 | #include "base/value_object.h" |
Elliott Hughes | 0f3c553 | 2012-03-30 14:51:51 -0700 | [diff] [blame] | 26 | #include "constants_arm.h" |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 27 | #include "utils/arm/managed_register_arm.h" |
| 28 | #include "utils/assembler.h" |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 29 | #include "offsets.h" |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 30 | |
Carl Shapiro | 6b6b5f0 | 2011-06-21 15:05:09 -0700 | [diff] [blame] | 31 | namespace art { |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 32 | namespace arm { |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 33 | |
Nicolas Geoffray | 3bcc8ea | 2014-11-28 15:00:02 +0000 | [diff] [blame] | 34 | class Arm32Assembler; |
| 35 | class Thumb2Assembler; |
| 36 | |
Vladimir Marko | cf93a5c | 2015-06-16 11:33:24 +0000 | [diff] [blame] | 37 | // Assembler literal is a value embedded in code, retrieved using a PC-relative load. |
| 38 | class Literal { |
Nicolas Geoffray | d56376c | 2015-05-21 12:32:34 +0000 | [diff] [blame] | 39 | public: |
Vladimir Marko | cf93a5c | 2015-06-16 11:33:24 +0000 | [diff] [blame] | 40 | static constexpr size_t kMaxSize = 8; |
| 41 | |
| 42 | Literal(uint32_t size, const uint8_t* data) |
| 43 | : label_(), size_(size) { |
| 44 | DCHECK_LE(size, Literal::kMaxSize); |
| 45 | memcpy(data_, data, size); |
| 46 | } |
| 47 | |
| 48 | template <typename T> |
| 49 | T GetValue() const { |
| 50 | DCHECK_EQ(size_, sizeof(T)); |
| 51 | T value; |
| 52 | memcpy(&value, data_, sizeof(T)); |
| 53 | return value; |
| 54 | } |
| 55 | |
| 56 | uint32_t GetSize() const { |
| 57 | return size_; |
| 58 | } |
| 59 | |
| 60 | const uint8_t* GetData() const { |
| 61 | return data_; |
| 62 | } |
| 63 | |
| 64 | Label* GetLabel() { |
| 65 | return &label_; |
| 66 | } |
| 67 | |
| 68 | const Label* GetLabel() const { |
| 69 | return &label_; |
| 70 | } |
Nicolas Geoffray | d56376c | 2015-05-21 12:32:34 +0000 | [diff] [blame] | 71 | |
| 72 | private: |
Vladimir Marko | cf93a5c | 2015-06-16 11:33:24 +0000 | [diff] [blame] | 73 | Label label_; |
| 74 | const uint32_t size_; |
| 75 | uint8_t data_[kMaxSize]; |
| 76 | |
| 77 | DISALLOW_COPY_AND_ASSIGN(Literal); |
Nicolas Geoffray | d56376c | 2015-05-21 12:32:34 +0000 | [diff] [blame] | 78 | }; |
| 79 | |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 80 | class ShifterOperand { |
| 81 | public: |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 82 | ShifterOperand() : type_(kUnknown), rm_(kNoRegister), rs_(kNoRegister), |
| 83 | is_rotate_(false), is_shift_(false), shift_(kNoShift), rotate_(0), immed_(0) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 84 | } |
| 85 | |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 86 | explicit ShifterOperand(uint32_t immed); |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 87 | |
| 88 | // Data-processing operands - Register |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 89 | explicit ShifterOperand(Register rm) : type_(kRegister), rm_(rm), rs_(kNoRegister), |
| 90 | is_rotate_(false), is_shift_(false), shift_(kNoShift), rotate_(0), immed_(0) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 91 | } |
| 92 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 93 | ShifterOperand(uint32_t rotate, uint32_t immed8) : type_(kImmediate), rm_(kNoRegister), |
| 94 | rs_(kNoRegister), |
| 95 | is_rotate_(true), is_shift_(false), shift_(kNoShift), rotate_(rotate), immed_(immed8) { |
| 96 | } |
| 97 | |
| 98 | ShifterOperand(Register rm, Shift shift, uint32_t shift_imm = 0) : type_(kRegister), rm_(rm), |
| 99 | rs_(kNoRegister), |
| 100 | is_rotate_(false), is_shift_(true), shift_(shift), rotate_(0), immed_(shift_imm) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | // Data-processing operands - Logical shift/rotate by register |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 104 | ShifterOperand(Register rm, Shift shift, Register rs) : type_(kRegister), rm_(rm), |
| 105 | rs_(rs), |
| 106 | is_rotate_(false), is_shift_(true), shift_(shift), rotate_(0), immed_(0) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 107 | } |
| 108 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 109 | bool is_valid() const { return (type_ == kImmediate) || (type_ == kRegister); } |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 110 | |
| 111 | uint32_t type() const { |
| 112 | CHECK(is_valid()); |
| 113 | return type_; |
| 114 | } |
| 115 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 116 | uint32_t encodingArm() const; |
Dave Allison | 45fdb93 | 2014-06-25 12:37:10 -0700 | [diff] [blame] | 117 | uint32_t encodingThumb() const; |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 118 | |
| 119 | bool IsEmpty() const { |
| 120 | return type_ == kUnknown; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 121 | } |
| 122 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 123 | bool IsImmediate() const { |
| 124 | return type_ == kImmediate; |
| 125 | } |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 126 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 127 | bool IsRegister() const { |
| 128 | return type_ == kRegister; |
| 129 | } |
| 130 | |
| 131 | bool IsShift() const { |
| 132 | return is_shift_; |
| 133 | } |
| 134 | |
| 135 | uint32_t GetImmediate() const { |
| 136 | return immed_; |
| 137 | } |
| 138 | |
| 139 | Shift GetShift() const { |
| 140 | return shift_; |
| 141 | } |
| 142 | |
| 143 | Register GetRegister() const { |
| 144 | return rm_; |
| 145 | } |
| 146 | |
Guillaume "Vermeille" Sanchez | ab4a2f5 | 2015-03-11 14:00:30 +0000 | [diff] [blame] | 147 | Register GetSecondRegister() const { |
| 148 | return rs_; |
| 149 | } |
| 150 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 151 | enum Type { |
| 152 | kUnknown = -1, |
| 153 | kRegister, |
| 154 | kImmediate |
| 155 | }; |
| 156 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 157 | private: |
| 158 | Type type_; |
| 159 | Register rm_; |
| 160 | Register rs_; |
| 161 | bool is_rotate_; |
| 162 | bool is_shift_; |
| 163 | Shift shift_; |
| 164 | uint32_t rotate_; |
| 165 | uint32_t immed_; |
| 166 | |
Nicolas Geoffray | 3bcc8ea | 2014-11-28 15:00:02 +0000 | [diff] [blame] | 167 | friend class Arm32Assembler; |
| 168 | friend class Thumb2Assembler; |
| 169 | |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 170 | #ifdef SOURCE_ASSEMBLER_SUPPORT |
| 171 | friend class BinaryAssembler; |
| 172 | #endif |
| 173 | }; |
| 174 | |
| 175 | |
| 176 | enum LoadOperandType { |
| 177 | kLoadSignedByte, |
| 178 | kLoadUnsignedByte, |
| 179 | kLoadSignedHalfword, |
| 180 | kLoadUnsignedHalfword, |
| 181 | kLoadWord, |
| 182 | kLoadWordPair, |
| 183 | kLoadSWord, |
| 184 | kLoadDWord |
| 185 | }; |
| 186 | |
| 187 | |
| 188 | enum StoreOperandType { |
| 189 | kStoreByte, |
| 190 | kStoreHalfword, |
| 191 | kStoreWord, |
| 192 | kStoreWordPair, |
| 193 | kStoreSWord, |
| 194 | kStoreDWord |
| 195 | }; |
| 196 | |
| 197 | |
| 198 | // Load/store multiple addressing mode. |
| 199 | enum BlockAddressMode { |
| 200 | // bit encoding P U W |
| 201 | DA = (0|0|0) << 21, // decrement after |
| 202 | IA = (0|4|0) << 21, // increment after |
| 203 | DB = (8|0|0) << 21, // decrement before |
| 204 | IB = (8|4|0) << 21, // increment before |
| 205 | DA_W = (0|0|1) << 21, // decrement after with writeback to base |
| 206 | IA_W = (0|4|1) << 21, // increment after with writeback to base |
| 207 | DB_W = (8|0|1) << 21, // decrement before with writeback to base |
| 208 | IB_W = (8|4|1) << 21 // increment before with writeback to base |
| 209 | }; |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 210 | inline std::ostream& operator<<(std::ostream& os, const BlockAddressMode& rhs) { |
| 211 | os << static_cast<int>(rhs); |
| 212 | return os; |
| 213 | } |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 214 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 215 | class Address : public ValueObject { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 216 | public: |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 217 | // Memory operand addressing mode (in ARM encoding form. For others we need |
| 218 | // to adjust) |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 219 | enum Mode { |
| 220 | // bit encoding P U W |
| 221 | Offset = (8|4|0) << 21, // offset (w/o writeback to base) |
| 222 | PreIndex = (8|4|1) << 21, // pre-indexed addressing with writeback |
| 223 | PostIndex = (0|4|0) << 21, // post-indexed addressing with writeback |
| 224 | NegOffset = (8|0|0) << 21, // negative offset (w/o writeback to base) |
| 225 | NegPreIndex = (8|0|1) << 21, // negative pre-indexed with writeback |
| 226 | NegPostIndex = (0|0|0) << 21 // negative post-indexed with writeback |
| 227 | }; |
| 228 | |
Dave Allison | 45fdb93 | 2014-06-25 12:37:10 -0700 | [diff] [blame] | 229 | Address(Register rn, int32_t offset = 0, Mode am = Offset) : rn_(rn), rm_(R0), |
| 230 | offset_(offset), |
| 231 | am_(am), is_immed_offset_(true), shift_(LSL) { |
| 232 | } |
| 233 | |
| 234 | Address(Register rn, Register rm, Mode am = Offset) : rn_(rn), rm_(rm), offset_(0), |
| 235 | am_(am), is_immed_offset_(false), shift_(LSL) { |
| 236 | CHECK_NE(rm, PC); |
| 237 | } |
| 238 | |
| 239 | Address(Register rn, Register rm, Shift shift, uint32_t count, Mode am = Offset) : |
| 240 | rn_(rn), rm_(rm), offset_(count), |
| 241 | am_(am), is_immed_offset_(false), shift_(shift) { |
| 242 | CHECK_NE(rm, PC); |
| 243 | } |
| 244 | |
| 245 | // LDR(literal) - pc relative load. |
| 246 | explicit Address(int32_t offset) : |
| 247 | rn_(PC), rm_(R0), offset_(offset), |
| 248 | am_(Offset), is_immed_offset_(false), shift_(LSL) { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 249 | } |
| 250 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 251 | static bool CanHoldLoadOffsetArm(LoadOperandType type, int offset); |
| 252 | static bool CanHoldStoreOffsetArm(StoreOperandType type, int offset); |
| 253 | |
| 254 | static bool CanHoldLoadOffsetThumb(LoadOperandType type, int offset); |
| 255 | static bool CanHoldStoreOffsetThumb(StoreOperandType type, int offset); |
| 256 | |
| 257 | uint32_t encodingArm() const; |
Dave Allison | 45fdb93 | 2014-06-25 12:37:10 -0700 | [diff] [blame] | 258 | uint32_t encodingThumb(bool is_32bit) const; |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 259 | |
| 260 | uint32_t encoding3() const; |
| 261 | uint32_t vencoding() const; |
| 262 | |
| 263 | uint32_t encodingThumbLdrdStrd() const; |
| 264 | |
| 265 | Register GetRegister() const { |
| 266 | return rn_; |
| 267 | } |
| 268 | |
Dave Allison | 45fdb93 | 2014-06-25 12:37:10 -0700 | [diff] [blame] | 269 | Register GetRegisterOffset() const { |
| 270 | return rm_; |
| 271 | } |
| 272 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 273 | int32_t GetOffset() const { |
| 274 | return offset_; |
| 275 | } |
| 276 | |
| 277 | Mode GetMode() const { |
| 278 | return am_; |
| 279 | } |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 280 | |
Dave Allison | 45fdb93 | 2014-06-25 12:37:10 -0700 | [diff] [blame] | 281 | bool IsImmediate() const { |
| 282 | return is_immed_offset_; |
| 283 | } |
| 284 | |
| 285 | Shift GetShift() const { |
| 286 | return shift_; |
| 287 | } |
| 288 | |
| 289 | int32_t GetShiftCount() const { |
| 290 | CHECK(!is_immed_offset_); |
| 291 | return offset_; |
| 292 | } |
| 293 | |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 294 | private: |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 295 | const Register rn_; |
| 296 | const Register rm_; |
| 297 | const int32_t offset_; // Used as shift amount for register offset. |
| 298 | const Mode am_; |
| 299 | const bool is_immed_offset_; |
| 300 | const Shift shift_; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 301 | }; |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 302 | inline std::ostream& operator<<(std::ostream& os, const Address::Mode& rhs) { |
| 303 | os << static_cast<int>(rhs); |
| 304 | return os; |
| 305 | } |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 306 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 307 | // Instruction encoding bits. |
| 308 | enum { |
| 309 | H = 1 << 5, // halfword (or byte) |
| 310 | L = 1 << 20, // load (or store) |
| 311 | S = 1 << 20, // set condition code (or leave unchanged) |
| 312 | W = 1 << 21, // writeback base register (or leave unchanged) |
| 313 | A = 1 << 21, // accumulate in multiply instruction (or not) |
| 314 | B = 1 << 22, // unsigned byte (or word) |
| 315 | N = 1 << 22, // long (or short) |
| 316 | U = 1 << 23, // positive (or negative) offset/index |
| 317 | P = 1 << 24, // offset/pre-indexed addressing (or post-indexed addressing) |
| 318 | I = 1 << 25, // immediate shifter operand (or not) |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 319 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 320 | B0 = 1, |
| 321 | B1 = 1 << 1, |
| 322 | B2 = 1 << 2, |
| 323 | B3 = 1 << 3, |
| 324 | B4 = 1 << 4, |
| 325 | B5 = 1 << 5, |
| 326 | B6 = 1 << 6, |
| 327 | B7 = 1 << 7, |
| 328 | B8 = 1 << 8, |
| 329 | B9 = 1 << 9, |
| 330 | B10 = 1 << 10, |
| 331 | B11 = 1 << 11, |
| 332 | B12 = 1 << 12, |
| 333 | B13 = 1 << 13, |
| 334 | B14 = 1 << 14, |
| 335 | B15 = 1 << 15, |
| 336 | B16 = 1 << 16, |
| 337 | B17 = 1 << 17, |
| 338 | B18 = 1 << 18, |
| 339 | B19 = 1 << 19, |
| 340 | B20 = 1 << 20, |
| 341 | B21 = 1 << 21, |
| 342 | B22 = 1 << 22, |
| 343 | B23 = 1 << 23, |
| 344 | B24 = 1 << 24, |
| 345 | B25 = 1 << 25, |
| 346 | B26 = 1 << 26, |
| 347 | B27 = 1 << 27, |
| 348 | B28 = 1 << 28, |
| 349 | B29 = 1 << 29, |
| 350 | B30 = 1 << 30, |
| 351 | B31 = 1 << 31, |
| 352 | |
| 353 | // Instruction bit masks. |
| 354 | RdMask = 15 << 12, // in str instruction |
| 355 | CondMask = 15 << 28, |
| 356 | CoprocessorMask = 15 << 8, |
| 357 | OpCodeMask = 15 << 21, // in data-processing instructions |
| 358 | Imm24Mask = (1 << 24) - 1, |
| 359 | Off12Mask = (1 << 12) - 1, |
| 360 | |
| 361 | // ldrex/strex register field encodings. |
| 362 | kLdExRnShift = 16, |
| 363 | kLdExRtShift = 12, |
| 364 | kStrExRnShift = 16, |
| 365 | kStrExRdShift = 12, |
| 366 | kStrExRtShift = 0, |
| 367 | }; |
| 368 | |
| 369 | // IfThen state for IT instructions. |
| 370 | enum ItState { |
| 371 | kItOmitted, |
| 372 | kItThen, |
| 373 | kItT = kItThen, |
| 374 | kItElse, |
| 375 | kItE = kItElse |
| 376 | }; |
| 377 | |
| 378 | constexpr uint32_t kNoItCondition = 3; |
| 379 | constexpr uint32_t kInvalidModifiedImmediate = -1; |
| 380 | |
| 381 | extern const char* kRegisterNames[]; |
| 382 | extern const char* kConditionNames[]; |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 383 | |
| 384 | // This is an abstract ARM assembler. Subclasses provide assemblers for the individual |
| 385 | // instruction sets (ARM32, Thumb2, etc.) |
| 386 | // |
| 387 | class ArmAssembler : public Assembler { |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 388 | public: |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 389 | virtual ~ArmAssembler() {} |
buzbee | c143c55 | 2011-08-20 17:38:58 -0700 | [diff] [blame] | 390 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 391 | // Is this assembler for the thumb instruction set? |
| 392 | virtual bool IsThumb() const = 0; |
| 393 | |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 394 | // Data-processing instructions. |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 395 | virtual void and_(Register rd, Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 396 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 397 | virtual void eor(Register rd, Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 398 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 399 | virtual void sub(Register rd, Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
| 400 | virtual void subs(Register rd, Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 401 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 402 | virtual void rsb(Register rd, Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
| 403 | virtual void rsbs(Register rd, Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 404 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 405 | virtual void add(Register rd, Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 406 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 407 | virtual void adds(Register rd, Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 408 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 409 | virtual void adc(Register rd, Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 410 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 411 | virtual void sbc(Register rd, Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 412 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 413 | virtual void rsc(Register rd, Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 414 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 415 | virtual void tst(Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 416 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 417 | virtual void teq(Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 418 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 419 | virtual void cmp(Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 420 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 421 | virtual void cmn(Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 422 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 423 | virtual void orr(Register rd, Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
| 424 | virtual void orrs(Register rd, Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 425 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 426 | virtual void mov(Register rd, const ShifterOperand& so, Condition cond = AL) = 0; |
| 427 | virtual void movs(Register rd, const ShifterOperand& so, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 428 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 429 | virtual void bic(Register rd, Register rn, const ShifterOperand& so, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 430 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 431 | virtual void mvn(Register rd, const ShifterOperand& so, Condition cond = AL) = 0; |
| 432 | virtual void mvns(Register rd, const ShifterOperand& so, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 433 | |
| 434 | // Miscellaneous data-processing instructions. |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 435 | virtual void clz(Register rd, Register rm, Condition cond = AL) = 0; |
| 436 | virtual void movw(Register rd, uint16_t imm16, Condition cond = AL) = 0; |
| 437 | virtual void movt(Register rd, uint16_t imm16, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 438 | |
| 439 | // Multiply instructions. |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 440 | virtual void mul(Register rd, Register rn, Register rm, Condition cond = AL) = 0; |
| 441 | virtual void mla(Register rd, Register rn, Register rm, Register ra, |
| 442 | Condition cond = AL) = 0; |
| 443 | virtual void mls(Register rd, Register rn, Register rm, Register ra, |
| 444 | Condition cond = AL) = 0; |
Zheng Xu | c666710 | 2015-05-15 16:08:45 +0800 | [diff] [blame] | 445 | virtual void smull(Register rd_lo, Register rd_hi, Register rn, Register rm, |
| 446 | Condition cond = AL) = 0; |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 447 | virtual void umull(Register rd_lo, Register rd_hi, Register rn, Register rm, |
| 448 | Condition cond = AL) = 0; |
| 449 | |
| 450 | virtual void sdiv(Register rd, Register rn, Register rm, Condition cond = AL) = 0; |
| 451 | virtual void udiv(Register rd, Register rn, Register rm, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 452 | |
Roland Levillain | 981e454 | 2014-11-14 11:47:14 +0000 | [diff] [blame] | 453 | // Bit field extract instructions. |
Roland Levillain | 51d3fc4 | 2014-11-13 14:11:42 +0000 | [diff] [blame] | 454 | virtual void sbfx(Register rd, Register rn, uint32_t lsb, uint32_t width, |
| 455 | Condition cond = AL) = 0; |
Roland Levillain | 981e454 | 2014-11-14 11:47:14 +0000 | [diff] [blame] | 456 | virtual void ubfx(Register rd, Register rn, uint32_t lsb, uint32_t width, |
| 457 | Condition cond = AL) = 0; |
Roland Levillain | 51d3fc4 | 2014-11-13 14:11:42 +0000 | [diff] [blame] | 458 | |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 459 | // Load/store instructions. |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 460 | virtual void ldr(Register rd, const Address& ad, Condition cond = AL) = 0; |
| 461 | virtual void str(Register rd, const Address& ad, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 462 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 463 | virtual void ldrb(Register rd, const Address& ad, Condition cond = AL) = 0; |
| 464 | virtual void strb(Register rd, const Address& ad, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 465 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 466 | virtual void ldrh(Register rd, const Address& ad, Condition cond = AL) = 0; |
| 467 | virtual void strh(Register rd, const Address& ad, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 468 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 469 | virtual void ldrsb(Register rd, const Address& ad, Condition cond = AL) = 0; |
| 470 | virtual void ldrsh(Register rd, const Address& ad, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 471 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 472 | virtual void ldrd(Register rd, const Address& ad, Condition cond = AL) = 0; |
| 473 | virtual void strd(Register rd, const Address& ad, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 474 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 475 | virtual void ldm(BlockAddressMode am, Register base, |
| 476 | RegList regs, Condition cond = AL) = 0; |
| 477 | virtual void stm(BlockAddressMode am, Register base, |
| 478 | RegList regs, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 479 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 480 | virtual void ldrex(Register rd, Register rn, Condition cond = AL) = 0; |
| 481 | virtual void strex(Register rd, Register rt, Register rn, Condition cond = AL) = 0; |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 482 | virtual void ldrexd(Register rt, Register rt2, Register rn, Condition cond = AL) = 0; |
| 483 | virtual void strexd(Register rd, Register rt, Register rt2, Register rn, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 484 | |
| 485 | // Miscellaneous instructions. |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 486 | virtual void clrex(Condition cond = AL) = 0; |
| 487 | virtual void nop(Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 488 | |
| 489 | // Note that gdb sets breakpoints using the undefined instruction 0xe7f001f0. |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 490 | virtual void bkpt(uint16_t imm16) = 0; |
| 491 | virtual void svc(uint32_t imm24) = 0; |
| 492 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 493 | virtual void it(Condition firstcond ATTRIBUTE_UNUSED, |
| 494 | ItState i1 ATTRIBUTE_UNUSED = kItOmitted, |
| 495 | ItState i2 ATTRIBUTE_UNUSED = kItOmitted, |
| 496 | ItState i3 ATTRIBUTE_UNUSED = kItOmitted) { |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 497 | // Ignored if not supported. |
| 498 | } |
| 499 | |
| 500 | virtual void cbz(Register rn, Label* target) = 0; |
| 501 | virtual void cbnz(Register rn, Label* target) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 502 | |
| 503 | // Floating point instructions (VFPv3-D16 and VFPv3-D32 profiles). |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 504 | virtual void vmovsr(SRegister sn, Register rt, Condition cond = AL) = 0; |
| 505 | virtual void vmovrs(Register rt, SRegister sn, Condition cond = AL) = 0; |
| 506 | virtual void vmovsrr(SRegister sm, Register rt, Register rt2, Condition cond = AL) = 0; |
| 507 | virtual void vmovrrs(Register rt, Register rt2, SRegister sm, Condition cond = AL) = 0; |
| 508 | virtual void vmovdrr(DRegister dm, Register rt, Register rt2, Condition cond = AL) = 0; |
| 509 | virtual void vmovrrd(Register rt, Register rt2, DRegister dm, Condition cond = AL) = 0; |
| 510 | virtual void vmovs(SRegister sd, SRegister sm, Condition cond = AL) = 0; |
| 511 | virtual void vmovd(DRegister dd, DRegister dm, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 512 | |
| 513 | // Returns false if the immediate cannot be encoded. |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 514 | virtual bool vmovs(SRegister sd, float s_imm, Condition cond = AL) = 0; |
| 515 | virtual bool vmovd(DRegister dd, double d_imm, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 516 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 517 | virtual void vldrs(SRegister sd, const Address& ad, Condition cond = AL) = 0; |
| 518 | virtual void vstrs(SRegister sd, const Address& ad, Condition cond = AL) = 0; |
| 519 | virtual void vldrd(DRegister dd, const Address& ad, Condition cond = AL) = 0; |
| 520 | virtual void vstrd(DRegister dd, const Address& ad, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 521 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 522 | virtual void vadds(SRegister sd, SRegister sn, SRegister sm, Condition cond = AL) = 0; |
| 523 | virtual void vaddd(DRegister dd, DRegister dn, DRegister dm, Condition cond = AL) = 0; |
| 524 | virtual void vsubs(SRegister sd, SRegister sn, SRegister sm, Condition cond = AL) = 0; |
| 525 | virtual void vsubd(DRegister dd, DRegister dn, DRegister dm, Condition cond = AL) = 0; |
| 526 | virtual void vmuls(SRegister sd, SRegister sn, SRegister sm, Condition cond = AL) = 0; |
| 527 | virtual void vmuld(DRegister dd, DRegister dn, DRegister dm, Condition cond = AL) = 0; |
| 528 | virtual void vmlas(SRegister sd, SRegister sn, SRegister sm, Condition cond = AL) = 0; |
| 529 | virtual void vmlad(DRegister dd, DRegister dn, DRegister dm, Condition cond = AL) = 0; |
| 530 | virtual void vmlss(SRegister sd, SRegister sn, SRegister sm, Condition cond = AL) = 0; |
| 531 | virtual void vmlsd(DRegister dd, DRegister dn, DRegister dm, Condition cond = AL) = 0; |
| 532 | virtual void vdivs(SRegister sd, SRegister sn, SRegister sm, Condition cond = AL) = 0; |
| 533 | virtual void vdivd(DRegister dd, DRegister dn, DRegister dm, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 534 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 535 | virtual void vabss(SRegister sd, SRegister sm, Condition cond = AL) = 0; |
| 536 | virtual void vabsd(DRegister dd, DRegister dm, Condition cond = AL) = 0; |
| 537 | virtual void vnegs(SRegister sd, SRegister sm, Condition cond = AL) = 0; |
| 538 | virtual void vnegd(DRegister dd, DRegister dm, Condition cond = AL) = 0; |
| 539 | virtual void vsqrts(SRegister sd, SRegister sm, Condition cond = AL) = 0; |
| 540 | virtual void vsqrtd(DRegister dd, DRegister dm, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 541 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 542 | virtual void vcvtsd(SRegister sd, DRegister dm, Condition cond = AL) = 0; |
| 543 | virtual void vcvtds(DRegister dd, SRegister sm, Condition cond = AL) = 0; |
| 544 | virtual void vcvtis(SRegister sd, SRegister sm, Condition cond = AL) = 0; |
| 545 | virtual void vcvtid(SRegister sd, DRegister dm, Condition cond = AL) = 0; |
| 546 | virtual void vcvtsi(SRegister sd, SRegister sm, Condition cond = AL) = 0; |
| 547 | virtual void vcvtdi(DRegister dd, SRegister sm, Condition cond = AL) = 0; |
| 548 | virtual void vcvtus(SRegister sd, SRegister sm, Condition cond = AL) = 0; |
| 549 | virtual void vcvtud(SRegister sd, DRegister dm, Condition cond = AL) = 0; |
| 550 | virtual void vcvtsu(SRegister sd, SRegister sm, Condition cond = AL) = 0; |
| 551 | virtual void vcvtdu(DRegister dd, SRegister sm, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 552 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 553 | virtual void vcmps(SRegister sd, SRegister sm, Condition cond = AL) = 0; |
| 554 | virtual void vcmpd(DRegister dd, DRegister dm, Condition cond = AL) = 0; |
| 555 | virtual void vcmpsz(SRegister sd, Condition cond = AL) = 0; |
| 556 | virtual void vcmpdz(DRegister dd, Condition cond = AL) = 0; |
| 557 | virtual void vmstat(Condition cond = AL) = 0; // VMRS APSR_nzcv, FPSCR |
| 558 | |
| 559 | virtual void vpushs(SRegister reg, int nregs, Condition cond = AL) = 0; |
| 560 | virtual void vpushd(DRegister reg, int nregs, Condition cond = AL) = 0; |
| 561 | virtual void vpops(SRegister reg, int nregs, Condition cond = AL) = 0; |
| 562 | virtual void vpopd(DRegister reg, int nregs, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 563 | |
| 564 | // Branch instructions. |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 565 | virtual void b(Label* label, Condition cond = AL) = 0; |
| 566 | virtual void bl(Label* label, Condition cond = AL) = 0; |
| 567 | virtual void blx(Register rm, Condition cond = AL) = 0; |
| 568 | virtual void bx(Register rm, Condition cond = AL) = 0; |
| 569 | |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 570 | // Memory barriers. |
| 571 | virtual void dmb(DmbOptions flavor) = 0; |
| 572 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 573 | void Pad(uint32_t bytes); |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 574 | |
Vladimir Marko | cf93a5c | 2015-06-16 11:33:24 +0000 | [diff] [blame] | 575 | // Adjust label position. |
| 576 | void AdjustLabelPosition(Label* label) { |
| 577 | DCHECK(label->IsBound()); |
| 578 | uint32_t old_position = static_cast<uint32_t>(label->Position()); |
| 579 | uint32_t new_position = GetAdjustedPosition(old_position); |
| 580 | label->Reinitialize(); |
| 581 | DCHECK_GE(static_cast<int>(new_position), 0); |
| 582 | label->BindTo(static_cast<int>(new_position)); |
| 583 | } |
| 584 | |
| 585 | // Get the final position of a label after local fixup based on the old position |
| 586 | // recorded before FinalizeCode(). |
| 587 | virtual uint32_t GetAdjustedPosition(uint32_t old_position) = 0; |
| 588 | |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 589 | // Macros. |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 590 | // Most of these are pure virtual as they need to be implemented per instruction set. |
| 591 | |
Vladimir Marko | cf93a5c | 2015-06-16 11:33:24 +0000 | [diff] [blame] | 592 | // Create a new literal with a given value. |
| 593 | // NOTE: Force the template parameter to be explicitly specified. In the absence of |
| 594 | // std::omit_from_type_deduction<T> or std::identity<T>, use std::decay<T>. |
| 595 | template <typename T> |
| 596 | Literal* NewLiteral(typename std::decay<T>::type value) { |
| 597 | static_assert(std::is_integral<T>::value, "T must be an integral type."); |
| 598 | return NewLiteral(sizeof(value), reinterpret_cast<const uint8_t*>(&value)); |
| 599 | } |
| 600 | |
| 601 | // Create a new literal with the given data. |
| 602 | virtual Literal* NewLiteral(size_t size, const uint8_t* data) = 0; |
| 603 | |
| 604 | // Load literal. |
| 605 | virtual void LoadLiteral(Register rt, Literal* literal) = 0; |
| 606 | virtual void LoadLiteral(Register rt, Register rt2, Literal* literal) = 0; |
| 607 | virtual void LoadLiteral(SRegister sd, Literal* literal) = 0; |
| 608 | virtual void LoadLiteral(DRegister dd, Literal* literal) = 0; |
| 609 | |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 610 | // Add signed constant value to rd. May clobber IP. |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 611 | virtual void AddConstant(Register rd, int32_t value, Condition cond = AL) = 0; |
| 612 | virtual void AddConstant(Register rd, Register rn, int32_t value, |
| 613 | Condition cond = AL) = 0; |
| 614 | virtual void AddConstantSetFlags(Register rd, Register rn, int32_t value, |
| 615 | Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 616 | |
| 617 | // Load and Store. May clobber IP. |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 618 | virtual void LoadImmediate(Register rd, int32_t value, Condition cond = AL) = 0; |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 619 | void LoadSImmediate(SRegister sd, float value, Condition cond = AL) { |
| 620 | if (!vmovs(sd, value, cond)) { |
Nicolas Geoffray | ffe8a57 | 2015-02-11 01:10:39 +0000 | [diff] [blame] | 621 | int32_t int_value = bit_cast<int32_t, float>(value); |
| 622 | if (int_value == bit_cast<int32_t, float>(0.0f)) { |
| 623 | // 0.0 is quite common, so we special case it by loading |
| 624 | // 2.0 in `sd` and then substracting it. |
| 625 | bool success = vmovs(sd, 2.0, cond); |
| 626 | CHECK(success); |
| 627 | vsubs(sd, sd, sd, cond); |
| 628 | } else { |
| 629 | LoadImmediate(IP, int_value, cond); |
| 630 | vmovsr(sd, IP, cond); |
| 631 | } |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 632 | } |
| 633 | } |
| 634 | |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 635 | void LoadDImmediate(DRegister sd, double value, Condition cond = AL) { |
| 636 | if (!vmovd(sd, value, cond)) { |
| 637 | uint64_t int_value = bit_cast<uint64_t, double>(value); |
Nicolas Geoffray | ffe8a57 | 2015-02-11 01:10:39 +0000 | [diff] [blame] | 638 | if (int_value == bit_cast<uint64_t, double>(0.0)) { |
| 639 | // 0.0 is quite common, so we special case it by loading |
| 640 | // 2.0 in `sd` and then substracting it. |
| 641 | bool success = vmovd(sd, 2.0, cond); |
| 642 | CHECK(success); |
| 643 | vsubd(sd, sd, sd, cond); |
| 644 | } else { |
| 645 | if (sd < 16) { |
| 646 | SRegister low = static_cast<SRegister>(sd << 1); |
| 647 | SRegister high = static_cast<SRegister>(low + 1); |
| 648 | LoadSImmediate(low, bit_cast<float, uint32_t>(Low32Bits(int_value)), cond); |
| 649 | if (High32Bits(int_value) == Low32Bits(int_value)) { |
| 650 | vmovs(high, low); |
| 651 | } else { |
| 652 | LoadSImmediate(high, bit_cast<float, uint32_t>(High32Bits(int_value)), cond); |
| 653 | } |
| 654 | } else { |
| 655 | LOG(FATAL) << "Unimplemented loading of double into a D register " |
| 656 | << "that cannot be split into two S registers"; |
| 657 | } |
| 658 | } |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 659 | } |
| 660 | } |
| 661 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 662 | virtual void MarkExceptionHandler(Label* label) = 0; |
| 663 | virtual void LoadFromOffset(LoadOperandType type, |
| 664 | Register reg, |
| 665 | Register base, |
| 666 | int32_t offset, |
| 667 | Condition cond = AL) = 0; |
| 668 | virtual void StoreToOffset(StoreOperandType type, |
| 669 | Register reg, |
| 670 | Register base, |
| 671 | int32_t offset, |
| 672 | Condition cond = AL) = 0; |
| 673 | virtual void LoadSFromOffset(SRegister reg, |
| 674 | Register base, |
| 675 | int32_t offset, |
| 676 | Condition cond = AL) = 0; |
| 677 | virtual void StoreSToOffset(SRegister reg, |
| 678 | Register base, |
| 679 | int32_t offset, |
| 680 | Condition cond = AL) = 0; |
| 681 | virtual void LoadDFromOffset(DRegister reg, |
| 682 | Register base, |
| 683 | int32_t offset, |
| 684 | Condition cond = AL) = 0; |
| 685 | virtual void StoreDToOffset(DRegister reg, |
| 686 | Register base, |
| 687 | int32_t offset, |
| 688 | Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 689 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 690 | virtual void Push(Register rd, Condition cond = AL) = 0; |
| 691 | virtual void Pop(Register rd, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 692 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 693 | virtual void PushList(RegList regs, Condition cond = AL) = 0; |
| 694 | virtual void PopList(RegList regs, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 695 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 696 | virtual void Mov(Register rd, Register rm, Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 697 | |
| 698 | // Convenience shift instructions. Use mov instruction with shifter operand |
| 699 | // for variants setting the status flags or using a register shift count. |
Dave Allison | 45fdb93 | 2014-06-25 12:37:10 -0700 | [diff] [blame] | 700 | virtual void Lsl(Register rd, Register rm, uint32_t shift_imm, bool setcc = false, |
| 701 | Condition cond = AL) = 0; |
| 702 | virtual void Lsr(Register rd, Register rm, uint32_t shift_imm, bool setcc = false, |
| 703 | Condition cond = AL) = 0; |
| 704 | virtual void Asr(Register rd, Register rm, uint32_t shift_imm, bool setcc = false, |
| 705 | Condition cond = AL) = 0; |
| 706 | virtual void Ror(Register rd, Register rm, uint32_t shift_imm, bool setcc = false, |
| 707 | Condition cond = AL) = 0; |
| 708 | virtual void Rrx(Register rd, Register rm, bool setcc = false, |
| 709 | Condition cond = AL) = 0; |
| 710 | |
| 711 | virtual void Lsl(Register rd, Register rm, Register rn, bool setcc = false, |
| 712 | Condition cond = AL) = 0; |
| 713 | virtual void Lsr(Register rd, Register rm, Register rn, bool setcc = false, |
| 714 | Condition cond = AL) = 0; |
| 715 | virtual void Asr(Register rd, Register rm, Register rn, bool setcc = false, |
| 716 | Condition cond = AL) = 0; |
| 717 | virtual void Ror(Register rd, Register rm, Register rn, bool setcc = false, |
| 718 | Condition cond = AL) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 719 | |
Nicolas Geoffray | 3bcc8ea | 2014-11-28 15:00:02 +0000 | [diff] [blame] | 720 | // Returns whether the `immediate` can fit in a `ShifterOperand`. If yes, |
| 721 | // `shifter_op` contains the operand. |
| 722 | virtual bool ShifterOperandCanHold(Register rd, |
| 723 | Register rn, |
| 724 | Opcode opcode, |
| 725 | uint32_t immediate, |
| 726 | ShifterOperand* shifter_op) = 0; |
| 727 | |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 728 | static bool IsInstructionForExceptionHandling(uintptr_t pc); |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 729 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 730 | virtual void Bind(Label* label) = 0; |
| 731 | |
| 732 | virtual void CompareAndBranchIfZero(Register r, Label* label) = 0; |
| 733 | virtual void CompareAndBranchIfNonZero(Register r, Label* label) = 0; |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 734 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 735 | // |
| 736 | // Overridden common assembler high-level functionality |
| 737 | // |
Ian Rogers | 45a76cb | 2011-07-21 22:00:15 -0700 | [diff] [blame] | 738 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 739 | // Emit code that will create an activation on the stack |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 740 | void BuildFrame(size_t frame_size, ManagedRegister method_reg, |
| 741 | const std::vector<ManagedRegister>& callee_save_regs, |
| 742 | const ManagedRegisterEntrySpills& entry_spills) OVERRIDE; |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 743 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 744 | // Emit code that will remove an activation from the stack |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 745 | void RemoveFrame(size_t frame_size, const std::vector<ManagedRegister>& callee_save_regs) |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 746 | OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 747 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 748 | void IncreaseFrameSize(size_t adjust) OVERRIDE; |
| 749 | void DecreaseFrameSize(size_t adjust) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 750 | |
| 751 | // Store routines |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 752 | void Store(FrameOffset offs, ManagedRegister src, size_t size) OVERRIDE; |
| 753 | void StoreRef(FrameOffset dest, ManagedRegister src) OVERRIDE; |
| 754 | void StoreRawPtr(FrameOffset dest, ManagedRegister src) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 755 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 756 | void StoreImmediateToFrame(FrameOffset dest, uint32_t imm, ManagedRegister scratch) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 757 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 758 | void StoreImmediateToThread32(ThreadOffset<4> dest, uint32_t imm, ManagedRegister scratch) |
| 759 | OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 760 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 761 | void StoreStackOffsetToThread32(ThreadOffset<4> thr_offs, FrameOffset fr_offs, |
| 762 | ManagedRegister scratch) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 763 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 764 | void StoreStackPointerToThread32(ThreadOffset<4> thr_offs) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 765 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 766 | void StoreSpanning(FrameOffset dest, ManagedRegister src, FrameOffset in_off, |
| 767 | ManagedRegister scratch) OVERRIDE; |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 768 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 769 | // Load routines |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 770 | void Load(ManagedRegister dest, FrameOffset src, size_t size) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 771 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 772 | void LoadFromThread32(ManagedRegister dest, ThreadOffset<4> src, size_t size) OVERRIDE; |
Ian Rogers | 5a7a74a | 2011-09-26 16:32:29 -0700 | [diff] [blame] | 773 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 774 | void LoadRef(ManagedRegister dest, FrameOffset src) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 775 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 776 | void LoadRef(ManagedRegister dest, ManagedRegister base, MemberOffset offs, |
| 777 | bool poison_reference) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 778 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 779 | void LoadRawPtr(ManagedRegister dest, ManagedRegister base, Offset offs) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 780 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 781 | void LoadRawPtrFromThread32(ManagedRegister dest, ThreadOffset<4> offs) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 782 | |
| 783 | // Copying routines |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 784 | void Move(ManagedRegister dest, ManagedRegister src, size_t size) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 785 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 786 | void CopyRawPtrFromThread32(FrameOffset fr_offs, ThreadOffset<4> thr_offs, |
| 787 | ManagedRegister scratch) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 788 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 789 | void CopyRawPtrToThread32(ThreadOffset<4> thr_offs, FrameOffset fr_offs, ManagedRegister scratch) |
| 790 | OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 791 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 792 | void CopyRef(FrameOffset dest, FrameOffset src, ManagedRegister scratch) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 793 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 794 | void Copy(FrameOffset dest, FrameOffset src, ManagedRegister scratch, size_t size) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 795 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 796 | void Copy(FrameOffset dest, ManagedRegister src_base, Offset src_offset, ManagedRegister scratch, |
| 797 | size_t size) OVERRIDE; |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 798 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 799 | void Copy(ManagedRegister dest_base, Offset dest_offset, FrameOffset src, ManagedRegister scratch, |
| 800 | size_t size) OVERRIDE; |
Ian Rogers | 5a7a74a | 2011-09-26 16:32:29 -0700 | [diff] [blame] | 801 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 802 | void Copy(FrameOffset dest, FrameOffset src_base, Offset src_offset, ManagedRegister scratch, |
| 803 | size_t size) OVERRIDE; |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 804 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 805 | void Copy(ManagedRegister dest, Offset dest_offset, ManagedRegister src, Offset src_offset, |
| 806 | ManagedRegister scratch, size_t size) OVERRIDE; |
Ian Rogers | 5a7a74a | 2011-09-26 16:32:29 -0700 | [diff] [blame] | 807 | |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 808 | void Copy(FrameOffset dest, Offset dest_offset, FrameOffset src, Offset src_offset, |
| 809 | ManagedRegister scratch, size_t size) OVERRIDE; |
Ian Rogers | dc51b79 | 2011-09-22 20:41:37 -0700 | [diff] [blame] | 810 | |
jeffhao | 58136ca | 2012-05-24 13:40:11 -0700 | [diff] [blame] | 811 | // Sign extension |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 812 | void SignExtend(ManagedRegister mreg, size_t size) OVERRIDE; |
jeffhao | 58136ca | 2012-05-24 13:40:11 -0700 | [diff] [blame] | 813 | |
jeffhao | cee4d0c | 2012-06-15 14:42:01 -0700 | [diff] [blame] | 814 | // Zero extension |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 815 | void ZeroExtend(ManagedRegister mreg, size_t size) OVERRIDE; |
jeffhao | cee4d0c | 2012-06-15 14:42:01 -0700 | [diff] [blame] | 816 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 817 | // Exploit fast access in managed code to Thread::Current() |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 818 | void GetCurrentThread(ManagedRegister tr) OVERRIDE; |
| 819 | void GetCurrentThread(FrameOffset dest_offset, ManagedRegister scratch) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 820 | |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 821 | // Set up out_reg to hold a Object** into the handle scope, or to be null if the |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 822 | // value is null and null_allowed. in_reg holds a possibly stale reference |
Mathieu Chartier | eb8167a | 2014-05-07 15:43:14 -0700 | [diff] [blame] | 823 | // that can be used to avoid loading the handle scope entry to see if the value is |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 824 | // null. |
| 825 | void CreateHandleScopeEntry(ManagedRegister out_reg, FrameOffset handlescope_offset, |
| 826 | ManagedRegister in_reg, bool null_allowed) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 827 | |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 828 | // Set up out_off to hold a Object** into the handle scope, or to be null if the |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 829 | // value is null and null_allowed. |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 830 | void CreateHandleScopeEntry(FrameOffset out_off, FrameOffset handlescope_offset, |
| 831 | ManagedRegister scratch, bool null_allowed) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 832 | |
Mathieu Chartier | eb8167a | 2014-05-07 15:43:14 -0700 | [diff] [blame] | 833 | // src holds a handle scope entry (Object**) load this into dst |
| 834 | void LoadReferenceFromHandleScope(ManagedRegister dst, ManagedRegister src) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 835 | |
| 836 | // Heap::VerifyObject on src. In some cases (such as a reference to this) we |
| 837 | // know that src may not be null. |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 838 | void VerifyObject(ManagedRegister src, bool could_be_null) OVERRIDE; |
| 839 | void VerifyObject(FrameOffset src, bool could_be_null) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 840 | |
| 841 | // Call to address held at [base+offset] |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 842 | void Call(ManagedRegister base, Offset offset, ManagedRegister scratch) OVERRIDE; |
| 843 | void Call(FrameOffset base, Offset offset, ManagedRegister scratch) OVERRIDE; |
| 844 | void CallFromThread32(ThreadOffset<4> offset, ManagedRegister scratch) OVERRIDE; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 845 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 846 | // Generate code to check if Thread::Current()->exception_ is non-null |
| 847 | // and branch to a ExceptionSlowPath if it is. |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 848 | void ExceptionPoll(ManagedRegister scratch, size_t stack_adjust) OVERRIDE; |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 849 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 850 | static uint32_t ModifiedImmediate(uint32_t value); |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 851 | |
Dave Allison | 45fdb93 | 2014-06-25 12:37:10 -0700 | [diff] [blame] | 852 | static bool IsLowRegister(Register r) { |
| 853 | return r < R8; |
| 854 | } |
| 855 | |
| 856 | static bool IsHighRegister(Register r) { |
| 857 | return r >= R8; |
| 858 | } |
| 859 | |
Dave Allison | 65fcc2c | 2014-04-28 13:45:27 -0700 | [diff] [blame] | 860 | protected: |
Carl Shapiro | a2e18e1 | 2011-06-21 18:57:55 -0700 | [diff] [blame] | 861 | // Returns whether or not the given register is used for passing parameters. |
| 862 | static int RegisterCompare(const Register* reg1, const Register* reg2) { |
| 863 | return *reg1 - *reg2; |
| 864 | } |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 865 | }; |
| 866 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 867 | // Slowpath entered when Thread::Current()->_exception is non-null |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 868 | class ArmExceptionSlowPath FINAL : public SlowPath { |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 869 | public: |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 870 | explicit ArmExceptionSlowPath(ArmManagedRegister scratch, size_t stack_adjust) |
| 871 | : scratch_(scratch), stack_adjust_(stack_adjust) { |
| 872 | } |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 873 | void Emit(Assembler *sp_asm) OVERRIDE; |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 874 | private: |
| 875 | const ArmManagedRegister scratch_; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 876 | const size_t stack_adjust_; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 877 | }; |
| 878 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 879 | } // namespace arm |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 880 | } // namespace art |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 881 | |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 882 | #endif // ART_COMPILER_UTILS_ARM_ASSEMBLER_ARM_H_ |