Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +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 are |
| 6 | // 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 distribution. |
| 14 | // |
| 15 | // - Neither the name of Sun Microsystems or the names of contributors may |
| 16 | // be used to endorse or promote products derived from this software without |
| 17 | // specific prior written permission. |
| 18 | // |
| 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
| 20 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 21 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 22 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
| 23 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 24 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 25 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 26 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 27 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 28 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 29 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | |
| 31 | // The original source code covered by the above license above has been |
| 32 | // modified significantly by Google Inc. |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 33 | // Copyright 2012 the V8 project authors. All rights reserved. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 34 | |
| 35 | |
| 36 | #ifndef V8_MIPS_ASSEMBLER_MIPS_H_ |
| 37 | #define V8_MIPS_ASSEMBLER_MIPS_H_ |
| 38 | |
| 39 | #include <stdio.h> |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 40 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 41 | #include <set> |
| 42 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 43 | #include "src/assembler.h" |
| 44 | #include "src/mips/constants-mips.h" |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 45 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 46 | namespace v8 { |
| 47 | namespace internal { |
| 48 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 49 | // clang-format off |
| 50 | #define GENERAL_REGISTERS(V) \ |
| 51 | V(zero_reg) V(at) V(v0) V(v1) V(a0) V(a1) V(a2) V(a3) \ |
| 52 | V(t0) V(t1) V(t2) V(t3) V(t4) V(t5) V(t6) V(t7) \ |
| 53 | V(s0) V(s1) V(s2) V(s3) V(s4) V(s5) V(s6) V(s7) V(t8) V(t9) \ |
| 54 | V(k0) V(k1) V(gp) V(sp) V(fp) V(ra) |
| 55 | |
| 56 | #define ALLOCATABLE_GENERAL_REGISTERS(V) \ |
| 57 | V(v0) V(v1) V(a0) V(a1) V(a2) V(a3) \ |
| 58 | V(t0) V(t1) V(t2) V(t3) V(t4) V(t5) V(t6) V(s7) |
| 59 | |
| 60 | #define DOUBLE_REGISTERS(V) \ |
| 61 | V(f0) V(f1) V(f2) V(f3) V(f4) V(f5) V(f6) V(f7) \ |
| 62 | V(f8) V(f9) V(f10) V(f11) V(f12) V(f13) V(f14) V(f15) \ |
| 63 | V(f16) V(f17) V(f18) V(f19) V(f20) V(f21) V(f22) V(f23) \ |
| 64 | V(f24) V(f25) V(f26) V(f27) V(f28) V(f29) V(f30) V(f31) |
| 65 | |
| 66 | #define ALLOCATABLE_DOUBLE_REGISTERS(V) \ |
| 67 | V(f0) V(f2) V(f4) V(f6) V(f8) V(f10) V(f12) V(f14) \ |
| 68 | V(f16) V(f18) V(f20) V(f22) V(f24) V(f26) |
| 69 | // clang-format on |
| 70 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 71 | // CPU Registers. |
| 72 | // |
| 73 | // 1) We would prefer to use an enum, but enum values are assignment- |
| 74 | // compatible with int, which has caused code-generation bugs. |
| 75 | // |
| 76 | // 2) We would prefer to use a class instead of a struct but we don't like |
| 77 | // the register initialization to depend on the particular initialization |
| 78 | // order (which appears to be different on OS X, Linux, and Windows for the |
| 79 | // installed versions of C++ we tried). Using a struct permits C-style |
| 80 | // "initialization". Also, the Register objects cannot be const as this |
| 81 | // forces initialization stubs in MSVC, making us dependent on initialization |
| 82 | // order. |
| 83 | // |
| 84 | // 3) By not using an enum, we are possibly preventing the compiler from |
| 85 | // doing certain constant folds, which may significantly reduce the |
| 86 | // code generated for some assembly instructions (because they boil down |
| 87 | // to a few constants). If this is a problem, we could change the code |
| 88 | // such that we use an enum in optimized mode, and the struct in debug |
| 89 | // mode. This way we get the compile-time error checking in debug mode |
| 90 | // and best performance in optimized code. |
| 91 | |
| 92 | |
| 93 | // ----------------------------------------------------------------------------- |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 94 | // Implementation of Register and FPURegister. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 95 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 96 | struct Register { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 97 | static const int kCpRegister = 23; // cp (s7) is the 23rd register. |
| 98 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 99 | enum Code { |
| 100 | #define REGISTER_CODE(R) kCode_##R, |
| 101 | GENERAL_REGISTERS(REGISTER_CODE) |
| 102 | #undef REGISTER_CODE |
| 103 | kAfterLast, |
| 104 | kCode_no_reg = -1 |
| 105 | }; |
| 106 | |
| 107 | static const int kNumRegisters = Code::kAfterLast; |
| 108 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 109 | #if defined(V8_TARGET_LITTLE_ENDIAN) |
| 110 | static const int kMantissaOffset = 0; |
| 111 | static const int kExponentOffset = 4; |
| 112 | #elif defined(V8_TARGET_BIG_ENDIAN) |
| 113 | static const int kMantissaOffset = 4; |
| 114 | static const int kExponentOffset = 0; |
| 115 | #else |
| 116 | #error Unknown endianness |
| 117 | #endif |
| 118 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 119 | |
| 120 | static Register from_code(int code) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 121 | DCHECK(code >= 0); |
| 122 | DCHECK(code < kNumRegisters); |
| 123 | Register r = {code}; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 124 | return r; |
| 125 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 126 | const char* ToString(); |
| 127 | bool IsAllocatable() const; |
| 128 | bool is_valid() const { return 0 <= reg_code && reg_code < kNumRegisters; } |
| 129 | bool is(Register reg) const { return reg_code == reg.reg_code; } |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 130 | int code() const { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 131 | DCHECK(is_valid()); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 132 | return reg_code; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 133 | } |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 134 | int bit() const { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 135 | DCHECK(is_valid()); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 136 | return 1 << reg_code; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | // Unfortunately we can't make this private in a struct. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 140 | int reg_code; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 141 | }; |
| 142 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 143 | // s7: context register |
| 144 | // s3: lithium scratch |
| 145 | // s4: lithium scratch2 |
| 146 | #define DECLARE_REGISTER(R) const Register R = {Register::kCode_##R}; |
| 147 | GENERAL_REGISTERS(DECLARE_REGISTER) |
| 148 | #undef DECLARE_REGISTER |
| 149 | const Register no_reg = {Register::kCode_no_reg}; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 150 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 151 | |
| 152 | int ToNumber(Register reg); |
| 153 | |
| 154 | Register ToRegister(int num); |
| 155 | |
| 156 | // Coprocessor register. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 157 | struct DoubleRegister { |
| 158 | enum Code { |
| 159 | #define REGISTER_CODE(R) kCode_##R, |
| 160 | DOUBLE_REGISTERS(REGISTER_CODE) |
| 161 | #undef REGISTER_CODE |
| 162 | kAfterLast, |
| 163 | kCode_no_reg = -1 |
| 164 | }; |
| 165 | |
| 166 | static const int kMaxNumRegisters = Code::kAfterLast; |
| 167 | |
| 168 | inline static int NumRegisters(); |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 169 | |
| 170 | // TODO(plind): Warning, inconsistent numbering here. kNumFPURegisters refers |
| 171 | // to number of 32-bit FPU regs, but kNumAllocatableRegisters refers to |
| 172 | // number of Double regs (64-bit regs, or FPU-reg-pairs). |
| 173 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 174 | const char* ToString(); |
| 175 | bool IsAllocatable() const; |
| 176 | bool is_valid() const { return 0 <= reg_code && reg_code < kMaxNumRegisters; } |
| 177 | bool is(DoubleRegister reg) const { return reg_code == reg.reg_code; } |
| 178 | DoubleRegister low() const { |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 179 | // Find low reg of a Double-reg pair, which is the reg itself. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 180 | DCHECK(reg_code % 2 == 0); // Specified Double reg must be even. |
| 181 | DoubleRegister reg; |
| 182 | reg.reg_code = reg_code; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 183 | DCHECK(reg.is_valid()); |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 184 | return reg; |
| 185 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 186 | DoubleRegister high() const { |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 187 | // Find high reg of a Doubel-reg pair, which is reg + 1. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 188 | DCHECK(reg_code % 2 == 0); // Specified Double reg must be even. |
| 189 | DoubleRegister reg; |
| 190 | reg.reg_code = reg_code + 1; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 191 | DCHECK(reg.is_valid()); |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 192 | return reg; |
| 193 | } |
| 194 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 195 | int code() const { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 196 | DCHECK(is_valid()); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 197 | return reg_code; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 198 | } |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 199 | int bit() const { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 200 | DCHECK(is_valid()); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 201 | return 1 << reg_code; |
| 202 | } |
| 203 | |
| 204 | static DoubleRegister from_code(int code) { |
| 205 | DoubleRegister r = {code}; |
| 206 | return r; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 207 | } |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 208 | void setcode(int f) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 209 | reg_code = f; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 210 | DCHECK(is_valid()); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 211 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 212 | // Unfortunately we can't make this private in a struct. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 213 | int reg_code; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 214 | }; |
| 215 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 216 | // A few double registers are reserved: one as a scratch register and one to |
| 217 | // hold 0.0. |
| 218 | // f28: 0.0 |
| 219 | // f30: scratch register. |
| 220 | |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 221 | // V8 now supports the O32 ABI, and the FPU Registers are organized as 32 |
| 222 | // 32-bit registers, f0 through f31. When used as 'double' they are used |
| 223 | // in pairs, starting with the even numbered register. So a double operation |
| 224 | // on f0 really uses f0 and f1. |
| 225 | // (Modern mips hardware also supports 32 64-bit registers, via setting |
| 226 | // (priviledged) Status Register FR bit to 1. This is used by the N32 ABI, |
| 227 | // but it is not in common use. Someday we will want to support this in v8.) |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 228 | |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 229 | // For O32 ABI, Floats and Doubles refer to same set of 32 32-bit registers. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 230 | typedef DoubleRegister FPURegister; |
| 231 | typedef DoubleRegister FloatRegister; |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 232 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 233 | const DoubleRegister no_freg = {-1}; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 234 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 235 | const DoubleRegister f0 = {0}; // Return value in hard float mode. |
| 236 | const DoubleRegister f1 = {1}; |
| 237 | const DoubleRegister f2 = {2}; |
| 238 | const DoubleRegister f3 = {3}; |
| 239 | const DoubleRegister f4 = {4}; |
| 240 | const DoubleRegister f5 = {5}; |
| 241 | const DoubleRegister f6 = {6}; |
| 242 | const DoubleRegister f7 = {7}; |
| 243 | const DoubleRegister f8 = {8}; |
| 244 | const DoubleRegister f9 = {9}; |
| 245 | const DoubleRegister f10 = {10}; |
| 246 | const DoubleRegister f11 = {11}; |
| 247 | const DoubleRegister f12 = {12}; // Arg 0 in hard float mode. |
| 248 | const DoubleRegister f13 = {13}; |
| 249 | const DoubleRegister f14 = {14}; // Arg 1 in hard float mode. |
| 250 | const DoubleRegister f15 = {15}; |
| 251 | const DoubleRegister f16 = {16}; |
| 252 | const DoubleRegister f17 = {17}; |
| 253 | const DoubleRegister f18 = {18}; |
| 254 | const DoubleRegister f19 = {19}; |
| 255 | const DoubleRegister f20 = {20}; |
| 256 | const DoubleRegister f21 = {21}; |
| 257 | const DoubleRegister f22 = {22}; |
| 258 | const DoubleRegister f23 = {23}; |
| 259 | const DoubleRegister f24 = {24}; |
| 260 | const DoubleRegister f25 = {25}; |
| 261 | const DoubleRegister f26 = {26}; |
| 262 | const DoubleRegister f27 = {27}; |
| 263 | const DoubleRegister f28 = {28}; |
| 264 | const DoubleRegister f29 = {29}; |
| 265 | const DoubleRegister f30 = {30}; |
| 266 | const DoubleRegister f31 = {31}; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 267 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 268 | // Register aliases. |
| 269 | // cp is assumed to be a callee saved register. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 270 | // Defined using #define instead of "static const Register&" because Clang |
| 271 | // complains otherwise when a compilation unit that includes this header |
| 272 | // doesn't use the variables. |
| 273 | #define kRootRegister s6 |
| 274 | #define cp s7 |
| 275 | #define kLithiumScratchReg s3 |
| 276 | #define kLithiumScratchReg2 s4 |
| 277 | #define kLithiumScratchDouble f30 |
| 278 | #define kDoubleRegZero f28 |
| 279 | // Used on mips32r6 for compare operations. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 280 | // We use the last non-callee saved odd register for O32 ABI |
| 281 | #define kDoubleCompareReg f19 |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 282 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 283 | // FPU (coprocessor 1) control registers. |
| 284 | // Currently only FCSR (#31) is implemented. |
| 285 | struct FPUControlRegister { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 286 | bool is_valid() const { return reg_code == kFCSRRegister; } |
| 287 | bool is(FPUControlRegister creg) const { return reg_code == creg.reg_code; } |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 288 | int code() const { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 289 | DCHECK(is_valid()); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 290 | return reg_code; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 291 | } |
| 292 | int bit() const { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 293 | DCHECK(is_valid()); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 294 | return 1 << reg_code; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 295 | } |
| 296 | void setcode(int f) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 297 | reg_code = f; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 298 | DCHECK(is_valid()); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 299 | } |
| 300 | // Unfortunately we can't make this private in a struct. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 301 | int reg_code; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 302 | }; |
| 303 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 304 | const FPUControlRegister no_fpucreg = { kInvalidFPUControlRegister }; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 305 | const FPUControlRegister FCSR = { kFCSRRegister }; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 306 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 307 | // TODO(mips) Define SIMD registers. |
| 308 | typedef DoubleRegister Simd128Register; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 309 | |
| 310 | // ----------------------------------------------------------------------------- |
| 311 | // Machine instruction Operands. |
| 312 | |
| 313 | // Class Operand represents a shifter operand in data processing instructions. |
| 314 | class Operand BASE_EMBEDDED { |
| 315 | public: |
| 316 | // Immediate. |
| 317 | INLINE(explicit Operand(int32_t immediate, |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 318 | RelocInfo::Mode rmode = RelocInfo::NONE32)); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 319 | INLINE(explicit Operand(const ExternalReference& f)); |
| 320 | INLINE(explicit Operand(const char* s)); |
| 321 | INLINE(explicit Operand(Object** opp)); |
| 322 | INLINE(explicit Operand(Context** cpp)); |
| 323 | explicit Operand(Handle<Object> handle); |
| 324 | INLINE(explicit Operand(Smi* value)); |
| 325 | |
| 326 | // Register. |
| 327 | INLINE(explicit Operand(Register rm)); |
| 328 | |
| 329 | // Return true if this is a register operand. |
| 330 | INLINE(bool is_reg() const); |
| 331 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 332 | inline int32_t immediate() const { |
| 333 | DCHECK(!is_reg()); |
| 334 | return imm32_; |
| 335 | } |
| 336 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 337 | Register rm() const { return rm_; } |
| 338 | |
| 339 | private: |
| 340 | Register rm_; |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 341 | int32_t imm32_; // Valid if rm_ == no_reg. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 342 | RelocInfo::Mode rmode_; |
| 343 | |
| 344 | friend class Assembler; |
| 345 | friend class MacroAssembler; |
| 346 | }; |
| 347 | |
| 348 | |
| 349 | // On MIPS we have only one adressing mode with base_reg + offset. |
| 350 | // Class MemOperand represents a memory operand in load and store instructions. |
| 351 | class MemOperand : public Operand { |
| 352 | public: |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 353 | // Immediate value attached to offset. |
| 354 | enum OffsetAddend { |
| 355 | offset_minus_one = -1, |
| 356 | offset_zero = 0 |
| 357 | }; |
| 358 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 359 | explicit MemOperand(Register rn, int32_t offset = 0); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 360 | explicit MemOperand(Register rn, int32_t unit, int32_t multiplier, |
| 361 | OffsetAddend offset_addend = offset_zero); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 362 | int32_t offset() const { return offset_; } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 363 | |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 364 | bool OffsetIsInt16Encodable() const { |
| 365 | return is_int16(offset_); |
| 366 | } |
| 367 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 368 | private: |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 369 | int32_t offset_; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 370 | |
| 371 | friend class Assembler; |
| 372 | }; |
| 373 | |
| 374 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 375 | class Assembler : public AssemblerBase { |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 376 | public: |
| 377 | // Create an assembler. Instructions and relocation information are emitted |
| 378 | // into a buffer, with the instructions starting from the beginning and the |
| 379 | // relocation information starting from the end of the buffer. See CodeDesc |
| 380 | // for a detailed comment on the layout (globals.h). |
| 381 | // |
| 382 | // If the provided buffer is NULL, the assembler allocates and grows its own |
| 383 | // buffer, and buffer_size determines the initial buffer size. The buffer is |
| 384 | // owned by the assembler and deallocated upon destruction of the assembler. |
| 385 | // |
| 386 | // If the provided buffer is not NULL, the assembler uses the provided buffer |
| 387 | // for code generation and assumes its size to be buffer_size. If the buffer |
| 388 | // is too small, a fatal error occurs. No deallocation of the buffer is done |
| 389 | // upon destruction of the assembler. |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 390 | Assembler(Isolate* isolate, void* buffer, int buffer_size); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 391 | virtual ~Assembler() { } |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 392 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 393 | // GetCode emits any pending (non-emitted) code and fills the descriptor |
| 394 | // desc. GetCode() is idempotent; it returns the same result if no other |
| 395 | // Assembler functions are invoked in between GetCode() calls. |
| 396 | void GetCode(CodeDesc* desc); |
| 397 | |
| 398 | // Label operations & relative jumps (PPUM Appendix D). |
| 399 | // |
| 400 | // Takes a branch opcode (cc) and a label (L) and generates |
| 401 | // either a backward branch or a forward branch and links it |
| 402 | // to the label fixup chain. Usage: |
| 403 | // |
| 404 | // Label L; // unbound label |
| 405 | // j(cc, &L); // forward branch to unbound label |
| 406 | // bind(&L); // bind label to the current pc |
| 407 | // j(cc, &L); // backward branch to bound label |
| 408 | // bind(&L); // illegal: a label may be bound only once |
| 409 | // |
| 410 | // Note: The same Label can be used for forward and backward branches |
| 411 | // but it may be bound only once. |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 412 | void bind(Label* L); // Binds an unbound label L to current code position. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 413 | |
| 414 | enum OffsetSize : int { kOffset26 = 26, kOffset21 = 21, kOffset16 = 16 }; |
| 415 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 416 | // Determines if Label is bound and near enough so that branch instruction |
| 417 | // can be used to reach it, instead of jump instruction. |
| 418 | bool is_near(Label* L); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 419 | bool is_near(Label* L, OffsetSize bits); |
| 420 | bool is_near_branch(Label* L); |
| 421 | inline bool is_near_pre_r6(Label* L) { |
| 422 | DCHECK(!IsMipsArchVariant(kMips32r6)); |
| 423 | return pc_offset() - L->pos() < kMaxBranchOffset - 4 * kInstrSize; |
| 424 | } |
| 425 | inline bool is_near_r6(Label* L) { |
| 426 | DCHECK(IsMipsArchVariant(kMips32r6)); |
| 427 | return pc_offset() - L->pos() < kMaxCompactBranchOffset - 4 * kInstrSize; |
| 428 | } |
| 429 | |
| 430 | int BranchOffset(Instr instr); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 431 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 432 | // Returns the branch offset to the given label from the current code |
| 433 | // position. Links the label to the current position if it is still unbound. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 434 | // Manages the jump elimination optimization if the second parameter is true. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 435 | int32_t branch_offset_helper(Label* L, OffsetSize bits); |
| 436 | inline int32_t branch_offset(Label* L) { |
| 437 | return branch_offset_helper(L, OffsetSize::kOffset16); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 438 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 439 | inline int32_t branch_offset21(Label* L) { |
| 440 | return branch_offset_helper(L, OffsetSize::kOffset21); |
| 441 | } |
| 442 | inline int32_t branch_offset26(Label* L) { |
| 443 | return branch_offset_helper(L, OffsetSize::kOffset26); |
| 444 | } |
| 445 | inline int32_t shifted_branch_offset(Label* L) { |
| 446 | return branch_offset(L) >> 2; |
| 447 | } |
| 448 | inline int32_t shifted_branch_offset21(Label* L) { |
| 449 | return branch_offset21(L) >> 2; |
| 450 | } |
| 451 | inline int32_t shifted_branch_offset26(Label* L) { |
| 452 | return branch_offset26(L) >> 2; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 453 | } |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 454 | uint32_t jump_address(Label* L); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 455 | |
| 456 | // Puts a labels target address at the given position. |
| 457 | // The high 8 bits are set to zero. |
| 458 | void label_at_put(Label* L, int at_offset); |
| 459 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 460 | // Read/Modify the code target address in the branch/call instruction at pc. |
| 461 | static Address target_address_at(Address pc); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 462 | static void set_target_address_at( |
| 463 | Isolate* isolate, Address pc, Address target, |
| 464 | ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 465 | // On MIPS there is no Constant Pool so we skip that parameter. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 466 | INLINE(static Address target_address_at(Address pc, Address constant_pool)) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 467 | return target_address_at(pc); |
| 468 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 469 | INLINE(static void set_target_address_at( |
| 470 | Isolate* isolate, Address pc, Address constant_pool, Address target, |
| 471 | ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED)) { |
| 472 | set_target_address_at(isolate, pc, target, icache_flush_mode); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 473 | } |
| 474 | INLINE(static Address target_address_at(Address pc, Code* code)) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 475 | Address constant_pool = code ? code->constant_pool() : NULL; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 476 | return target_address_at(pc, constant_pool); |
| 477 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 478 | INLINE(static void set_target_address_at( |
| 479 | Isolate* isolate, Address pc, Code* code, Address target, |
| 480 | ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED)) { |
| 481 | Address constant_pool = code ? code->constant_pool() : NULL; |
| 482 | set_target_address_at(isolate, pc, constant_pool, target, |
| 483 | icache_flush_mode); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | // Return the code target address at a call site from the return address |
| 487 | // of that call in the instruction stream. |
| 488 | inline static Address target_address_from_return_address(Address pc); |
| 489 | |
Ben Murdoch | db1b438 | 2012-04-26 19:03:50 +0100 | [diff] [blame] | 490 | static void QuietNaN(HeapObject* nan); |
| 491 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 492 | // This sets the branch destination (which gets loaded at the call address). |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 493 | // This is for calls and branches within generated code. The serializer |
| 494 | // has already deserialized the lui/ori instructions etc. |
| 495 | inline static void deserialization_set_special_target_at( |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 496 | Isolate* isolate, Address instruction_payload, Code* code, |
| 497 | Address target) { |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 498 | set_target_address_at( |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 499 | isolate, |
| 500 | instruction_payload - kInstructionsFor32BitConstant * kInstrSize, code, |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 501 | target); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 502 | } |
| 503 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 504 | // This sets the internal reference at the pc. |
| 505 | inline static void deserialization_set_target_internal_reference_at( |
| 506 | Isolate* isolate, Address pc, Address target, |
| 507 | RelocInfo::Mode mode = RelocInfo::INTERNAL_REFERENCE); |
| 508 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 509 | // Size of an instruction. |
| 510 | static const int kInstrSize = sizeof(Instr); |
| 511 | |
| 512 | // Difference between address of current opcode and target address offset. |
| 513 | static const int kBranchPCOffset = 4; |
| 514 | |
| 515 | // Here we are patching the address in the LUI/ORI instruction pair. |
| 516 | // These values are used in the serialization process and must be zero for |
| 517 | // MIPS platform, as Code, Embedded Object or External-reference pointers |
| 518 | // are split across two consecutive instructions and don't exist separately |
| 519 | // in the code, so the serializer should not step forwards in memory after |
| 520 | // a target is resolved and written. |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 521 | static const int kSpecialTargetSize = 0; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 522 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 523 | // Number of consecutive instructions used to store 32bit constant. This |
| 524 | // constant is used in RelocInfo::target_address_address() function to tell |
| 525 | // serializer address of the instruction that follows LUI/ORI instruction |
| 526 | // pair. |
| 527 | static const int kInstructionsFor32BitConstant = 2; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 528 | |
| 529 | // Distance between the instruction referring to the address of the call |
| 530 | // target and the return address. |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 531 | #ifdef _MIPS_ARCH_MIPS32R6 |
| 532 | static const int kCallTargetAddressOffset = 3 * kInstrSize; |
| 533 | #else |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 534 | static const int kCallTargetAddressOffset = 4 * kInstrSize; |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 535 | #endif |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 536 | |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 537 | // Distance between start of patched debug break slot and the emitted address |
| 538 | // to jump to. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 539 | static const int kPatchDebugBreakSlotAddressOffset = 4 * kInstrSize; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 540 | |
| 541 | // Difference between address of current opcode and value read from pc |
| 542 | // register. |
| 543 | static const int kPcLoadDelta = 4; |
| 544 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 545 | #ifdef _MIPS_ARCH_MIPS32R6 |
| 546 | static const int kDebugBreakSlotInstructions = 3; |
| 547 | #else |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 548 | static const int kDebugBreakSlotInstructions = 4; |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 549 | #endif |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 550 | static const int kDebugBreakSlotLength = |
| 551 | kDebugBreakSlotInstructions * kInstrSize; |
| 552 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 553 | |
| 554 | // --------------------------------------------------------------------------- |
| 555 | // Code generation. |
| 556 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 557 | // Insert the smallest number of nop instructions |
| 558 | // possible to align the pc offset to a multiple |
| 559 | // of m. m must be a power of 2 (>= 4). |
| 560 | void Align(int m); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 561 | // Insert the smallest number of zero bytes possible to align the pc offset |
| 562 | // to a mulitple of m. m must be a power of 2 (>= 2). |
| 563 | void DataAlign(int m); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 564 | // Aligns code to something that's optimal for a jump target for the platform. |
| 565 | void CodeTargetAlign(); |
| 566 | |
| 567 | // Different nop operations are used by the code generator to detect certain |
| 568 | // states of the generated code. |
| 569 | enum NopMarkerTypes { |
| 570 | NON_MARKING_NOP = 0, |
| 571 | DEBUG_BREAK_NOP, |
| 572 | // IC markers. |
| 573 | PROPERTY_ACCESS_INLINED, |
| 574 | PROPERTY_ACCESS_INLINED_CONTEXT, |
| 575 | PROPERTY_ACCESS_INLINED_CONTEXT_DONT_DELETE, |
| 576 | // Helper values. |
| 577 | LAST_CODE_MARKER, |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 578 | FIRST_IC_MARKER = PROPERTY_ACCESS_INLINED, |
| 579 | // Code aging |
| 580 | CODE_AGE_MARKER_NOP = 6, |
| 581 | CODE_AGE_SEQUENCE_NOP |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 582 | }; |
| 583 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 584 | // Type == 0 is the default non-marking nop. For mips this is a |
| 585 | // sll(zero_reg, zero_reg, 0). We use rt_reg == at for non-zero |
| 586 | // marking, to avoid conflict with ssnop and ehb instructions. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 587 | void nop(unsigned int type = 0) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 588 | DCHECK(type < 32); |
| 589 | Register nop_rt_reg = (type == 0) ? zero_reg : at; |
| 590 | sll(zero_reg, nop_rt_reg, type, true); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 591 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 592 | |
| 593 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 594 | // --------Branch-and-jump-instructions---------- |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 595 | // We don't use likely variant of instructions. |
| 596 | void b(int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 597 | inline void b(Label* L) { b(shifted_branch_offset(L)); } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 598 | void bal(int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 599 | inline void bal(Label* L) { bal(shifted_branch_offset(L)); } |
| 600 | void bc(int32_t offset); |
| 601 | inline void bc(Label* L) { bc(shifted_branch_offset26(L)); } |
| 602 | void balc(int32_t offset); |
| 603 | inline void balc(Label* L) { balc(shifted_branch_offset26(L)); } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 604 | |
| 605 | void beq(Register rs, Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 606 | inline void beq(Register rs, Register rt, Label* L) { |
| 607 | beq(rs, rt, shifted_branch_offset(L)); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 608 | } |
| 609 | void bgez(Register rs, int16_t offset); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 610 | void bgezc(Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 611 | inline void bgezc(Register rt, Label* L) { |
| 612 | bgezc(rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 613 | } |
| 614 | void bgeuc(Register rs, Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 615 | inline void bgeuc(Register rs, Register rt, Label* L) { |
| 616 | bgeuc(rs, rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 617 | } |
| 618 | void bgec(Register rs, Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 619 | inline void bgec(Register rs, Register rt, Label* L) { |
| 620 | bgec(rs, rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 621 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 622 | void bgezal(Register rs, int16_t offset); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 623 | void bgezalc(Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 624 | inline void bgezalc(Register rt, Label* L) { |
| 625 | bgezalc(rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 626 | } |
| 627 | void bgezall(Register rs, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 628 | inline void bgezall(Register rs, Label* L) { |
| 629 | bgezall(rs, branch_offset(L) >> 2); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 630 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 631 | void bgtz(Register rs, int16_t offset); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 632 | void bgtzc(Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 633 | inline void bgtzc(Register rt, Label* L) { |
| 634 | bgtzc(rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 635 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 636 | void blez(Register rs, int16_t offset); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 637 | void blezc(Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 638 | inline void blezc(Register rt, Label* L) { |
| 639 | blezc(rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 640 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 641 | void bltz(Register rs, int16_t offset); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 642 | void bltzc(Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 643 | inline void bltzc(Register rt, Label* L) { |
| 644 | bltzc(rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 645 | } |
| 646 | void bltuc(Register rs, Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 647 | inline void bltuc(Register rs, Register rt, Label* L) { |
| 648 | bltuc(rs, rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 649 | } |
| 650 | void bltc(Register rs, Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 651 | inline void bltc(Register rs, Register rt, Label* L) { |
| 652 | bltc(rs, rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 653 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 654 | void bltzal(Register rs, int16_t offset); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 655 | void blezalc(Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 656 | inline void blezalc(Register rt, Label* L) { |
| 657 | blezalc(rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 658 | } |
| 659 | void bltzalc(Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 660 | inline void bltzalc(Register rt, Label* L) { |
| 661 | bltzalc(rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 662 | } |
| 663 | void bgtzalc(Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 664 | inline void bgtzalc(Register rt, Label* L) { |
| 665 | bgtzalc(rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 666 | } |
| 667 | void beqzalc(Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 668 | inline void beqzalc(Register rt, Label* L) { |
| 669 | beqzalc(rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 670 | } |
| 671 | void beqc(Register rs, Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 672 | inline void beqc(Register rs, Register rt, Label* L) { |
| 673 | beqc(rs, rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 674 | } |
| 675 | void beqzc(Register rs, int32_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 676 | inline void beqzc(Register rs, Label* L) { |
| 677 | beqzc(rs, shifted_branch_offset21(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 678 | } |
| 679 | void bnezalc(Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 680 | inline void bnezalc(Register rt, Label* L) { |
| 681 | bnezalc(rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 682 | } |
| 683 | void bnec(Register rs, Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 684 | inline void bnec(Register rs, Register rt, Label* L) { |
| 685 | bnec(rs, rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 686 | } |
| 687 | void bnezc(Register rt, int32_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 688 | inline void bnezc(Register rt, Label* L) { |
| 689 | bnezc(rt, shifted_branch_offset21(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 690 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 691 | void bne(Register rs, Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 692 | inline void bne(Register rs, Register rt, Label* L) { |
| 693 | bne(rs, rt, shifted_branch_offset(L)); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 694 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 695 | void bovc(Register rs, Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 696 | inline void bovc(Register rs, Register rt, Label* L) { |
| 697 | bovc(rs, rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 698 | } |
| 699 | void bnvc(Register rs, Register rt, int16_t offset); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 700 | inline void bnvc(Register rs, Register rt, Label* L) { |
| 701 | bnvc(rs, rt, shifted_branch_offset(L)); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 702 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 703 | |
| 704 | // Never use the int16_t b(l)cond version with a branch offset |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 705 | // instead of using the Label* version. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 706 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 707 | // Jump targets must be in the current 256 MB-aligned region. i.e. 28 bits. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 708 | void j(int32_t target); |
| 709 | void jal(int32_t target); |
| 710 | void jalr(Register rs, Register rd = ra); |
| 711 | void jr(Register target); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 712 | void jic(Register rt, int16_t offset); |
| 713 | void jialc(Register rt, int16_t offset); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 714 | |
| 715 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 716 | // -------Data-processing-instructions--------- |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 717 | |
| 718 | // Arithmetic. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 719 | void addu(Register rd, Register rs, Register rt); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 720 | void subu(Register rd, Register rs, Register rt); |
| 721 | void mult(Register rs, Register rt); |
| 722 | void multu(Register rs, Register rt); |
| 723 | void div(Register rs, Register rt); |
| 724 | void divu(Register rs, Register rt); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 725 | void div(Register rd, Register rs, Register rt); |
| 726 | void divu(Register rd, Register rs, Register rt); |
| 727 | void mod(Register rd, Register rs, Register rt); |
| 728 | void modu(Register rd, Register rs, Register rt); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 729 | void mul(Register rd, Register rs, Register rt); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 730 | void muh(Register rd, Register rs, Register rt); |
| 731 | void mulu(Register rd, Register rs, Register rt); |
| 732 | void muhu(Register rd, Register rs, Register rt); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 733 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 734 | void addiu(Register rd, Register rs, int32_t j); |
| 735 | |
| 736 | // Logical. |
| 737 | void and_(Register rd, Register rs, Register rt); |
| 738 | void or_(Register rd, Register rs, Register rt); |
| 739 | void xor_(Register rd, Register rs, Register rt); |
| 740 | void nor(Register rd, Register rs, Register rt); |
| 741 | |
| 742 | void andi(Register rd, Register rs, int32_t j); |
| 743 | void ori(Register rd, Register rs, int32_t j); |
| 744 | void xori(Register rd, Register rs, int32_t j); |
| 745 | void lui(Register rd, int32_t j); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 746 | void aui(Register rs, Register rt, int32_t j); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 747 | |
| 748 | // Shifts. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 749 | // Please note: sll(zero_reg, zero_reg, x) instructions are reserved as nop |
| 750 | // and may cause problems in normal code. coming_from_nop makes sure this |
| 751 | // doesn't happen. |
| 752 | void sll(Register rd, Register rt, uint16_t sa, bool coming_from_nop = false); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 753 | void sllv(Register rd, Register rt, Register rs); |
| 754 | void srl(Register rd, Register rt, uint16_t sa); |
| 755 | void srlv(Register rd, Register rt, Register rs); |
| 756 | void sra(Register rt, Register rd, uint16_t sa); |
| 757 | void srav(Register rt, Register rd, Register rs); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 758 | void rotr(Register rd, Register rt, uint16_t sa); |
| 759 | void rotrv(Register rd, Register rt, Register rs); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 760 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 761 | // ------------Memory-instructions------------- |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 762 | |
| 763 | void lb(Register rd, const MemOperand& rs); |
| 764 | void lbu(Register rd, const MemOperand& rs); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 765 | void lh(Register rd, const MemOperand& rs); |
| 766 | void lhu(Register rd, const MemOperand& rs); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 767 | void lw(Register rd, const MemOperand& rs); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 768 | void lwl(Register rd, const MemOperand& rs); |
| 769 | void lwr(Register rd, const MemOperand& rs); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 770 | void sb(Register rd, const MemOperand& rs); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 771 | void sh(Register rd, const MemOperand& rs); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 772 | void sw(Register rd, const MemOperand& rs); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 773 | void swl(Register rd, const MemOperand& rs); |
| 774 | void swr(Register rd, const MemOperand& rs); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 775 | |
| 776 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 777 | // ---------PC-Relative-instructions----------- |
| 778 | |
| 779 | void addiupc(Register rs, int32_t imm19); |
| 780 | void lwpc(Register rs, int32_t offset19); |
| 781 | void auipc(Register rs, int16_t imm16); |
| 782 | void aluipc(Register rs, int16_t imm16); |
| 783 | |
| 784 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 785 | // ----------------Prefetch-------------------- |
| 786 | |
| 787 | void pref(int32_t hint, const MemOperand& rs); |
| 788 | |
| 789 | |
| 790 | // -------------Misc-instructions-------------- |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 791 | |
| 792 | // Break / Trap instructions. |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 793 | void break_(uint32_t code, bool break_as_stop = false); |
| 794 | void stop(const char* msg, uint32_t code = kMaxStopCode); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 795 | void tge(Register rs, Register rt, uint16_t code); |
| 796 | void tgeu(Register rs, Register rt, uint16_t code); |
| 797 | void tlt(Register rs, Register rt, uint16_t code); |
| 798 | void tltu(Register rs, Register rt, uint16_t code); |
| 799 | void teq(Register rs, Register rt, uint16_t code); |
| 800 | void tne(Register rs, Register rt, uint16_t code); |
| 801 | |
| 802 | // Move from HI/LO register. |
| 803 | void mfhi(Register rd); |
| 804 | void mflo(Register rd); |
| 805 | |
| 806 | // Set on less than. |
| 807 | void slt(Register rd, Register rs, Register rt); |
| 808 | void sltu(Register rd, Register rs, Register rt); |
| 809 | void slti(Register rd, Register rs, int32_t j); |
| 810 | void sltiu(Register rd, Register rs, int32_t j); |
| 811 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 812 | // Conditional move. |
| 813 | void movz(Register rd, Register rs, Register rt); |
| 814 | void movn(Register rd, Register rs, Register rt); |
| 815 | void movt(Register rd, Register rs, uint16_t cc = 0); |
| 816 | void movf(Register rd, Register rs, uint16_t cc = 0); |
| 817 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 818 | void sel(SecondaryField fmt, FPURegister fd, FPURegister fs, FPURegister ft); |
| 819 | void sel_s(FPURegister fd, FPURegister fs, FPURegister ft); |
| 820 | void sel_d(FPURegister fd, FPURegister fs, FPURegister ft); |
| 821 | void seleqz(Register rd, Register rs, Register rt); |
| 822 | void seleqz(SecondaryField fmt, FPURegister fd, FPURegister fs, |
| 823 | FPURegister ft); |
| 824 | void selnez(Register rd, Register rs, Register rt); |
| 825 | void selnez(SecondaryField fmt, FPURegister fd, FPURegister fs, |
| 826 | FPURegister ft); |
| 827 | void seleqz_d(FPURegister fd, FPURegister fs, FPURegister ft); |
| 828 | void seleqz_s(FPURegister fd, FPURegister fs, FPURegister ft); |
| 829 | void selnez_d(FPURegister fd, FPURegister fs, FPURegister ft); |
| 830 | void selnez_s(FPURegister fd, FPURegister fs, FPURegister ft); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 831 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 832 | void movz_s(FPURegister fd, FPURegister fs, Register rt); |
| 833 | void movz_d(FPURegister fd, FPURegister fs, Register rt); |
| 834 | void movt_s(FPURegister fd, FPURegister fs, uint16_t cc = 0); |
| 835 | void movt_d(FPURegister fd, FPURegister fs, uint16_t cc = 0); |
| 836 | void movf_s(FPURegister fd, FPURegister fs, uint16_t cc = 0); |
| 837 | void movf_d(FPURegister fd, FPURegister fs, uint16_t cc = 0); |
| 838 | void movn_s(FPURegister fd, FPURegister fs, Register rt); |
| 839 | void movn_d(FPURegister fd, FPURegister fs, Register rt); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 840 | // Bit twiddling. |
| 841 | void clz(Register rd, Register rs); |
| 842 | void ins_(Register rt, Register rs, uint16_t pos, uint16_t size); |
| 843 | void ext_(Register rt, Register rs, uint16_t pos, uint16_t size); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 844 | void bitswap(Register rd, Register rt); |
| 845 | void align(Register rd, Register rs, Register rt, uint8_t bp); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 846 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 847 | // --------Coprocessor-instructions---------------- |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 848 | |
| 849 | // Load, store, and move. |
| 850 | void lwc1(FPURegister fd, const MemOperand& src); |
| 851 | void ldc1(FPURegister fd, const MemOperand& src); |
| 852 | |
| 853 | void swc1(FPURegister fs, const MemOperand& dst); |
| 854 | void sdc1(FPURegister fs, const MemOperand& dst); |
| 855 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 856 | void mtc1(Register rt, FPURegister fs); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 857 | void mthc1(Register rt, FPURegister fs); |
| 858 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 859 | void mfc1(Register rt, FPURegister fs); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 860 | void mfhc1(Register rt, FPURegister fs); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 861 | |
| 862 | void ctc1(Register rt, FPUControlRegister fs); |
| 863 | void cfc1(Register rt, FPUControlRegister fs); |
| 864 | |
| 865 | // Arithmetic. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 866 | void add_s(FPURegister fd, FPURegister fs, FPURegister ft); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 867 | void add_d(FPURegister fd, FPURegister fs, FPURegister ft); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 868 | void sub_s(FPURegister fd, FPURegister fs, FPURegister ft); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 869 | void sub_d(FPURegister fd, FPURegister fs, FPURegister ft); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 870 | void mul_s(FPURegister fd, FPURegister fs, FPURegister ft); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 871 | void mul_d(FPURegister fd, FPURegister fs, FPURegister ft); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 872 | void madd_d(FPURegister fd, FPURegister fr, FPURegister fs, FPURegister ft); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 873 | void div_s(FPURegister fd, FPURegister fs, FPURegister ft); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 874 | void div_d(FPURegister fd, FPURegister fs, FPURegister ft); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 875 | void abs_s(FPURegister fd, FPURegister fs); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 876 | void abs_d(FPURegister fd, FPURegister fs); |
| 877 | void mov_d(FPURegister fd, FPURegister fs); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 878 | void mov_s(FPURegister fd, FPURegister fs); |
| 879 | void neg_s(FPURegister fd, FPURegister fs); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 880 | void neg_d(FPURegister fd, FPURegister fs); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 881 | void sqrt_s(FPURegister fd, FPURegister fs); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 882 | void sqrt_d(FPURegister fd, FPURegister fs); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 883 | void rsqrt_s(FPURegister fd, FPURegister fs); |
| 884 | void rsqrt_d(FPURegister fd, FPURegister fs); |
| 885 | void recip_d(FPURegister fd, FPURegister fs); |
| 886 | void recip_s(FPURegister fd, FPURegister fs); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 887 | |
| 888 | // Conversion. |
| 889 | void cvt_w_s(FPURegister fd, FPURegister fs); |
| 890 | void cvt_w_d(FPURegister fd, FPURegister fs); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 891 | void trunc_w_s(FPURegister fd, FPURegister fs); |
| 892 | void trunc_w_d(FPURegister fd, FPURegister fs); |
| 893 | void round_w_s(FPURegister fd, FPURegister fs); |
| 894 | void round_w_d(FPURegister fd, FPURegister fs); |
| 895 | void floor_w_s(FPURegister fd, FPURegister fs); |
| 896 | void floor_w_d(FPURegister fd, FPURegister fs); |
| 897 | void ceil_w_s(FPURegister fd, FPURegister fs); |
| 898 | void ceil_w_d(FPURegister fd, FPURegister fs); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 899 | void rint_s(FPURegister fd, FPURegister fs); |
| 900 | void rint_d(FPURegister fd, FPURegister fs); |
| 901 | void rint(SecondaryField fmt, FPURegister fd, FPURegister fs); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 902 | |
| 903 | void cvt_l_s(FPURegister fd, FPURegister fs); |
| 904 | void cvt_l_d(FPURegister fd, FPURegister fs); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 905 | void trunc_l_s(FPURegister fd, FPURegister fs); |
| 906 | void trunc_l_d(FPURegister fd, FPURegister fs); |
| 907 | void round_l_s(FPURegister fd, FPURegister fs); |
| 908 | void round_l_d(FPURegister fd, FPURegister fs); |
| 909 | void floor_l_s(FPURegister fd, FPURegister fs); |
| 910 | void floor_l_d(FPURegister fd, FPURegister fs); |
| 911 | void ceil_l_s(FPURegister fd, FPURegister fs); |
| 912 | void ceil_l_d(FPURegister fd, FPURegister fs); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 913 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 914 | void class_s(FPURegister fd, FPURegister fs); |
| 915 | void class_d(FPURegister fd, FPURegister fs); |
| 916 | |
| 917 | void min(SecondaryField fmt, FPURegister fd, FPURegister fs, FPURegister ft); |
| 918 | void mina(SecondaryField fmt, FPURegister fd, FPURegister fs, FPURegister ft); |
| 919 | void max(SecondaryField fmt, FPURegister fd, FPURegister fs, FPURegister ft); |
| 920 | void maxa(SecondaryField fmt, FPURegister fd, FPURegister fs, FPURegister ft); |
| 921 | void min_s(FPURegister fd, FPURegister fs, FPURegister ft); |
| 922 | void min_d(FPURegister fd, FPURegister fs, FPURegister ft); |
| 923 | void max_s(FPURegister fd, FPURegister fs, FPURegister ft); |
| 924 | void max_d(FPURegister fd, FPURegister fs, FPURegister ft); |
| 925 | void mina_s(FPURegister fd, FPURegister fs, FPURegister ft); |
| 926 | void mina_d(FPURegister fd, FPURegister fs, FPURegister ft); |
| 927 | void maxa_s(FPURegister fd, FPURegister fs, FPURegister ft); |
| 928 | void maxa_d(FPURegister fd, FPURegister fs, FPURegister ft); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 929 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 930 | void cvt_s_w(FPURegister fd, FPURegister fs); |
| 931 | void cvt_s_l(FPURegister fd, FPURegister fs); |
| 932 | void cvt_s_d(FPURegister fd, FPURegister fs); |
| 933 | |
| 934 | void cvt_d_w(FPURegister fd, FPURegister fs); |
| 935 | void cvt_d_l(FPURegister fd, FPURegister fs); |
| 936 | void cvt_d_s(FPURegister fd, FPURegister fs); |
| 937 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 938 | // Conditions and branches for MIPSr6. |
| 939 | void cmp(FPUCondition cond, SecondaryField fmt, |
| 940 | FPURegister fd, FPURegister ft, FPURegister fs); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 941 | void cmp_s(FPUCondition cond, FPURegister fd, FPURegister fs, FPURegister ft); |
| 942 | void cmp_d(FPUCondition cond, FPURegister fd, FPURegister fs, FPURegister ft); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 943 | |
| 944 | void bc1eqz(int16_t offset, FPURegister ft); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 945 | inline void bc1eqz(Label* L, FPURegister ft) { |
| 946 | bc1eqz(shifted_branch_offset(L), ft); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 947 | } |
| 948 | void bc1nez(int16_t offset, FPURegister ft); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 949 | inline void bc1nez(Label* L, FPURegister ft) { |
| 950 | bc1nez(shifted_branch_offset(L), ft); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 951 | } |
| 952 | |
| 953 | // Conditions and branches for non MIPSr6. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 954 | void c(FPUCondition cond, SecondaryField fmt, |
| 955 | FPURegister ft, FPURegister fs, uint16_t cc = 0); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 956 | void c_s(FPUCondition cond, FPURegister ft, FPURegister fs, uint16_t cc = 0); |
| 957 | void c_d(FPUCondition cond, FPURegister ft, FPURegister fs, uint16_t cc = 0); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 958 | |
| 959 | void bc1f(int16_t offset, uint16_t cc = 0); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 960 | inline void bc1f(Label* L, uint16_t cc = 0) { |
| 961 | bc1f(shifted_branch_offset(L), cc); |
| 962 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 963 | void bc1t(int16_t offset, uint16_t cc = 0); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 964 | inline void bc1t(Label* L, uint16_t cc = 0) { |
| 965 | bc1t(shifted_branch_offset(L), cc); |
| 966 | } |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 967 | void fcmp(FPURegister src1, const double src2, FPUCondition cond); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 968 | |
| 969 | // Check the code size generated from label to here. |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 970 | int SizeOfCodeGeneratedSince(Label* label) { |
| 971 | return pc_offset() - label->pos(); |
| 972 | } |
| 973 | |
| 974 | // Check the number of instructions generated from label to here. |
| 975 | int InstructionsGeneratedSince(Label* label) { |
| 976 | return SizeOfCodeGeneratedSince(label) / kInstrSize; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 977 | } |
| 978 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 979 | // Class for scoping postponing the trampoline pool generation. |
| 980 | class BlockTrampolinePoolScope { |
| 981 | public: |
| 982 | explicit BlockTrampolinePoolScope(Assembler* assem) : assem_(assem) { |
| 983 | assem_->StartBlockTrampolinePool(); |
| 984 | } |
| 985 | ~BlockTrampolinePoolScope() { |
| 986 | assem_->EndBlockTrampolinePool(); |
| 987 | } |
| 988 | |
| 989 | private: |
| 990 | Assembler* assem_; |
| 991 | |
| 992 | DISALLOW_IMPLICIT_CONSTRUCTORS(BlockTrampolinePoolScope); |
| 993 | }; |
| 994 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 995 | // Class for postponing the assembly buffer growth. Typically used for |
| 996 | // sequences of instructions that must be emitted as a unit, before |
| 997 | // buffer growth (and relocation) can occur. |
| 998 | // This blocking scope is not nestable. |
| 999 | class BlockGrowBufferScope { |
| 1000 | public: |
| 1001 | explicit BlockGrowBufferScope(Assembler* assem) : assem_(assem) { |
| 1002 | assem_->StartBlockGrowBuffer(); |
| 1003 | } |
| 1004 | ~BlockGrowBufferScope() { |
| 1005 | assem_->EndBlockGrowBuffer(); |
| 1006 | } |
| 1007 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1008 | private: |
| 1009 | Assembler* assem_; |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1010 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1011 | DISALLOW_IMPLICIT_CONSTRUCTORS(BlockGrowBufferScope); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1012 | }; |
| 1013 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1014 | // Debugging. |
| 1015 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1016 | // Mark generator continuation. |
| 1017 | void RecordGeneratorContinuation(); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1018 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1019 | // Mark address of a debug break slot. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1020 | void RecordDebugBreakSlot(RelocInfo::Mode mode); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1021 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1022 | // Record the AST id of the CallIC being compiled, so that it can be placed |
| 1023 | // in the relocation information. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1024 | void SetRecordedAstId(TypeFeedbackId ast_id) { |
| 1025 | DCHECK(recorded_ast_id_.IsNone()); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1026 | recorded_ast_id_ = ast_id; |
| 1027 | } |
| 1028 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1029 | TypeFeedbackId RecordedAstId() { |
| 1030 | DCHECK(!recorded_ast_id_.IsNone()); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1031 | return recorded_ast_id_; |
| 1032 | } |
| 1033 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1034 | void ClearRecordedAstId() { recorded_ast_id_ = TypeFeedbackId::None(); } |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1035 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1036 | // Record a comment relocation entry that can be used by a disassembler. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1037 | // Use --code-comments to enable. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1038 | void RecordComment(const char* msg); |
| 1039 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1040 | // Record a deoptimization reason that can be used by a log or cpu profiler. |
| 1041 | // Use --trace-deopt to enable. |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1042 | void RecordDeoptReason(const int reason, int raw_position); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1043 | |
| 1044 | |
| 1045 | static int RelocateInternalReference(RelocInfo::Mode rmode, byte* pc, |
| 1046 | intptr_t pc_delta); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1047 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1048 | // Writes a single byte or word of data in the code stream. Used for |
| 1049 | // inline tables, e.g., jump-tables. |
| 1050 | void db(uint8_t data); |
| 1051 | void dd(uint32_t data); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1052 | void dq(uint64_t data); |
| 1053 | void dp(uintptr_t data) { dd(data); } |
| 1054 | void dd(Label* label); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1055 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1056 | AssemblerPositionsRecorder* positions_recorder() { |
| 1057 | return &positions_recorder_; |
| 1058 | } |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1059 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1060 | // Postpone the generation of the trampoline pool for the specified number of |
| 1061 | // instructions. |
| 1062 | void BlockTrampolinePoolFor(int instructions); |
| 1063 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1064 | // Check if there is less than kGap bytes available in the buffer. |
| 1065 | // If this is the case, we need to grow the buffer before emitting |
| 1066 | // an instruction or relocation information. |
| 1067 | inline bool overflow() const { return pc_ >= reloc_info_writer.pos() - kGap; } |
| 1068 | |
| 1069 | // Get the number of bytes available in the buffer. |
| 1070 | inline int available_space() const { return reloc_info_writer.pos() - pc_; } |
| 1071 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1072 | // Read/patch instructions. |
| 1073 | static Instr instr_at(byte* pc) { return *reinterpret_cast<Instr*>(pc); } |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1074 | static void instr_at_put(byte* pc, Instr instr) { |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1075 | *reinterpret_cast<Instr*>(pc) = instr; |
| 1076 | } |
| 1077 | Instr instr_at(int pos) { return *reinterpret_cast<Instr*>(buffer_ + pos); } |
| 1078 | void instr_at_put(int pos, Instr instr) { |
| 1079 | *reinterpret_cast<Instr*>(buffer_ + pos) = instr; |
| 1080 | } |
| 1081 | |
| 1082 | // Check if an instruction is a branch of some kind. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1083 | static bool IsBranch(Instr instr); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1084 | static bool IsBc(Instr instr); |
| 1085 | static bool IsBzc(Instr instr); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1086 | static bool IsBeq(Instr instr); |
| 1087 | static bool IsBne(Instr instr); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1088 | static bool IsBeqzc(Instr instr); |
| 1089 | static bool IsBnezc(Instr instr); |
| 1090 | static bool IsBeqc(Instr instr); |
| 1091 | static bool IsBnec(Instr instr); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1092 | static bool IsJicOrJialc(Instr instr); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1093 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1094 | static bool IsJump(Instr instr); |
| 1095 | static bool IsJ(Instr instr); |
| 1096 | static bool IsLui(Instr instr); |
| 1097 | static bool IsOri(Instr instr); |
| 1098 | |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 1099 | static bool IsJal(Instr instr); |
| 1100 | static bool IsJr(Instr instr); |
| 1101 | static bool IsJalr(Instr instr); |
| 1102 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1103 | static bool IsNop(Instr instr, unsigned int type); |
| 1104 | static bool IsPop(Instr instr); |
| 1105 | static bool IsPush(Instr instr); |
| 1106 | static bool IsLwRegFpOffset(Instr instr); |
| 1107 | static bool IsSwRegFpOffset(Instr instr); |
| 1108 | static bool IsLwRegFpNegOffset(Instr instr); |
| 1109 | static bool IsSwRegFpNegOffset(Instr instr); |
| 1110 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1111 | static Register GetRtReg(Instr instr); |
| 1112 | static Register GetRsReg(Instr instr); |
| 1113 | static Register GetRdReg(Instr instr); |
| 1114 | |
| 1115 | static uint32_t GetRt(Instr instr); |
| 1116 | static uint32_t GetRtField(Instr instr); |
| 1117 | static uint32_t GetRs(Instr instr); |
| 1118 | static uint32_t GetRsField(Instr instr); |
| 1119 | static uint32_t GetRd(Instr instr); |
| 1120 | static uint32_t GetRdField(Instr instr); |
| 1121 | static uint32_t GetSa(Instr instr); |
| 1122 | static uint32_t GetSaField(Instr instr); |
| 1123 | static uint32_t GetOpcodeField(Instr instr); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1124 | static uint32_t GetFunction(Instr instr); |
| 1125 | static uint32_t GetFunctionField(Instr instr); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1126 | static uint32_t GetImmediate16(Instr instr); |
| 1127 | static uint32_t GetLabelConst(Instr instr); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1128 | |
| 1129 | static int32_t GetBranchOffset(Instr instr); |
| 1130 | static bool IsLw(Instr instr); |
| 1131 | static int16_t GetLwOffset(Instr instr); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1132 | static int16_t GetJicOrJialcOffset(Instr instr); |
| 1133 | static int16_t GetLuiOffset(Instr instr); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1134 | static Instr SetLwOffset(Instr instr, int16_t offset); |
| 1135 | |
| 1136 | static bool IsSw(Instr instr); |
| 1137 | static Instr SetSwOffset(Instr instr, int16_t offset); |
| 1138 | static bool IsAddImmediate(Instr instr); |
| 1139 | static Instr SetAddImmediateOffset(Instr instr, int16_t offset); |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1140 | static uint32_t CreateTargetAddress(Instr instr_lui, Instr instr_jic); |
| 1141 | static void UnpackTargetAddress(uint32_t address, int16_t& lui_offset, |
| 1142 | int16_t& jic_offset); |
| 1143 | static void UnpackTargetAddressUnsigned(uint32_t address, |
| 1144 | uint32_t& lui_offset, |
| 1145 | uint32_t& jic_offset); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1146 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1147 | static bool IsAndImmediate(Instr instr); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1148 | static bool IsEmittedConstant(Instr instr); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1149 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1150 | void CheckTrampolinePool(); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1151 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1152 | void PatchConstantPoolAccessInstruction(int pc_offset, int offset, |
| 1153 | ConstantPoolEntry::Access access, |
| 1154 | ConstantPoolEntry::Type type) { |
| 1155 | // No embedded constant pool support. |
| 1156 | UNREACHABLE(); |
| 1157 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1158 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1159 | bool IsPrevInstrCompactBranch() { return prev_instr_compact_branch_; } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1160 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1161 | protected: |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1162 | // Load Scaled Address instruction. |
| 1163 | void lsa(Register rd, Register rt, Register rs, uint8_t sa); |
| 1164 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1165 | // Relocation for a type-recording IC has the AST id added to it. This |
| 1166 | // member variable is a way to pass the information from the call site to |
| 1167 | // the relocation info. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1168 | TypeFeedbackId recorded_ast_id_; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1169 | |
| 1170 | int32_t buffer_space() const { return reloc_info_writer.pos() - pc_; } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1171 | |
| 1172 | // Decode branch instruction at pos and return branch target pos. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1173 | int target_at(int pos, bool is_internal); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1174 | |
| 1175 | // Patch branch instruction at pos to branch to given branch target pos. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1176 | void target_at_put(int pos, int target_pos, bool is_internal); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1177 | |
| 1178 | // Say if we need to relocate with this mode. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1179 | bool MustUseReg(RelocInfo::Mode rmode); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1180 | |
| 1181 | // Record reloc info for current pc_. |
| 1182 | void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); |
| 1183 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1184 | // Block the emission of the trampoline pool before pc_offset. |
| 1185 | void BlockTrampolinePoolBefore(int pc_offset) { |
| 1186 | if (no_trampoline_pool_before_ < pc_offset) |
| 1187 | no_trampoline_pool_before_ = pc_offset; |
| 1188 | } |
| 1189 | |
| 1190 | void StartBlockTrampolinePool() { |
| 1191 | trampoline_pool_blocked_nesting_++; |
| 1192 | } |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1193 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1194 | void EndBlockTrampolinePool() { |
| 1195 | trampoline_pool_blocked_nesting_--; |
| 1196 | } |
| 1197 | |
| 1198 | bool is_trampoline_pool_blocked() const { |
| 1199 | return trampoline_pool_blocked_nesting_ > 0; |
| 1200 | } |
| 1201 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1202 | bool has_exception() const { |
| 1203 | return internal_trampoline_exception_; |
| 1204 | } |
| 1205 | |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 1206 | void DoubleAsTwoUInt32(double d, uint32_t* lo, uint32_t* hi); |
| 1207 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1208 | bool is_trampoline_emitted() const { |
| 1209 | return trampoline_emitted_; |
| 1210 | } |
| 1211 | |
| 1212 | // Temporarily block automatic assembly buffer growth. |
| 1213 | void StartBlockGrowBuffer() { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1214 | DCHECK(!block_buffer_growth_); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1215 | block_buffer_growth_ = true; |
| 1216 | } |
| 1217 | |
| 1218 | void EndBlockGrowBuffer() { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1219 | DCHECK(block_buffer_growth_); |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1220 | block_buffer_growth_ = false; |
| 1221 | } |
| 1222 | |
| 1223 | bool is_buffer_growth_blocked() const { |
| 1224 | return block_buffer_growth_; |
| 1225 | } |
| 1226 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1227 | void EmitForbiddenSlotInstruction() { |
| 1228 | if (IsPrevInstrCompactBranch()) { |
| 1229 | nop(); |
| 1230 | } |
| 1231 | } |
| 1232 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1233 | inline void CheckTrampolinePoolQuick(int extra_instructions = 0); |
| 1234 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1235 | inline void CheckBuffer(); |
| 1236 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1237 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1238 | inline static void set_target_internal_reference_encoded_at(Address pc, |
| 1239 | Address target); |
| 1240 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1241 | // Buffer size and constant pool distance are checked together at regular |
| 1242 | // intervals of kBufferCheckInterval emitted bytes. |
| 1243 | static const int kBufferCheckInterval = 1*KB/2; |
| 1244 | |
| 1245 | // Code generation. |
| 1246 | // The relocation writer's position is at least kGap bytes below the end of |
| 1247 | // the generated instructions. This is so that multi-instruction sequences do |
| 1248 | // not have to check for overflow. The same is true for writes of large |
| 1249 | // relocation info entries. |
| 1250 | static const int kGap = 32; |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1251 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1252 | |
| 1253 | // Repeated checking whether the trampoline pool should be emitted is rather |
| 1254 | // expensive. By default we only check again once a number of instructions |
| 1255 | // has been generated. |
| 1256 | static const int kCheckConstIntervalInst = 32; |
| 1257 | static const int kCheckConstInterval = kCheckConstIntervalInst * kInstrSize; |
| 1258 | |
| 1259 | int next_buffer_check_; // pc offset of next buffer check. |
| 1260 | |
| 1261 | // Emission of the trampoline pool may be blocked in some code sequences. |
| 1262 | int trampoline_pool_blocked_nesting_; // Block emission if this is not zero. |
| 1263 | int no_trampoline_pool_before_; // Block emission before this pc offset. |
| 1264 | |
| 1265 | // Keep track of the last emitted pool to guarantee a maximal distance. |
| 1266 | int last_trampoline_pool_end_; // pc offset of the end of the last pool. |
| 1267 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1268 | // Automatic growth of the assembly buffer may be blocked for some sequences. |
| 1269 | bool block_buffer_growth_; // Block growth when true. |
| 1270 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1271 | // Relocation information generation. |
| 1272 | // Each relocation is encoded as a variable size value. |
| 1273 | static const int kMaxRelocSize = RelocInfoWriter::kMaxSize; |
| 1274 | RelocInfoWriter reloc_info_writer; |
| 1275 | |
| 1276 | // The bound position, before this we cannot do instruction elimination. |
| 1277 | int last_bound_pos_; |
| 1278 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1279 | // Readable constants for compact branch handling in emit() |
| 1280 | enum class CompactBranchType : bool { NO = false, COMPACT_BRANCH = true }; |
| 1281 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1282 | // Code emission. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1283 | void GrowBuffer(); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1284 | inline void emit(Instr x, |
| 1285 | CompactBranchType is_compact_branch = CompactBranchType::NO); |
| 1286 | inline void emit(uint64_t x); |
| 1287 | inline void CheckForEmitInForbiddenSlot(); |
| 1288 | template <typename T> |
| 1289 | inline void EmitHelper(T x); |
| 1290 | inline void EmitHelper(Instr x, CompactBranchType is_compact_branch); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1291 | |
| 1292 | // Instruction generation. |
| 1293 | // We have 3 different kind of encoding layout on MIPS. |
| 1294 | // However due to many different types of objects encoded in the same fields |
| 1295 | // we have quite a few aliases for each mode. |
| 1296 | // Using the same structure to refer to Register and FPURegister would spare a |
| 1297 | // few aliases, but mixing both does not look clean to me. |
| 1298 | // Anyway we could surely implement this differently. |
| 1299 | |
| 1300 | void GenInstrRegister(Opcode opcode, |
| 1301 | Register rs, |
| 1302 | Register rt, |
| 1303 | Register rd, |
| 1304 | uint16_t sa = 0, |
| 1305 | SecondaryField func = NULLSF); |
| 1306 | |
| 1307 | void GenInstrRegister(Opcode opcode, |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1308 | Register rs, |
| 1309 | Register rt, |
| 1310 | uint16_t msb, |
| 1311 | uint16_t lsb, |
| 1312 | SecondaryField func); |
| 1313 | |
| 1314 | void GenInstrRegister(Opcode opcode, |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1315 | SecondaryField fmt, |
| 1316 | FPURegister ft, |
| 1317 | FPURegister fs, |
| 1318 | FPURegister fd, |
| 1319 | SecondaryField func = NULLSF); |
| 1320 | |
| 1321 | void GenInstrRegister(Opcode opcode, |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1322 | FPURegister fr, |
| 1323 | FPURegister ft, |
| 1324 | FPURegister fs, |
| 1325 | FPURegister fd, |
| 1326 | SecondaryField func = NULLSF); |
| 1327 | |
| 1328 | void GenInstrRegister(Opcode opcode, |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1329 | SecondaryField fmt, |
| 1330 | Register rt, |
| 1331 | FPURegister fs, |
| 1332 | FPURegister fd, |
| 1333 | SecondaryField func = NULLSF); |
| 1334 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1335 | void GenInstrRegister(Opcode opcode, |
| 1336 | SecondaryField fmt, |
| 1337 | Register rt, |
| 1338 | FPUControlRegister fs, |
| 1339 | SecondaryField func = NULLSF); |
| 1340 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1341 | void GenInstrImmediate( |
| 1342 | Opcode opcode, Register rs, Register rt, int32_t j, |
| 1343 | CompactBranchType is_compact_branch = CompactBranchType::NO); |
| 1344 | void GenInstrImmediate( |
| 1345 | Opcode opcode, Register rs, SecondaryField SF, int32_t j, |
| 1346 | CompactBranchType is_compact_branch = CompactBranchType::NO); |
| 1347 | void GenInstrImmediate( |
| 1348 | Opcode opcode, Register r1, FPURegister r2, int32_t j, |
| 1349 | CompactBranchType is_compact_branch = CompactBranchType::NO); |
| 1350 | void GenInstrImmediate( |
| 1351 | Opcode opcode, Register rs, int32_t offset21, |
| 1352 | CompactBranchType is_compact_branch = CompactBranchType::NO); |
| 1353 | void GenInstrImmediate(Opcode opcode, Register rs, uint32_t offset21); |
| 1354 | void GenInstrImmediate( |
| 1355 | Opcode opcode, int32_t offset26, |
| 1356 | CompactBranchType is_compact_branch = CompactBranchType::NO); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1357 | |
| 1358 | |
| 1359 | void GenInstrJump(Opcode opcode, |
| 1360 | uint32_t address); |
| 1361 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1362 | // Helpers. |
| 1363 | void LoadRegPlusOffsetToAt(const MemOperand& src); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1364 | |
| 1365 | // Labels. |
| 1366 | void print(Label* L); |
| 1367 | void bind_to(Label* L, int pos); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1368 | void next(Label* L, bool is_internal); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1369 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1370 | // One trampoline consists of: |
| 1371 | // - space for trampoline slots, |
| 1372 | // - space for labels. |
| 1373 | // |
| 1374 | // Space for trampoline slots is equal to slot_count * 2 * kInstrSize. |
| 1375 | // Space for trampoline slots preceeds space for labels. Each label is of one |
| 1376 | // instruction size, so total amount for labels is equal to |
| 1377 | // label_count * kInstrSize. |
| 1378 | class Trampoline { |
| 1379 | public: |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1380 | Trampoline() { |
| 1381 | start_ = 0; |
| 1382 | next_slot_ = 0; |
| 1383 | free_slot_count_ = 0; |
| 1384 | end_ = 0; |
| 1385 | } |
| 1386 | Trampoline(int start, int slot_count) { |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1387 | start_ = start; |
| 1388 | next_slot_ = start; |
| 1389 | free_slot_count_ = slot_count; |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1390 | end_ = start + slot_count * kTrampolineSlotsSize; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1391 | } |
| 1392 | int start() { |
| 1393 | return start_; |
| 1394 | } |
| 1395 | int end() { |
| 1396 | return end_; |
| 1397 | } |
| 1398 | int take_slot() { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1399 | int trampoline_slot = kInvalidSlotPos; |
| 1400 | if (free_slot_count_ <= 0) { |
| 1401 | // We have run out of space on trampolines. |
| 1402 | // Make sure we fail in debug mode, so we become aware of each case |
| 1403 | // when this happens. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1404 | DCHECK(0); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1405 | // Internal exception will be caught. |
| 1406 | } else { |
| 1407 | trampoline_slot = next_slot_; |
| 1408 | free_slot_count_--; |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1409 | next_slot_ += kTrampolineSlotsSize; |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1410 | } |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1411 | return trampoline_slot; |
| 1412 | } |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 1413 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1414 | private: |
| 1415 | int start_; |
| 1416 | int end_; |
| 1417 | int next_slot_; |
| 1418 | int free_slot_count_; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1419 | }; |
| 1420 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1421 | int32_t get_trampoline_entry(int32_t pos); |
| 1422 | int unbound_labels_count_; |
| 1423 | // If trampoline is emitted, generated code is becoming large. As this is |
| 1424 | // already a slow case which can possibly break our code generation for the |
| 1425 | // extreme case, we use this information to trigger different mode of |
| 1426 | // branch instruction generation, where we use jump instructions rather |
| 1427 | // than regular branch instructions. |
| 1428 | bool trampoline_emitted_; |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1429 | #ifdef _MIPS_ARCH_MIPS32R6 |
| 1430 | static const int kTrampolineSlotsSize = 2 * kInstrSize; |
| 1431 | #else |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1432 | static const int kTrampolineSlotsSize = 4 * kInstrSize; |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1433 | #endif |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1434 | static const int kMaxBranchOffset = (1 << (18 - 1)) - 1; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1435 | static const int kMaxCompactBranchOffset = (1 << (28 - 1)) - 1; |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1436 | static const int kInvalidSlotPos = -1; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1437 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1438 | // Internal reference positions, required for unbounded internal reference |
| 1439 | // labels. |
| 1440 | std::set<int> internal_reference_positions_; |
| 1441 | |
| 1442 | void EmittedCompactBranchInstruction() { prev_instr_compact_branch_ = true; } |
| 1443 | void ClearCompactBranchState() { prev_instr_compact_branch_ = false; } |
| 1444 | bool prev_instr_compact_branch_ = false; |
| 1445 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1446 | Trampoline trampoline_; |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 1447 | bool internal_trampoline_exception_; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1448 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1449 | friend class RegExpMacroAssemblerMIPS; |
| 1450 | friend class RelocInfo; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1451 | friend class CodePatcher; |
| 1452 | friend class BlockTrampolinePoolScope; |
| 1453 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1454 | AssemblerPositionsRecorder positions_recorder_; |
| 1455 | friend class AssemblerPositionsRecorder; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 1456 | friend class EnsureSpace; |
| 1457 | }; |
| 1458 | |
| 1459 | |
| 1460 | class EnsureSpace BASE_EMBEDDED { |
| 1461 | public: |
| 1462 | explicit EnsureSpace(Assembler* assembler) { |
| 1463 | assembler->CheckBuffer(); |
| 1464 | } |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1465 | }; |
| 1466 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1467 | } // namespace internal |
| 1468 | } // namespace v8 |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 1469 | |
| 1470 | #endif // V8_ARM_ASSEMBLER_MIPS_H_ |