Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1 | // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 | // All Rights Reserved. |
| 3 | // |
| 4 | // Redistribution and use in source and binary forms, with or without |
| 5 | // modification, are permitted provided that the following conditions |
| 6 | // are met: |
| 7 | // |
| 8 | // - Redistributions of source code must retain the above copyright notice, |
| 9 | // this list of conditions and the following disclaimer. |
| 10 | // |
| 11 | // - Redistribution in binary form must reproduce the above copyright |
| 12 | // notice, this list of conditions and the following disclaimer in the |
| 13 | // documentation and/or other materials provided with the |
| 14 | // distribution. |
| 15 | // |
| 16 | // - Neither the name of Sun Microsystems or the names of contributors may |
| 17 | // be used to endorse or promote products derived from this software without |
| 18 | // specific prior written permission. |
| 19 | // |
| 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 26 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 27 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 29 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 30 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 31 | // OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 33 | // The original source code covered by the above license above has been |
| 34 | // modified significantly by Google Inc. |
| 35 | // Copyright 2010 the V8 project authors. All rights reserved. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 36 | |
| 37 | // A light-weight ARM Assembler |
| 38 | // Generates user mode instructions for the ARM architecture up to version 5 |
| 39 | |
| 40 | #ifndef V8_ARM_ASSEMBLER_ARM_H_ |
| 41 | #define V8_ARM_ASSEMBLER_ARM_H_ |
| 42 | #include <stdio.h> |
| 43 | #include "assembler.h" |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 44 | #include "serialize.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 45 | |
| 46 | namespace v8 { |
| 47 | namespace internal { |
| 48 | |
| 49 | // CPU Registers. |
| 50 | // |
| 51 | // 1) We would prefer to use an enum, but enum values are assignment- |
| 52 | // compatible with int, which has caused code-generation bugs. |
| 53 | // |
| 54 | // 2) We would prefer to use a class instead of a struct but we don't like |
| 55 | // the register initialization to depend on the particular initialization |
| 56 | // order (which appears to be different on OS X, Linux, and Windows for the |
| 57 | // installed versions of C++ we tried). Using a struct permits C-style |
| 58 | // "initialization". Also, the Register objects cannot be const as this |
| 59 | // forces initialization stubs in MSVC, making us dependent on initialization |
| 60 | // order. |
| 61 | // |
| 62 | // 3) By not using an enum, we are possibly preventing the compiler from |
| 63 | // doing certain constant folds, which may significantly reduce the |
| 64 | // code generated for some assembly instructions (because they boil down |
| 65 | // to a few constants). If this is a problem, we could change the code |
| 66 | // such that we use an enum in optimized mode, and the struct in debug |
| 67 | // mode. This way we get the compile-time error checking in debug mode |
| 68 | // and best performance in optimized code. |
| 69 | // |
| 70 | // Core register |
| 71 | struct Register { |
| 72 | bool is_valid() const { return 0 <= code_ && code_ < 16; } |
| 73 | bool is(Register reg) const { return code_ == reg.code_; } |
| 74 | int code() const { |
| 75 | ASSERT(is_valid()); |
| 76 | return code_; |
| 77 | } |
| 78 | int bit() const { |
| 79 | ASSERT(is_valid()); |
| 80 | return 1 << code_; |
| 81 | } |
| 82 | |
Leon Clarke | f7060e2 | 2010-06-03 12:02:55 +0100 | [diff] [blame] | 83 | void set_code(int code) { |
| 84 | code_ = code; |
| 85 | ASSERT(is_valid()); |
| 86 | } |
| 87 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 88 | // Unfortunately we can't make this private in a struct. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 89 | int code_; |
| 90 | }; |
| 91 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 92 | const Register no_reg = { -1 }; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 93 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 94 | const Register r0 = { 0 }; |
| 95 | const Register r1 = { 1 }; |
| 96 | const Register r2 = { 2 }; |
| 97 | const Register r3 = { 3 }; |
| 98 | const Register r4 = { 4 }; |
| 99 | const Register r5 = { 5 }; |
| 100 | const Register r6 = { 6 }; |
| 101 | const Register r7 = { 7 }; |
| 102 | const Register r8 = { 8 }; // Used as context register. |
| 103 | const Register r9 = { 9 }; |
| 104 | const Register r10 = { 10 }; // Used as roots register. |
| 105 | const Register fp = { 11 }; |
| 106 | const Register ip = { 12 }; |
| 107 | const Register sp = { 13 }; |
| 108 | const Register lr = { 14 }; |
| 109 | const Register pc = { 15 }; |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 110 | |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 111 | // Single word VFP register. |
| 112 | struct SwVfpRegister { |
| 113 | bool is_valid() const { return 0 <= code_ && code_ < 32; } |
| 114 | bool is(SwVfpRegister reg) const { return code_ == reg.code_; } |
| 115 | int code() const { |
| 116 | ASSERT(is_valid()); |
| 117 | return code_; |
| 118 | } |
| 119 | int bit() const { |
| 120 | ASSERT(is_valid()); |
| 121 | return 1 << code_; |
| 122 | } |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame^] | 123 | void split_code(int* vm, int* m) const { |
| 124 | ASSERT(is_valid()); |
| 125 | *m = code_ & 0x1; |
| 126 | *vm = code_ >> 1; |
| 127 | } |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 128 | |
| 129 | int code_; |
| 130 | }; |
| 131 | |
| 132 | |
| 133 | // Double word VFP register. |
| 134 | struct DwVfpRegister { |
| 135 | // Supporting d0 to d15, can be later extended to d31. |
| 136 | bool is_valid() const { return 0 <= code_ && code_ < 16; } |
| 137 | bool is(DwVfpRegister reg) const { return code_ == reg.code_; } |
Ben Murdoch | 3bec4d2 | 2010-07-22 14:51:16 +0100 | [diff] [blame] | 138 | SwVfpRegister low() const { |
| 139 | SwVfpRegister reg; |
| 140 | reg.code_ = code_ * 2; |
| 141 | |
| 142 | ASSERT(reg.is_valid()); |
| 143 | return reg; |
| 144 | } |
| 145 | SwVfpRegister high() const { |
| 146 | SwVfpRegister reg; |
| 147 | reg.code_ = (code_ * 2) + 1; |
| 148 | |
| 149 | ASSERT(reg.is_valid()); |
| 150 | return reg; |
| 151 | } |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 152 | int code() const { |
| 153 | ASSERT(is_valid()); |
| 154 | return code_; |
| 155 | } |
| 156 | int bit() const { |
| 157 | ASSERT(is_valid()); |
| 158 | return 1 << code_; |
| 159 | } |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame^] | 160 | void split_code(int* vm, int* m) const { |
| 161 | ASSERT(is_valid()); |
| 162 | *m = (code_ & 0x10) >> 4; |
| 163 | *vm = code_ & 0x0F; |
| 164 | } |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 165 | |
| 166 | int code_; |
| 167 | }; |
| 168 | |
| 169 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 170 | // Support for the VFP registers s0 to s31 (d0 to d15). |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 171 | // Note that "s(N):s(N+1)" is the same as "d(N/2)". |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 172 | const SwVfpRegister s0 = { 0 }; |
| 173 | const SwVfpRegister s1 = { 1 }; |
| 174 | const SwVfpRegister s2 = { 2 }; |
| 175 | const SwVfpRegister s3 = { 3 }; |
| 176 | const SwVfpRegister s4 = { 4 }; |
| 177 | const SwVfpRegister s5 = { 5 }; |
| 178 | const SwVfpRegister s6 = { 6 }; |
| 179 | const SwVfpRegister s7 = { 7 }; |
| 180 | const SwVfpRegister s8 = { 8 }; |
| 181 | const SwVfpRegister s9 = { 9 }; |
| 182 | const SwVfpRegister s10 = { 10 }; |
| 183 | const SwVfpRegister s11 = { 11 }; |
| 184 | const SwVfpRegister s12 = { 12 }; |
| 185 | const SwVfpRegister s13 = { 13 }; |
| 186 | const SwVfpRegister s14 = { 14 }; |
| 187 | const SwVfpRegister s15 = { 15 }; |
| 188 | const SwVfpRegister s16 = { 16 }; |
| 189 | const SwVfpRegister s17 = { 17 }; |
| 190 | const SwVfpRegister s18 = { 18 }; |
| 191 | const SwVfpRegister s19 = { 19 }; |
| 192 | const SwVfpRegister s20 = { 20 }; |
| 193 | const SwVfpRegister s21 = { 21 }; |
| 194 | const SwVfpRegister s22 = { 22 }; |
| 195 | const SwVfpRegister s23 = { 23 }; |
| 196 | const SwVfpRegister s24 = { 24 }; |
| 197 | const SwVfpRegister s25 = { 25 }; |
| 198 | const SwVfpRegister s26 = { 26 }; |
| 199 | const SwVfpRegister s27 = { 27 }; |
| 200 | const SwVfpRegister s28 = { 28 }; |
| 201 | const SwVfpRegister s29 = { 29 }; |
| 202 | const SwVfpRegister s30 = { 30 }; |
| 203 | const SwVfpRegister s31 = { 31 }; |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 204 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 205 | const DwVfpRegister d0 = { 0 }; |
| 206 | const DwVfpRegister d1 = { 1 }; |
| 207 | const DwVfpRegister d2 = { 2 }; |
| 208 | const DwVfpRegister d3 = { 3 }; |
| 209 | const DwVfpRegister d4 = { 4 }; |
| 210 | const DwVfpRegister d5 = { 5 }; |
| 211 | const DwVfpRegister d6 = { 6 }; |
| 212 | const DwVfpRegister d7 = { 7 }; |
| 213 | const DwVfpRegister d8 = { 8 }; |
| 214 | const DwVfpRegister d9 = { 9 }; |
| 215 | const DwVfpRegister d10 = { 10 }; |
| 216 | const DwVfpRegister d11 = { 11 }; |
| 217 | const DwVfpRegister d12 = { 12 }; |
| 218 | const DwVfpRegister d13 = { 13 }; |
| 219 | const DwVfpRegister d14 = { 14 }; |
| 220 | const DwVfpRegister d15 = { 15 }; |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 221 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 222 | |
| 223 | // Coprocessor register |
| 224 | struct CRegister { |
| 225 | bool is_valid() const { return 0 <= code_ && code_ < 16; } |
| 226 | bool is(CRegister creg) const { return code_ == creg.code_; } |
| 227 | int code() const { |
| 228 | ASSERT(is_valid()); |
| 229 | return code_; |
| 230 | } |
| 231 | int bit() const { |
| 232 | ASSERT(is_valid()); |
| 233 | return 1 << code_; |
| 234 | } |
| 235 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 236 | // Unfortunately we can't make this private in a struct. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 237 | int code_; |
| 238 | }; |
| 239 | |
| 240 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 241 | const CRegister no_creg = { -1 }; |
| 242 | |
| 243 | const CRegister cr0 = { 0 }; |
| 244 | const CRegister cr1 = { 1 }; |
| 245 | const CRegister cr2 = { 2 }; |
| 246 | const CRegister cr3 = { 3 }; |
| 247 | const CRegister cr4 = { 4 }; |
| 248 | const CRegister cr5 = { 5 }; |
| 249 | const CRegister cr6 = { 6 }; |
| 250 | const CRegister cr7 = { 7 }; |
| 251 | const CRegister cr8 = { 8 }; |
| 252 | const CRegister cr9 = { 9 }; |
| 253 | const CRegister cr10 = { 10 }; |
| 254 | const CRegister cr11 = { 11 }; |
| 255 | const CRegister cr12 = { 12 }; |
| 256 | const CRegister cr13 = { 13 }; |
| 257 | const CRegister cr14 = { 14 }; |
| 258 | const CRegister cr15 = { 15 }; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 259 | |
| 260 | |
| 261 | // Coprocessor number |
| 262 | enum Coprocessor { |
| 263 | p0 = 0, |
| 264 | p1 = 1, |
| 265 | p2 = 2, |
| 266 | p3 = 3, |
| 267 | p4 = 4, |
| 268 | p5 = 5, |
| 269 | p6 = 6, |
| 270 | p7 = 7, |
| 271 | p8 = 8, |
| 272 | p9 = 9, |
| 273 | p10 = 10, |
| 274 | p11 = 11, |
| 275 | p12 = 12, |
| 276 | p13 = 13, |
| 277 | p14 = 14, |
| 278 | p15 = 15 |
| 279 | }; |
| 280 | |
| 281 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 282 | // Condition field in instructions. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 283 | enum Condition { |
| 284 | eq = 0 << 28, // Z set equal. |
| 285 | ne = 1 << 28, // Z clear not equal. |
| 286 | nz = 1 << 28, // Z clear not zero. |
| 287 | cs = 2 << 28, // C set carry set. |
| 288 | hs = 2 << 28, // C set unsigned higher or same. |
| 289 | cc = 3 << 28, // C clear carry clear. |
| 290 | lo = 3 << 28, // C clear unsigned lower. |
| 291 | mi = 4 << 28, // N set negative. |
| 292 | pl = 5 << 28, // N clear positive or zero. |
| 293 | vs = 6 << 28, // V set overflow. |
| 294 | vc = 7 << 28, // V clear no overflow. |
| 295 | hi = 8 << 28, // C set, Z clear unsigned higher. |
| 296 | ls = 9 << 28, // C clear or Z set unsigned lower or same. |
| 297 | ge = 10 << 28, // N == V greater or equal. |
| 298 | lt = 11 << 28, // N != V less than. |
| 299 | gt = 12 << 28, // Z clear, N == V greater than. |
| 300 | le = 13 << 28, // Z set or N != V less then or equal |
| 301 | al = 14 << 28 // always. |
| 302 | }; |
| 303 | |
| 304 | |
| 305 | // Returns the equivalent of !cc. |
Kristian Monsen | 9dcf7e2 | 2010-06-28 14:14:28 +0100 | [diff] [blame] | 306 | inline Condition NegateCondition(Condition cc) { |
| 307 | ASSERT(cc != al); |
| 308 | return static_cast<Condition>(cc ^ ne); |
| 309 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 310 | |
| 311 | |
| 312 | // Corresponds to transposing the operands of a comparison. |
| 313 | inline Condition ReverseCondition(Condition cc) { |
| 314 | switch (cc) { |
| 315 | case lo: |
| 316 | return hi; |
| 317 | case hi: |
| 318 | return lo; |
| 319 | case hs: |
| 320 | return ls; |
| 321 | case ls: |
| 322 | return hs; |
| 323 | case lt: |
| 324 | return gt; |
| 325 | case gt: |
| 326 | return lt; |
| 327 | case ge: |
| 328 | return le; |
| 329 | case le: |
| 330 | return ge; |
| 331 | default: |
| 332 | return cc; |
| 333 | }; |
| 334 | } |
| 335 | |
| 336 | |
| 337 | // Branch hints are not used on the ARM. They are defined so that they can |
| 338 | // appear in shared function signatures, but will be ignored in ARM |
| 339 | // implementations. |
| 340 | enum Hint { no_hint }; |
| 341 | |
| 342 | // Hints are not used on the arm. Negating is trivial. |
| 343 | inline Hint NegateHint(Hint ignored) { return no_hint; } |
| 344 | |
| 345 | |
| 346 | // ----------------------------------------------------------------------------- |
| 347 | // Addressing modes and instruction variants |
| 348 | |
| 349 | // Shifter operand shift operation |
| 350 | enum ShiftOp { |
| 351 | LSL = 0 << 5, |
| 352 | LSR = 1 << 5, |
| 353 | ASR = 2 << 5, |
| 354 | ROR = 3 << 5, |
| 355 | RRX = -1 |
| 356 | }; |
| 357 | |
| 358 | |
| 359 | // Condition code updating mode |
| 360 | enum SBit { |
| 361 | SetCC = 1 << 20, // set condition code |
| 362 | LeaveCC = 0 << 20 // leave condition code unchanged |
| 363 | }; |
| 364 | |
| 365 | |
| 366 | // Status register selection |
| 367 | enum SRegister { |
| 368 | CPSR = 0 << 22, |
| 369 | SPSR = 1 << 22 |
| 370 | }; |
| 371 | |
| 372 | |
| 373 | // Status register fields |
| 374 | enum SRegisterField { |
| 375 | CPSR_c = CPSR | 1 << 16, |
| 376 | CPSR_x = CPSR | 1 << 17, |
| 377 | CPSR_s = CPSR | 1 << 18, |
| 378 | CPSR_f = CPSR | 1 << 19, |
| 379 | SPSR_c = SPSR | 1 << 16, |
| 380 | SPSR_x = SPSR | 1 << 17, |
| 381 | SPSR_s = SPSR | 1 << 18, |
| 382 | SPSR_f = SPSR | 1 << 19 |
| 383 | }; |
| 384 | |
| 385 | // Status register field mask (or'ed SRegisterField enum values) |
| 386 | typedef uint32_t SRegisterFieldMask; |
| 387 | |
| 388 | |
| 389 | // Memory operand addressing mode |
| 390 | enum AddrMode { |
| 391 | // bit encoding P U W |
| 392 | Offset = (8|4|0) << 21, // offset (without writeback to base) |
| 393 | PreIndex = (8|4|1) << 21, // pre-indexed addressing with writeback |
| 394 | PostIndex = (0|4|0) << 21, // post-indexed addressing with writeback |
| 395 | NegOffset = (8|0|0) << 21, // negative offset (without writeback to base) |
| 396 | NegPreIndex = (8|0|1) << 21, // negative pre-indexed with writeback |
| 397 | NegPostIndex = (0|0|0) << 21 // negative post-indexed with writeback |
| 398 | }; |
| 399 | |
| 400 | |
| 401 | // Load/store multiple addressing mode |
| 402 | enum BlockAddrMode { |
| 403 | // bit encoding P U W |
| 404 | da = (0|0|0) << 21, // decrement after |
| 405 | ia = (0|4|0) << 21, // increment after |
| 406 | db = (8|0|0) << 21, // decrement before |
| 407 | ib = (8|4|0) << 21, // increment before |
| 408 | da_w = (0|0|1) << 21, // decrement after with writeback to base |
| 409 | ia_w = (0|4|1) << 21, // increment after with writeback to base |
| 410 | db_w = (8|0|1) << 21, // decrement before with writeback to base |
| 411 | ib_w = (8|4|1) << 21 // increment before with writeback to base |
| 412 | }; |
| 413 | |
| 414 | |
| 415 | // Coprocessor load/store operand size |
| 416 | enum LFlag { |
| 417 | Long = 1 << 22, // long load/store coprocessor |
| 418 | Short = 0 << 22 // short load/store coprocessor |
| 419 | }; |
| 420 | |
| 421 | |
| 422 | // ----------------------------------------------------------------------------- |
| 423 | // Machine instruction Operands |
| 424 | |
| 425 | // Class Operand represents a shifter operand in data processing instructions |
| 426 | class Operand BASE_EMBEDDED { |
| 427 | public: |
| 428 | // immediate |
| 429 | INLINE(explicit Operand(int32_t immediate, |
| 430 | RelocInfo::Mode rmode = RelocInfo::NONE)); |
| 431 | INLINE(explicit Operand(const ExternalReference& f)); |
| 432 | INLINE(explicit Operand(const char* s)); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 433 | explicit Operand(Handle<Object> handle); |
| 434 | INLINE(explicit Operand(Smi* value)); |
| 435 | |
| 436 | // rm |
| 437 | INLINE(explicit Operand(Register rm)); |
| 438 | |
| 439 | // rm <shift_op> shift_imm |
| 440 | explicit Operand(Register rm, ShiftOp shift_op, int shift_imm); |
| 441 | |
| 442 | // rm <shift_op> rs |
| 443 | explicit Operand(Register rm, ShiftOp shift_op, Register rs); |
| 444 | |
| 445 | // Return true if this is a register operand. |
| 446 | INLINE(bool is_reg() const); |
| 447 | |
Kristian Monsen | 9dcf7e2 | 2010-06-28 14:14:28 +0100 | [diff] [blame] | 448 | // Return true of this operand fits in one instruction so that no |
| 449 | // 2-instruction solution with a load into the ip register is necessary. |
| 450 | bool is_single_instruction() const; |
| 451 | |
| 452 | inline int32_t immediate() const { |
| 453 | ASSERT(!rm_.is_valid()); |
| 454 | return imm32_; |
| 455 | } |
| 456 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 457 | Register rm() const { return rm_; } |
Kristian Monsen | 50ef84f | 2010-07-29 15:18:00 +0100 | [diff] [blame] | 458 | Register rs() const { return rs_; } |
| 459 | ShiftOp shift_op() const { return shift_op_; } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 460 | |
| 461 | private: |
| 462 | Register rm_; |
| 463 | Register rs_; |
| 464 | ShiftOp shift_op_; |
| 465 | int shift_imm_; // valid if rm_ != no_reg && rs_ == no_reg |
| 466 | int32_t imm32_; // valid if rm_ == no_reg |
| 467 | RelocInfo::Mode rmode_; |
| 468 | |
| 469 | friend class Assembler; |
| 470 | }; |
| 471 | |
| 472 | |
| 473 | // Class MemOperand represents a memory operand in load and store instructions |
| 474 | class MemOperand BASE_EMBEDDED { |
| 475 | public: |
| 476 | // [rn +/- offset] Offset/NegOffset |
| 477 | // [rn +/- offset]! PreIndex/NegPreIndex |
| 478 | // [rn], +/- offset PostIndex/NegPostIndex |
| 479 | // offset is any signed 32-bit value; offset is first loaded to register ip if |
| 480 | // it does not fit the addressing mode (12-bit unsigned and sign bit) |
| 481 | explicit MemOperand(Register rn, int32_t offset = 0, AddrMode am = Offset); |
| 482 | |
| 483 | // [rn +/- rm] Offset/NegOffset |
| 484 | // [rn +/- rm]! PreIndex/NegPreIndex |
| 485 | // [rn], +/- rm PostIndex/NegPostIndex |
| 486 | explicit MemOperand(Register rn, Register rm, AddrMode am = Offset); |
| 487 | |
| 488 | // [rn +/- rm <shift_op> shift_imm] Offset/NegOffset |
| 489 | // [rn +/- rm <shift_op> shift_imm]! PreIndex/NegPreIndex |
| 490 | // [rn], +/- rm <shift_op> shift_imm PostIndex/NegPostIndex |
| 491 | explicit MemOperand(Register rn, Register rm, |
| 492 | ShiftOp shift_op, int shift_imm, AddrMode am = Offset); |
| 493 | |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 494 | void set_offset(int32_t offset) { |
| 495 | ASSERT(rm_.is(no_reg)); |
| 496 | offset_ = offset; |
| 497 | } |
| 498 | |
| 499 | uint32_t offset() { |
| 500 | ASSERT(rm_.is(no_reg)); |
| 501 | return offset_; |
| 502 | } |
| 503 | |
Leon Clarke | f7060e2 | 2010-06-03 12:02:55 +0100 | [diff] [blame] | 504 | Register rn() const { return rn_; } |
| 505 | Register rm() const { return rm_; } |
Kristian Monsen | 25f6136 | 2010-05-21 11:50:48 +0100 | [diff] [blame] | 506 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 507 | private: |
| 508 | Register rn_; // base |
| 509 | Register rm_; // register offset |
| 510 | int32_t offset_; // valid if rm_ == no_reg |
| 511 | ShiftOp shift_op_; |
| 512 | int shift_imm_; // valid if rm_ != no_reg && rs_ == no_reg |
| 513 | AddrMode am_; // bits P, U, and W |
| 514 | |
| 515 | friend class Assembler; |
| 516 | }; |
| 517 | |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 518 | // CpuFeatures keeps track of which features are supported by the target CPU. |
| 519 | // Supported features must be enabled by a Scope before use. |
| 520 | class CpuFeatures : public AllStatic { |
| 521 | public: |
| 522 | // Detect features of the target CPU. Set safe defaults if the serializer |
| 523 | // is enabled (snapshots must be portable). |
| 524 | static void Probe(); |
| 525 | |
| 526 | // Check whether a feature is supported by the target CPU. |
| 527 | static bool IsSupported(CpuFeature f) { |
| 528 | if (f == VFP3 && !FLAG_enable_vfp3) return false; |
| 529 | return (supported_ & (1u << f)) != 0; |
| 530 | } |
| 531 | |
| 532 | // Check whether a feature is currently enabled. |
| 533 | static bool IsEnabled(CpuFeature f) { |
| 534 | return (enabled_ & (1u << f)) != 0; |
| 535 | } |
| 536 | |
| 537 | // Enable a specified feature within a scope. |
| 538 | class Scope BASE_EMBEDDED { |
| 539 | #ifdef DEBUG |
| 540 | public: |
| 541 | explicit Scope(CpuFeature f) { |
| 542 | ASSERT(CpuFeatures::IsSupported(f)); |
| 543 | ASSERT(!Serializer::enabled() || |
| 544 | (found_by_runtime_probing_ & (1u << f)) == 0); |
| 545 | old_enabled_ = CpuFeatures::enabled_; |
| 546 | CpuFeatures::enabled_ |= 1u << f; |
| 547 | } |
| 548 | ~Scope() { CpuFeatures::enabled_ = old_enabled_; } |
| 549 | private: |
| 550 | unsigned old_enabled_; |
| 551 | #else |
| 552 | public: |
| 553 | explicit Scope(CpuFeature f) {} |
| 554 | #endif |
| 555 | }; |
| 556 | |
| 557 | private: |
| 558 | static unsigned supported_; |
| 559 | static unsigned enabled_; |
| 560 | static unsigned found_by_runtime_probing_; |
| 561 | }; |
| 562 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 563 | |
| 564 | typedef int32_t Instr; |
| 565 | |
| 566 | |
| 567 | extern const Instr kMovLrPc; |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 568 | extern const Instr kLdrPCMask; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 569 | extern const Instr kLdrPCPattern; |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 570 | extern const Instr kBlxRegMask; |
| 571 | extern const Instr kBlxRegPattern; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 572 | |
Kristian Monsen | 9dcf7e2 | 2010-06-28 14:14:28 +0100 | [diff] [blame] | 573 | extern const Instr kMovMvnMask; |
| 574 | extern const Instr kMovMvnPattern; |
| 575 | extern const Instr kMovMvnFlip; |
| 576 | |
| 577 | extern const Instr kMovLeaveCCMask; |
| 578 | extern const Instr kMovLeaveCCPattern; |
| 579 | extern const Instr kMovwMask; |
| 580 | extern const Instr kMovwPattern; |
| 581 | extern const Instr kMovwLeaveCCFlip; |
| 582 | |
| 583 | extern const Instr kCmpCmnMask; |
| 584 | extern const Instr kCmpCmnPattern; |
| 585 | extern const Instr kCmpCmnFlip; |
| 586 | |
| 587 | extern const Instr kALUMask; |
| 588 | extern const Instr kAddPattern; |
| 589 | extern const Instr kSubPattern; |
| 590 | extern const Instr kAndPattern; |
| 591 | extern const Instr kBicPattern; |
| 592 | extern const Instr kAddSubFlip; |
| 593 | extern const Instr kAndBicFlip; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 594 | |
| 595 | class Assembler : public Malloced { |
| 596 | public: |
| 597 | // Create an assembler. Instructions and relocation information are emitted |
| 598 | // into a buffer, with the instructions starting from the beginning and the |
| 599 | // relocation information starting from the end of the buffer. See CodeDesc |
| 600 | // for a detailed comment on the layout (globals.h). |
| 601 | // |
| 602 | // If the provided buffer is NULL, the assembler allocates and grows its own |
| 603 | // buffer, and buffer_size determines the initial buffer size. The buffer is |
| 604 | // owned by the assembler and deallocated upon destruction of the assembler. |
| 605 | // |
| 606 | // If the provided buffer is not NULL, the assembler uses the provided buffer |
| 607 | // for code generation and assumes its size to be buffer_size. If the buffer |
| 608 | // is too small, a fatal error occurs. No deallocation of the buffer is done |
| 609 | // upon destruction of the assembler. |
| 610 | Assembler(void* buffer, int buffer_size); |
| 611 | ~Assembler(); |
| 612 | |
| 613 | // GetCode emits any pending (non-emitted) code and fills the descriptor |
| 614 | // desc. GetCode() is idempotent; it returns the same result if no other |
| 615 | // Assembler functions are invoked in between GetCode() calls. |
| 616 | void GetCode(CodeDesc* desc); |
| 617 | |
| 618 | // Label operations & relative jumps (PPUM Appendix D) |
| 619 | // |
| 620 | // Takes a branch opcode (cc) and a label (L) and generates |
| 621 | // either a backward branch or a forward branch and links it |
| 622 | // to the label fixup chain. Usage: |
| 623 | // |
| 624 | // Label L; // unbound label |
| 625 | // j(cc, &L); // forward branch to unbound label |
| 626 | // bind(&L); // bind label to the current pc |
| 627 | // j(cc, &L); // backward branch to bound label |
| 628 | // bind(&L); // illegal: a label may be bound only once |
| 629 | // |
| 630 | // Note: The same Label can be used for forward and backward branches |
| 631 | // but it may be bound only once. |
| 632 | |
| 633 | void bind(Label* L); // binds an unbound label L to the current code position |
| 634 | |
| 635 | // Returns the branch offset to the given label from the current code position |
| 636 | // Links the label to the current position if it is still unbound |
| 637 | // Manages the jump elimination optimization if the second parameter is true. |
| 638 | int branch_offset(Label* L, bool jump_elimination_allowed); |
| 639 | |
| 640 | // Puts a labels target address at the given position. |
| 641 | // The high 8 bits are set to zero. |
| 642 | void label_at_put(Label* L, int at_offset); |
| 643 | |
| 644 | // Return the address in the constant pool of the code target address used by |
| 645 | // the branch/call instruction at pc. |
| 646 | INLINE(static Address target_address_address_at(Address pc)); |
| 647 | |
| 648 | // Read/Modify the code target address in the branch/call instruction at pc. |
| 649 | INLINE(static Address target_address_at(Address pc)); |
| 650 | INLINE(static void set_target_address_at(Address pc, Address target)); |
| 651 | |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 652 | // This sets the branch destination (which is in the constant pool on ARM). |
| 653 | // This is for calls and branches within generated code. |
| 654 | inline static void set_target_at(Address constant_pool_entry, Address target); |
| 655 | |
| 656 | // This sets the branch destination (which is in the constant pool on ARM). |
| 657 | // This is for calls and branches to runtime code. |
| 658 | inline static void set_external_target_at(Address constant_pool_entry, |
| 659 | Address target) { |
| 660 | set_target_at(constant_pool_entry, target); |
| 661 | } |
| 662 | |
| 663 | // Here we are patching the address in the constant pool, not the actual call |
| 664 | // instruction. The address in the constant pool is the same size as a |
| 665 | // pointer. |
| 666 | static const int kCallTargetSize = kPointerSize; |
| 667 | static const int kExternalTargetSize = kPointerSize; |
| 668 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 669 | // Size of an instruction. |
| 670 | static const int kInstrSize = sizeof(Instr); |
| 671 | |
| 672 | // Distance between the instruction referring to the address of the call |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 673 | // target and the return address. |
| 674 | #ifdef USE_BLX |
| 675 | // Call sequence is: |
| 676 | // ldr ip, [pc, #...] @ call address |
| 677 | // blx ip |
| 678 | // @ return address |
| 679 | static const int kCallTargetAddressOffset = 2 * kInstrSize; |
| 680 | #else |
| 681 | // Call sequence is: |
| 682 | // mov lr, pc |
| 683 | // ldr pc, [pc, #...] @ call address |
| 684 | // @ return address |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 685 | static const int kCallTargetAddressOffset = kInstrSize; |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 686 | #endif |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 687 | |
| 688 | // Distance between start of patched return sequence and the emitted address |
| 689 | // to jump to. |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 690 | #ifdef USE_BLX |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 691 | // Patched return sequence is: |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 692 | // ldr ip, [pc, #0] @ emited address and start |
| 693 | // blx ip |
| 694 | static const int kPatchReturnSequenceAddressOffset = 0 * kInstrSize; |
| 695 | #else |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 696 | // Patched return sequence is: |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 697 | // mov lr, pc @ start of sequence |
| 698 | // ldr pc, [pc, #-4] @ emited address |
| 699 | static const int kPatchReturnSequenceAddressOffset = kInstrSize; |
| 700 | #endif |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 701 | |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 702 | // Distance between start of patched debug break slot and the emitted address |
| 703 | // to jump to. |
| 704 | #ifdef USE_BLX |
| 705 | // Patched debug break slot code is: |
| 706 | // ldr ip, [pc, #0] @ emited address and start |
| 707 | // blx ip |
| 708 | static const int kPatchDebugBreakSlotAddressOffset = 0 * kInstrSize; |
| 709 | #else |
| 710 | // Patched debug break slot code is: |
| 711 | // mov lr, pc @ start of sequence |
| 712 | // ldr pc, [pc, #-4] @ emited address |
| 713 | static const int kPatchDebugBreakSlotAddressOffset = kInstrSize; |
| 714 | #endif |
| 715 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 716 | // Difference between address of current opcode and value read from pc |
| 717 | // register. |
| 718 | static const int kPcLoadDelta = 8; |
| 719 | |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 720 | static const int kJSReturnSequenceInstructions = 4; |
| 721 | static const int kDebugBreakSlotInstructions = 3; |
| 722 | static const int kDebugBreakSlotLength = |
| 723 | kDebugBreakSlotInstructions * kInstrSize; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 724 | |
| 725 | // --------------------------------------------------------------------------- |
| 726 | // Code generation |
| 727 | |
| 728 | // Insert the smallest number of nop instructions |
| 729 | // possible to align the pc offset to a multiple |
| 730 | // of m. m must be a power of 2 (>= 4). |
| 731 | void Align(int m); |
Kristian Monsen | 9dcf7e2 | 2010-06-28 14:14:28 +0100 | [diff] [blame] | 732 | // Aligns code to something that's optimal for a jump target for the platform. |
| 733 | void CodeTargetAlign(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 734 | |
| 735 | // Branch instructions |
| 736 | void b(int branch_offset, Condition cond = al); |
| 737 | void bl(int branch_offset, Condition cond = al); |
| 738 | void blx(int branch_offset); // v5 and above |
| 739 | void blx(Register target, Condition cond = al); // v5 and above |
| 740 | void bx(Register target, Condition cond = al); // v5 and above, plus v4t |
| 741 | |
| 742 | // Convenience branch instructions using labels |
| 743 | void b(Label* L, Condition cond = al) { |
| 744 | b(branch_offset(L, cond == al), cond); |
| 745 | } |
| 746 | void b(Condition cond, Label* L) { b(branch_offset(L, cond == al), cond); } |
| 747 | void bl(Label* L, Condition cond = al) { bl(branch_offset(L, false), cond); } |
| 748 | void bl(Condition cond, Label* L) { bl(branch_offset(L, false), cond); } |
| 749 | void blx(Label* L) { blx(branch_offset(L, false)); } // v5 and above |
| 750 | |
| 751 | // Data-processing instructions |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 752 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 753 | void and_(Register dst, Register src1, const Operand& src2, |
| 754 | SBit s = LeaveCC, Condition cond = al); |
| 755 | |
| 756 | void eor(Register dst, Register src1, const Operand& src2, |
| 757 | SBit s = LeaveCC, Condition cond = al); |
| 758 | |
| 759 | void sub(Register dst, Register src1, const Operand& src2, |
| 760 | SBit s = LeaveCC, Condition cond = al); |
| 761 | void sub(Register dst, Register src1, Register src2, |
| 762 | SBit s = LeaveCC, Condition cond = al) { |
| 763 | sub(dst, src1, Operand(src2), s, cond); |
| 764 | } |
| 765 | |
| 766 | void rsb(Register dst, Register src1, const Operand& src2, |
| 767 | SBit s = LeaveCC, Condition cond = al); |
| 768 | |
| 769 | void add(Register dst, Register src1, const Operand& src2, |
| 770 | SBit s = LeaveCC, Condition cond = al); |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 771 | void add(Register dst, Register src1, Register src2, |
| 772 | SBit s = LeaveCC, Condition cond = al) { |
| 773 | add(dst, src1, Operand(src2), s, cond); |
| 774 | } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 775 | |
| 776 | void adc(Register dst, Register src1, const Operand& src2, |
| 777 | SBit s = LeaveCC, Condition cond = al); |
| 778 | |
| 779 | void sbc(Register dst, Register src1, const Operand& src2, |
| 780 | SBit s = LeaveCC, Condition cond = al); |
| 781 | |
| 782 | void rsc(Register dst, Register src1, const Operand& src2, |
| 783 | SBit s = LeaveCC, Condition cond = al); |
| 784 | |
| 785 | void tst(Register src1, const Operand& src2, Condition cond = al); |
| 786 | void tst(Register src1, Register src2, Condition cond = al) { |
| 787 | tst(src1, Operand(src2), cond); |
| 788 | } |
| 789 | |
| 790 | void teq(Register src1, const Operand& src2, Condition cond = al); |
| 791 | |
| 792 | void cmp(Register src1, const Operand& src2, Condition cond = al); |
| 793 | void cmp(Register src1, Register src2, Condition cond = al) { |
| 794 | cmp(src1, Operand(src2), cond); |
| 795 | } |
| 796 | |
| 797 | void cmn(Register src1, const Operand& src2, Condition cond = al); |
| 798 | |
| 799 | void orr(Register dst, Register src1, const Operand& src2, |
| 800 | SBit s = LeaveCC, Condition cond = al); |
| 801 | void orr(Register dst, Register src1, Register src2, |
| 802 | SBit s = LeaveCC, Condition cond = al) { |
| 803 | orr(dst, src1, Operand(src2), s, cond); |
| 804 | } |
| 805 | |
| 806 | void mov(Register dst, const Operand& src, |
| 807 | SBit s = LeaveCC, Condition cond = al); |
| 808 | void mov(Register dst, Register src, SBit s = LeaveCC, Condition cond = al) { |
| 809 | mov(dst, Operand(src), s, cond); |
| 810 | } |
| 811 | |
Kristian Monsen | 9dcf7e2 | 2010-06-28 14:14:28 +0100 | [diff] [blame] | 812 | // ARMv7 instructions for loading a 32 bit immediate in two instructions. |
| 813 | // This may actually emit a different mov instruction, but on an ARMv7 it |
| 814 | // is guaranteed to only emit one instruction. |
| 815 | void movw(Register reg, uint32_t immediate, Condition cond = al); |
| 816 | // The constant for movt should be in the range 0-0xffff. |
| 817 | void movt(Register reg, uint32_t immediate, Condition cond = al); |
| 818 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 819 | void bic(Register dst, Register src1, const Operand& src2, |
| 820 | SBit s = LeaveCC, Condition cond = al); |
| 821 | |
| 822 | void mvn(Register dst, const Operand& src, |
| 823 | SBit s = LeaveCC, Condition cond = al); |
| 824 | |
| 825 | // Multiply instructions |
| 826 | |
| 827 | void mla(Register dst, Register src1, Register src2, Register srcA, |
| 828 | SBit s = LeaveCC, Condition cond = al); |
| 829 | |
| 830 | void mul(Register dst, Register src1, Register src2, |
| 831 | SBit s = LeaveCC, Condition cond = al); |
| 832 | |
| 833 | void smlal(Register dstL, Register dstH, Register src1, Register src2, |
| 834 | SBit s = LeaveCC, Condition cond = al); |
| 835 | |
| 836 | void smull(Register dstL, Register dstH, Register src1, Register src2, |
| 837 | SBit s = LeaveCC, Condition cond = al); |
| 838 | |
| 839 | void umlal(Register dstL, Register dstH, Register src1, Register src2, |
| 840 | SBit s = LeaveCC, Condition cond = al); |
| 841 | |
| 842 | void umull(Register dstL, Register dstH, Register src1, Register src2, |
| 843 | SBit s = LeaveCC, Condition cond = al); |
| 844 | |
| 845 | // Miscellaneous arithmetic instructions |
| 846 | |
| 847 | void clz(Register dst, Register src, Condition cond = al); // v5 and above |
| 848 | |
Kristian Monsen | 50ef84f | 2010-07-29 15:18:00 +0100 | [diff] [blame] | 849 | // Saturating instructions. v6 and above. |
| 850 | |
| 851 | // Unsigned saturate. |
| 852 | // |
| 853 | // Saturate an optionally shifted signed value to an unsigned range. |
| 854 | // |
| 855 | // usat dst, #satpos, src |
| 856 | // usat dst, #satpos, src, lsl #sh |
| 857 | // usat dst, #satpos, src, asr #sh |
| 858 | // |
| 859 | // Register dst will contain: |
| 860 | // |
| 861 | // 0, if s < 0 |
| 862 | // (1 << satpos) - 1, if s > ((1 << satpos) - 1) |
| 863 | // s, otherwise |
| 864 | // |
| 865 | // where s is the contents of src after shifting (if used.) |
| 866 | void usat(Register dst, int satpos, const Operand& src, Condition cond = al); |
| 867 | |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 868 | // Bitfield manipulation instructions. v7 and above. |
| 869 | |
| 870 | void ubfx(Register dst, Register src, int lsb, int width, |
| 871 | Condition cond = al); |
| 872 | |
| 873 | void sbfx(Register dst, Register src, int lsb, int width, |
| 874 | Condition cond = al); |
| 875 | |
| 876 | void bfc(Register dst, int lsb, int width, Condition cond = al); |
| 877 | |
| 878 | void bfi(Register dst, Register src, int lsb, int width, |
| 879 | Condition cond = al); |
| 880 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 881 | // Status register access instructions |
| 882 | |
| 883 | void mrs(Register dst, SRegister s, Condition cond = al); |
| 884 | void msr(SRegisterFieldMask fields, const Operand& src, Condition cond = al); |
| 885 | |
| 886 | // Load/Store instructions |
| 887 | void ldr(Register dst, const MemOperand& src, Condition cond = al); |
| 888 | void str(Register src, const MemOperand& dst, Condition cond = al); |
| 889 | void ldrb(Register dst, const MemOperand& src, Condition cond = al); |
| 890 | void strb(Register src, const MemOperand& dst, Condition cond = al); |
| 891 | void ldrh(Register dst, const MemOperand& src, Condition cond = al); |
| 892 | void strh(Register src, const MemOperand& dst, Condition cond = al); |
| 893 | void ldrsb(Register dst, const MemOperand& src, Condition cond = al); |
| 894 | void ldrsh(Register dst, const MemOperand& src, Condition cond = al); |
Leon Clarke | f7060e2 | 2010-06-03 12:02:55 +0100 | [diff] [blame] | 895 | void ldrd(Register dst1, |
| 896 | Register dst2, |
| 897 | const MemOperand& src, Condition cond = al); |
| 898 | void strd(Register src1, |
| 899 | Register src2, |
| 900 | const MemOperand& dst, Condition cond = al); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 901 | |
| 902 | // Load/Store multiple instructions |
| 903 | void ldm(BlockAddrMode am, Register base, RegList dst, Condition cond = al); |
| 904 | void stm(BlockAddrMode am, Register base, RegList src, Condition cond = al); |
| 905 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 906 | // Exception-generating instructions and debugging support |
| 907 | void stop(const char* msg); |
| 908 | |
| 909 | void bkpt(uint32_t imm16); // v5 and above |
| 910 | void swi(uint32_t imm24, Condition cond = al); |
| 911 | |
| 912 | // Coprocessor instructions |
| 913 | |
| 914 | void cdp(Coprocessor coproc, int opcode_1, |
| 915 | CRegister crd, CRegister crn, CRegister crm, |
| 916 | int opcode_2, Condition cond = al); |
| 917 | |
| 918 | void cdp2(Coprocessor coproc, int opcode_1, |
| 919 | CRegister crd, CRegister crn, CRegister crm, |
| 920 | int opcode_2); // v5 and above |
| 921 | |
| 922 | void mcr(Coprocessor coproc, int opcode_1, |
| 923 | Register rd, CRegister crn, CRegister crm, |
| 924 | int opcode_2 = 0, Condition cond = al); |
| 925 | |
| 926 | void mcr2(Coprocessor coproc, int opcode_1, |
| 927 | Register rd, CRegister crn, CRegister crm, |
| 928 | int opcode_2 = 0); // v5 and above |
| 929 | |
| 930 | void mrc(Coprocessor coproc, int opcode_1, |
| 931 | Register rd, CRegister crn, CRegister crm, |
| 932 | int opcode_2 = 0, Condition cond = al); |
| 933 | |
| 934 | void mrc2(Coprocessor coproc, int opcode_1, |
| 935 | Register rd, CRegister crn, CRegister crm, |
| 936 | int opcode_2 = 0); // v5 and above |
| 937 | |
| 938 | void ldc(Coprocessor coproc, CRegister crd, const MemOperand& src, |
| 939 | LFlag l = Short, Condition cond = al); |
| 940 | void ldc(Coprocessor coproc, CRegister crd, Register base, int option, |
| 941 | LFlag l = Short, Condition cond = al); |
| 942 | |
| 943 | void ldc2(Coprocessor coproc, CRegister crd, const MemOperand& src, |
| 944 | LFlag l = Short); // v5 and above |
| 945 | void ldc2(Coprocessor coproc, CRegister crd, Register base, int option, |
| 946 | LFlag l = Short); // v5 and above |
| 947 | |
| 948 | void stc(Coprocessor coproc, CRegister crd, const MemOperand& dst, |
| 949 | LFlag l = Short, Condition cond = al); |
| 950 | void stc(Coprocessor coproc, CRegister crd, Register base, int option, |
| 951 | LFlag l = Short, Condition cond = al); |
| 952 | |
| 953 | void stc2(Coprocessor coproc, CRegister crd, const MemOperand& dst, |
| 954 | LFlag l = Short); // v5 and above |
| 955 | void stc2(Coprocessor coproc, CRegister crd, Register base, int option, |
| 956 | LFlag l = Short); // v5 and above |
| 957 | |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 958 | // Support for VFP. |
| 959 | // All these APIs support S0 to S31 and D0 to D15. |
| 960 | // Currently these APIs do not support extended D registers, i.e, D16 to D31. |
| 961 | // However, some simple modifications can allow |
| 962 | // these APIs to support D16 to D31. |
| 963 | |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 964 | void vldr(const DwVfpRegister dst, |
| 965 | const Register base, |
| 966 | int offset, // Offset must be a multiple of 4. |
| 967 | const Condition cond = al); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 968 | |
| 969 | void vldr(const SwVfpRegister dst, |
| 970 | const Register base, |
| 971 | int offset, // Offset must be a multiple of 4. |
| 972 | const Condition cond = al); |
| 973 | |
Leon Clarke | d91b9f7 | 2010-01-27 17:25:45 +0000 | [diff] [blame] | 974 | void vstr(const DwVfpRegister src, |
| 975 | const Register base, |
| 976 | int offset, // Offset must be a multiple of 4. |
| 977 | const Condition cond = al); |
Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 978 | |
Iain Merrick | 7568138 | 2010-08-19 15:07:18 +0100 | [diff] [blame] | 979 | void vstr(const SwVfpRegister src, |
| 980 | const Register base, |
| 981 | int offset, // Offset must be a multiple of 4. |
| 982 | const Condition cond = al); |
| 983 | |
Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 984 | void vmov(const DwVfpRegister dst, |
Ben Murdoch | 3bec4d2 | 2010-07-22 14:51:16 +0100 | [diff] [blame] | 985 | double imm, |
| 986 | const Condition cond = al); |
| 987 | void vmov(const SwVfpRegister dst, |
| 988 | const SwVfpRegister src, |
| 989 | const Condition cond = al); |
| 990 | void vmov(const DwVfpRegister dst, |
Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 991 | const DwVfpRegister src, |
| 992 | const Condition cond = al); |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 993 | void vmov(const DwVfpRegister dst, |
| 994 | const Register src1, |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 995 | const Register src2, |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 996 | const Condition cond = al); |
| 997 | void vmov(const Register dst1, |
| 998 | const Register dst2, |
| 999 | const DwVfpRegister src, |
| 1000 | const Condition cond = al); |
| 1001 | void vmov(const SwVfpRegister dst, |
| 1002 | const Register src, |
| 1003 | const Condition cond = al); |
| 1004 | void vmov(const Register dst, |
| 1005 | const SwVfpRegister src, |
| 1006 | const Condition cond = al); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 1007 | void vcvt_f64_s32(const DwVfpRegister dst, |
| 1008 | const SwVfpRegister src, |
| 1009 | const Condition cond = al); |
| 1010 | void vcvt_f32_s32(const SwVfpRegister dst, |
| 1011 | const SwVfpRegister src, |
| 1012 | const Condition cond = al); |
| 1013 | void vcvt_f64_u32(const DwVfpRegister dst, |
| 1014 | const SwVfpRegister src, |
| 1015 | const Condition cond = al); |
| 1016 | void vcvt_s32_f64(const SwVfpRegister dst, |
| 1017 | const DwVfpRegister src, |
| 1018 | const Condition cond = al); |
| 1019 | void vcvt_u32_f64(const SwVfpRegister dst, |
| 1020 | const DwVfpRegister src, |
| 1021 | const Condition cond = al); |
| 1022 | void vcvt_f64_f32(const DwVfpRegister dst, |
| 1023 | const SwVfpRegister src, |
| 1024 | const Condition cond = al); |
| 1025 | void vcvt_f32_f64(const SwVfpRegister dst, |
| 1026 | const DwVfpRegister src, |
| 1027 | const Condition cond = al); |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 1028 | |
| 1029 | void vadd(const DwVfpRegister dst, |
| 1030 | const DwVfpRegister src1, |
| 1031 | const DwVfpRegister src2, |
| 1032 | const Condition cond = al); |
| 1033 | void vsub(const DwVfpRegister dst, |
| 1034 | const DwVfpRegister src1, |
| 1035 | const DwVfpRegister src2, |
| 1036 | const Condition cond = al); |
| 1037 | void vmul(const DwVfpRegister dst, |
| 1038 | const DwVfpRegister src1, |
| 1039 | const DwVfpRegister src2, |
| 1040 | const Condition cond = al); |
| 1041 | void vdiv(const DwVfpRegister dst, |
| 1042 | const DwVfpRegister src1, |
| 1043 | const DwVfpRegister src2, |
| 1044 | const Condition cond = al); |
| 1045 | void vcmp(const DwVfpRegister src1, |
| 1046 | const DwVfpRegister src2, |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 1047 | const SBit s = LeaveCC, |
| 1048 | const Condition cond = al); |
Iain Merrick | 7568138 | 2010-08-19 15:07:18 +0100 | [diff] [blame] | 1049 | void vcmp(const DwVfpRegister src1, |
| 1050 | const double src2, |
| 1051 | const SBit s = LeaveCC, |
| 1052 | const Condition cond = al); |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 1053 | void vmrs(const Register dst, |
| 1054 | const Condition cond = al); |
Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 1055 | void vsqrt(const DwVfpRegister dst, |
| 1056 | const DwVfpRegister src, |
| 1057 | const Condition cond = al); |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 1058 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1059 | // Pseudo instructions |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 1060 | void nop(int type = 0); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1061 | |
| 1062 | void push(Register src, Condition cond = al) { |
| 1063 | str(src, MemOperand(sp, 4, NegPreIndex), cond); |
| 1064 | } |
| 1065 | |
| 1066 | void pop(Register dst, Condition cond = al) { |
| 1067 | ldr(dst, MemOperand(sp, 4, PostIndex), cond); |
| 1068 | } |
| 1069 | |
| 1070 | void pop() { |
| 1071 | add(sp, sp, Operand(kPointerSize)); |
| 1072 | } |
| 1073 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1074 | // Jump unconditionally to given label. |
| 1075 | void jmp(Label* L) { b(L, al); } |
| 1076 | |
| 1077 | // Check the code size generated from label to here. |
| 1078 | int InstructionsGeneratedSince(Label* l) { |
| 1079 | return (pc_offset() - l->pos()) / kInstrSize; |
| 1080 | } |
| 1081 | |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 1082 | // Check whether an immediate fits an addressing mode 1 instruction. |
| 1083 | bool ImmediateFitsAddrMode1Instruction(int32_t imm32); |
| 1084 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 1085 | // Class for scoping postponing the constant pool generation. |
| 1086 | class BlockConstPoolScope { |
| 1087 | public: |
| 1088 | explicit BlockConstPoolScope(Assembler* assem) : assem_(assem) { |
| 1089 | assem_->StartBlockConstPool(); |
| 1090 | } |
| 1091 | ~BlockConstPoolScope() { |
| 1092 | assem_->EndBlockConstPool(); |
| 1093 | } |
| 1094 | |
| 1095 | private: |
| 1096 | Assembler* assem_; |
| 1097 | |
| 1098 | DISALLOW_IMPLICIT_CONSTRUCTORS(BlockConstPoolScope); |
| 1099 | }; |
| 1100 | |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 1101 | // Postpone the generation of the constant pool for the specified number of |
| 1102 | // instructions. |
| 1103 | void BlockConstPoolFor(int instructions); |
| 1104 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1105 | // Debugging |
| 1106 | |
| 1107 | // Mark address of the ExitJSFrame code. |
| 1108 | void RecordJSReturn(); |
| 1109 | |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 1110 | // Mark address of a debug break slot. |
| 1111 | void RecordDebugBreakSlot(); |
| 1112 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1113 | // Record a comment relocation entry that can be used by a disassembler. |
| 1114 | // Use --debug_code to enable. |
| 1115 | void RecordComment(const char* msg); |
| 1116 | |
| 1117 | void RecordPosition(int pos); |
| 1118 | void RecordStatementPosition(int pos); |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 1119 | bool WriteRecordedPositions(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1120 | |
| 1121 | int pc_offset() const { return pc_ - buffer_; } |
| 1122 | int current_position() const { return current_position_; } |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 1123 | int current_statement_position() const { return current_statement_position_; } |
| 1124 | |
Leon Clarke | f7060e2 | 2010-06-03 12:02:55 +0100 | [diff] [blame] | 1125 | bool can_peephole_optimize(int instructions) { |
| 1126 | if (!FLAG_peephole_optimization) return false; |
| 1127 | if (last_bound_pos_ > pc_offset() - instructions * kInstrSize) return false; |
| 1128 | return reloc_info_writer.last_pc() <= pc_ - instructions * kInstrSize; |
| 1129 | } |
| 1130 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 1131 | // Read/patch instructions |
| 1132 | static Instr instr_at(byte* pc) { return *reinterpret_cast<Instr*>(pc); } |
| 1133 | static void instr_at_put(byte* pc, Instr instr) { |
| 1134 | *reinterpret_cast<Instr*>(pc) = instr; |
| 1135 | } |
| 1136 | static bool IsNop(Instr instr, int type = 0); |
| 1137 | static bool IsBranch(Instr instr); |
| 1138 | static int GetBranchOffset(Instr instr); |
| 1139 | static bool IsLdrRegisterImmediate(Instr instr); |
| 1140 | static int GetLdrRegisterImmediateOffset(Instr instr); |
| 1141 | static Instr SetLdrRegisterImmediateOffset(Instr instr, int offset); |
Kristian Monsen | 50ef84f | 2010-07-29 15:18:00 +0100 | [diff] [blame] | 1142 | static bool IsStrRegisterImmediate(Instr instr); |
| 1143 | static Instr SetStrRegisterImmediateOffset(Instr instr, int offset); |
| 1144 | static bool IsAddRegisterImmediate(Instr instr); |
| 1145 | static Instr SetAddRegisterImmediateOffset(Instr instr, int offset); |
Leon Clarke | f7060e2 | 2010-06-03 12:02:55 +0100 | [diff] [blame] | 1146 | static Register GetRd(Instr instr); |
| 1147 | static bool IsPush(Instr instr); |
| 1148 | static bool IsPop(Instr instr); |
| 1149 | static bool IsStrRegFpOffset(Instr instr); |
| 1150 | static bool IsLdrRegFpOffset(Instr instr); |
| 1151 | static bool IsStrRegFpNegOffset(Instr instr); |
| 1152 | static bool IsLdrRegFpNegOffset(Instr instr); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 1153 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1154 | |
| 1155 | protected: |
| 1156 | int buffer_space() const { return reloc_info_writer.pos() - pc_; } |
| 1157 | |
| 1158 | // Read/patch instructions |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1159 | Instr instr_at(int pos) { return *reinterpret_cast<Instr*>(buffer_ + pos); } |
| 1160 | void instr_at_put(int pos, Instr instr) { |
| 1161 | *reinterpret_cast<Instr*>(buffer_ + pos) = instr; |
| 1162 | } |
| 1163 | |
| 1164 | // Decode branch instruction at pos and return branch target pos |
| 1165 | int target_at(int pos); |
| 1166 | |
| 1167 | // Patch branch instruction at pos to branch to given branch target pos |
| 1168 | void target_at_put(int pos, int target_pos); |
| 1169 | |
| 1170 | // Check if is time to emit a constant pool for pending reloc info entries |
| 1171 | void CheckConstPool(bool force_emit, bool require_jump); |
| 1172 | |
| 1173 | // Block the emission of the constant pool before pc_offset |
| 1174 | void BlockConstPoolBefore(int pc_offset) { |
| 1175 | if (no_const_pool_before_ < pc_offset) no_const_pool_before_ = pc_offset; |
| 1176 | } |
| 1177 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 1178 | void StartBlockConstPool() { |
| 1179 | const_pool_blocked_nesting_++; |
| 1180 | } |
| 1181 | void EndBlockConstPool() { |
| 1182 | const_pool_blocked_nesting_--; |
| 1183 | } |
Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 1184 | bool is_const_pool_blocked() const { return const_pool_blocked_nesting_ > 0; } |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 1185 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1186 | private: |
| 1187 | // Code buffer: |
| 1188 | // The buffer into which code and relocation info are generated. |
| 1189 | byte* buffer_; |
| 1190 | int buffer_size_; |
| 1191 | // True if the assembler owns the buffer, false if buffer is external. |
| 1192 | bool own_buffer_; |
| 1193 | |
| 1194 | // Buffer size and constant pool distance are checked together at regular |
| 1195 | // intervals of kBufferCheckInterval emitted bytes |
| 1196 | static const int kBufferCheckInterval = 1*KB/2; |
| 1197 | int next_buffer_check_; // pc offset of next buffer check |
| 1198 | |
| 1199 | // Code generation |
| 1200 | // The relocation writer's position is at least kGap bytes below the end of |
| 1201 | // the generated instructions. This is so that multi-instruction sequences do |
| 1202 | // not have to check for overflow. The same is true for writes of large |
| 1203 | // relocation info entries. |
| 1204 | static const int kGap = 32; |
| 1205 | byte* pc_; // the program counter; moves forward |
| 1206 | |
| 1207 | // Constant pool generation |
| 1208 | // Pools are emitted in the instruction stream, preferably after unconditional |
| 1209 | // jumps or after returns from functions (in dead code locations). |
| 1210 | // If a long code sequence does not contain unconditional jumps, it is |
| 1211 | // necessary to emit the constant pool before the pool gets too far from the |
| 1212 | // location it is accessed from. In this case, we emit a jump over the emitted |
| 1213 | // constant pool. |
| 1214 | // Constants in the pool may be addresses of functions that gets relocated; |
| 1215 | // if so, a relocation info entry is associated to the constant pool entry. |
| 1216 | |
| 1217 | // Repeated checking whether the constant pool should be emitted is rather |
| 1218 | // expensive. By default we only check again once a number of instructions |
| 1219 | // has been generated. That also means that the sizing of the buffers is not |
| 1220 | // an exact science, and that we rely on some slop to not overrun buffers. |
| 1221 | static const int kCheckConstIntervalInst = 32; |
| 1222 | static const int kCheckConstInterval = kCheckConstIntervalInst * kInstrSize; |
| 1223 | |
| 1224 | |
| 1225 | // Pools are emitted after function return and in dead code at (more or less) |
| 1226 | // regular intervals of kDistBetweenPools bytes |
| 1227 | static const int kDistBetweenPools = 1*KB; |
| 1228 | |
| 1229 | // Constants in pools are accessed via pc relative addressing, which can |
| 1230 | // reach +/-4KB thereby defining a maximum distance between the instruction |
| 1231 | // and the accessed constant. We satisfy this constraint by limiting the |
| 1232 | // distance between pools. |
| 1233 | static const int kMaxDistBetweenPools = 4*KB - 2*kBufferCheckInterval; |
| 1234 | |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 1235 | // Emission of the constant pool may be blocked in some code sequences. |
| 1236 | int const_pool_blocked_nesting_; // Block emission if this is not zero. |
| 1237 | int no_const_pool_before_; // Block emission before this pc offset. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1238 | |
| 1239 | // Keep track of the last emitted pool to guarantee a maximal distance |
| 1240 | int last_const_pool_end_; // pc offset following the last constant pool |
| 1241 | |
| 1242 | // Relocation info generation |
| 1243 | // Each relocation is encoded as a variable size value |
| 1244 | static const int kMaxRelocSize = RelocInfoWriter::kMaxSize; |
| 1245 | RelocInfoWriter reloc_info_writer; |
| 1246 | // Relocation info records are also used during code generation as temporary |
| 1247 | // containers for constants and code target addresses until they are emitted |
| 1248 | // to the constant pool. These pending relocation info records are temporarily |
| 1249 | // stored in a separate buffer until a constant pool is emitted. |
| 1250 | // If every instruction in a long sequence is accessing the pool, we need one |
| 1251 | // pending relocation entry per instruction. |
| 1252 | static const int kMaxNumPRInfo = kMaxDistBetweenPools/kInstrSize; |
| 1253 | RelocInfo prinfo_[kMaxNumPRInfo]; // the buffer of pending relocation info |
| 1254 | int num_prinfo_; // number of pending reloc info entries in the buffer |
| 1255 | |
| 1256 | // The bound position, before this we cannot do instruction elimination. |
| 1257 | int last_bound_pos_; |
| 1258 | |
| 1259 | // source position information |
| 1260 | int current_position_; |
| 1261 | int current_statement_position_; |
| 1262 | int written_position_; |
| 1263 | int written_statement_position_; |
| 1264 | |
| 1265 | // Code emission |
| 1266 | inline void CheckBuffer(); |
| 1267 | void GrowBuffer(); |
| 1268 | inline void emit(Instr x); |
| 1269 | |
| 1270 | // Instruction generation |
| 1271 | void addrmod1(Instr instr, Register rn, Register rd, const Operand& x); |
| 1272 | void addrmod2(Instr instr, Register rd, const MemOperand& x); |
| 1273 | void addrmod3(Instr instr, Register rd, const MemOperand& x); |
| 1274 | void addrmod4(Instr instr, Register rn, RegList rl); |
| 1275 | void addrmod5(Instr instr, CRegister crd, const MemOperand& x); |
| 1276 | |
| 1277 | // Labels |
| 1278 | void print(Label* L); |
| 1279 | void bind_to(Label* L, int pos); |
| 1280 | void link_to(Label* L, Label* appendix); |
| 1281 | void next(Label* L); |
| 1282 | |
| 1283 | // Record reloc info for current pc_ |
| 1284 | void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); |
| 1285 | |
| 1286 | friend class RegExpMacroAssemblerARM; |
| 1287 | friend class RelocInfo; |
| 1288 | friend class CodePatcher; |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 1289 | friend class BlockConstPoolScope; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1290 | }; |
| 1291 | |
| 1292 | } } // namespace v8::internal |
| 1293 | |
| 1294 | #endif // V8_ARM_ASSEMBLER_ARM_H_ |