mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 1 | // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 | // All Rights Reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 3 | // |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 4 | // Redistribution and use in source and binary forms, with or without |
| 5 | // modification, are permitted provided that the following conditions |
| 6 | // are met: |
| 7 | // |
| 8 | // - Redistributions of source code must retain the above copyright notice, |
| 9 | // this list of conditions and the following disclaimer. |
| 10 | // |
| 11 | // - Redistribution in binary form must reproduce the above copyright |
| 12 | // notice, this list of conditions and the following disclaimer in the |
| 13 | // documentation and/or other materials provided with the |
| 14 | // distribution. |
| 15 | // |
| 16 | // - Neither the name of Sun Microsystems or the names of contributors may |
| 17 | // be used to endorse or promote products derived from this software without |
| 18 | // specific prior written permission. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 19 | // |
| 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 26 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 27 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 29 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 30 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 31 | // OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 33 | // The original source code covered by the above license above has been |
| 34 | // modified significantly by Google Inc. |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 35 | // Copyright 2012 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 36 | |
| 37 | // A light-weight ARM Assembler |
| 38 | // Generates user mode instructions for the ARM architecture up to version 5 |
| 39 | |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 40 | #ifndef V8_ARM_ASSEMBLER_ARM_H_ |
| 41 | #define V8_ARM_ASSEMBLER_ARM_H_ |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 42 | #include <stdio.h> |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 43 | #include "assembler.h" |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 44 | #include "constants-arm.h" |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 45 | #include "serialize.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 46 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 47 | namespace v8 { |
| 48 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 49 | |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 50 | // CpuFeatures keeps track of which features are supported by the target CPU. |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 51 | // Supported features must be enabled by a CpuFeatureScope before use. |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 52 | class CpuFeatures : public AllStatic { |
| 53 | public: |
| 54 | // Detect features of the target CPU. Set safe defaults if the serializer |
| 55 | // is enabled (snapshots must be portable). |
| 56 | static void Probe(); |
| 57 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 58 | // Display target use when compiling. |
| 59 | static void PrintTarget(); |
| 60 | |
| 61 | // Display features. |
| 62 | static void PrintFeatures(); |
| 63 | |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 64 | // Check whether a feature is supported by the target CPU. |
| 65 | static bool IsSupported(CpuFeature f) { |
| 66 | ASSERT(initialized_); |
mvstanton@chromium.org | 63ea3d2 | 2013-10-10 09:24:12 +0000 | [diff] [blame] | 67 | return Check(f, supported_); |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 68 | } |
| 69 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 70 | static bool IsFoundByRuntimeProbingOnly(CpuFeature f) { |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 71 | ASSERT(initialized_); |
mvstanton@chromium.org | 63ea3d2 | 2013-10-10 09:24:12 +0000 | [diff] [blame] | 72 | return Check(f, found_by_runtime_probing_only_); |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 73 | } |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 74 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 75 | static bool IsSafeForSnapshot(CpuFeature f) { |
mvstanton@chromium.org | 63ea3d2 | 2013-10-10 09:24:12 +0000 | [diff] [blame] | 76 | return Check(f, cross_compile_) || |
| 77 | (IsSupported(f) && |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 78 | (!Serializer::enabled() || !IsFoundByRuntimeProbingOnly(f))); |
| 79 | } |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 80 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 81 | static unsigned cache_line_size() { return cache_line_size_; } |
| 82 | |
mvstanton@chromium.org | 63ea3d2 | 2013-10-10 09:24:12 +0000 | [diff] [blame] | 83 | static bool VerifyCrossCompiling() { |
| 84 | return cross_compile_ == 0; |
| 85 | } |
| 86 | |
| 87 | static bool VerifyCrossCompiling(CpuFeature f) { |
| 88 | unsigned mask = flag2set(f); |
| 89 | return cross_compile_ == 0 || |
| 90 | (cross_compile_ & mask) == mask; |
| 91 | } |
| 92 | |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 93 | private: |
mvstanton@chromium.org | 63ea3d2 | 2013-10-10 09:24:12 +0000 | [diff] [blame] | 94 | static bool Check(CpuFeature f, unsigned set) { |
| 95 | return (set & flag2set(f)) != 0; |
| 96 | } |
| 97 | |
| 98 | static unsigned flag2set(CpuFeature f) { |
| 99 | return 1u << f; |
| 100 | } |
| 101 | |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 102 | #ifdef DEBUG |
| 103 | static bool initialized_; |
| 104 | #endif |
| 105 | static unsigned supported_; |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 106 | static unsigned found_by_runtime_probing_only_; |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 107 | static unsigned cache_line_size_; |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 108 | |
mvstanton@chromium.org | 63ea3d2 | 2013-10-10 09:24:12 +0000 | [diff] [blame] | 109 | static unsigned cross_compile_; |
| 110 | |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 111 | friend class ExternalReference; |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 112 | friend class PlatformFeatureScope; |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 113 | DISALLOW_COPY_AND_ASSIGN(CpuFeatures); |
| 114 | }; |
| 115 | |
| 116 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 117 | // CPU Registers. |
| 118 | // |
| 119 | // 1) We would prefer to use an enum, but enum values are assignment- |
| 120 | // compatible with int, which has caused code-generation bugs. |
| 121 | // |
| 122 | // 2) We would prefer to use a class instead of a struct but we don't like |
| 123 | // the register initialization to depend on the particular initialization |
| 124 | // order (which appears to be different on OS X, Linux, and Windows for the |
| 125 | // installed versions of C++ we tried). Using a struct permits C-style |
| 126 | // "initialization". Also, the Register objects cannot be const as this |
| 127 | // forces initialization stubs in MSVC, making us dependent on initialization |
| 128 | // order. |
| 129 | // |
| 130 | // 3) By not using an enum, we are possibly preventing the compiler from |
| 131 | // doing certain constant folds, which may significantly reduce the |
| 132 | // code generated for some assembly instructions (because they boil down |
| 133 | // to a few constants). If this is a problem, we could change the code |
| 134 | // such that we use an enum in optimized mode, and the struct in debug |
| 135 | // mode. This way we get the compile-time error checking in debug mode |
| 136 | // and best performance in optimized code. |
lrn@chromium.org | 5d00b60 | 2011-01-05 09:51:43 +0000 | [diff] [blame] | 137 | |
jkummerow@chromium.org | c366976 | 2013-09-30 13:42:25 +0000 | [diff] [blame] | 138 | // These constants are used in several locations, including static initializers |
| 139 | const int kRegister_no_reg_Code = -1; |
| 140 | const int kRegister_r0_Code = 0; |
| 141 | const int kRegister_r1_Code = 1; |
| 142 | const int kRegister_r2_Code = 2; |
| 143 | const int kRegister_r3_Code = 3; |
| 144 | const int kRegister_r4_Code = 4; |
| 145 | const int kRegister_r5_Code = 5; |
| 146 | const int kRegister_r6_Code = 6; |
| 147 | const int kRegister_r7_Code = 7; |
| 148 | const int kRegister_r8_Code = 8; |
| 149 | const int kRegister_r9_Code = 9; |
| 150 | const int kRegister_r10_Code = 10; |
| 151 | const int kRegister_fp_Code = 11; |
| 152 | const int kRegister_ip_Code = 12; |
| 153 | const int kRegister_sp_Code = 13; |
| 154 | const int kRegister_lr_Code = 14; |
| 155 | const int kRegister_pc_Code = 15; |
| 156 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 157 | // Core register |
| 158 | struct Register { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 159 | static const int kNumRegisters = 16; |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 160 | static const int kMaxNumAllocatableRegisters = |
jkummerow@chromium.org | c366976 | 2013-09-30 13:42:25 +0000 | [diff] [blame] | 161 | FLAG_enable_ool_constant_pool ? 8 : 9; |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 162 | static const int kSizeInBytes = 4; |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 163 | |
| 164 | inline static int NumAllocatableRegisters(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 165 | |
| 166 | static int ToAllocationIndex(Register reg) { |
jkummerow@chromium.org | c366976 | 2013-09-30 13:42:25 +0000 | [diff] [blame] | 167 | if (FLAG_enable_ool_constant_pool && (reg.code() >= kRegister_r8_Code)) { |
| 168 | return reg.code() - 1; |
| 169 | } |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 170 | ASSERT(reg.code() < kMaxNumAllocatableRegisters); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 171 | return reg.code(); |
| 172 | } |
| 173 | |
| 174 | static Register FromAllocationIndex(int index) { |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 175 | ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); |
jkummerow@chromium.org | c366976 | 2013-09-30 13:42:25 +0000 | [diff] [blame] | 176 | if (FLAG_enable_ool_constant_pool && (index >= 7)) { |
| 177 | return from_code(index + 1); |
| 178 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 179 | return from_code(index); |
| 180 | } |
| 181 | |
| 182 | static const char* AllocationIndexToString(int index) { |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 183 | ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 184 | const char* const names[] = { |
| 185 | "r0", |
| 186 | "r1", |
| 187 | "r2", |
| 188 | "r3", |
| 189 | "r4", |
| 190 | "r5", |
| 191 | "r6", |
| 192 | "r7", |
jkummerow@chromium.org | c366976 | 2013-09-30 13:42:25 +0000 | [diff] [blame] | 193 | "r8", |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 194 | }; |
jkummerow@chromium.org | c366976 | 2013-09-30 13:42:25 +0000 | [diff] [blame] | 195 | if (FLAG_enable_ool_constant_pool && (index >= 7)) { |
| 196 | return names[index + 1]; |
| 197 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 198 | return names[index]; |
| 199 | } |
| 200 | |
| 201 | static Register from_code(int code) { |
| 202 | Register r = { code }; |
| 203 | return r; |
| 204 | } |
| 205 | |
| 206 | bool is_valid() const { return 0 <= code_ && code_ < kNumRegisters; } |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 207 | bool is(Register reg) const { return code_ == reg.code_; } |
| 208 | int code() const { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 209 | ASSERT(is_valid()); |
| 210 | return code_; |
| 211 | } |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 212 | int bit() const { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 213 | ASSERT(is_valid()); |
| 214 | return 1 << code_; |
| 215 | } |
| 216 | |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 217 | void set_code(int code) { |
| 218 | code_ = code; |
| 219 | ASSERT(is_valid()); |
| 220 | } |
| 221 | |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 222 | // Unfortunately we can't make this private in a struct. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 223 | int code_; |
| 224 | }; |
| 225 | |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 226 | const Register no_reg = { kRegister_no_reg_Code }; |
| 227 | |
| 228 | const Register r0 = { kRegister_r0_Code }; |
| 229 | const Register r1 = { kRegister_r1_Code }; |
| 230 | const Register r2 = { kRegister_r2_Code }; |
| 231 | const Register r3 = { kRegister_r3_Code }; |
| 232 | const Register r4 = { kRegister_r4_Code }; |
| 233 | const Register r5 = { kRegister_r5_Code }; |
| 234 | const Register r6 = { kRegister_r6_Code }; |
jkummerow@chromium.org | c366976 | 2013-09-30 13:42:25 +0000 | [diff] [blame] | 235 | // Used as constant pool pointer register if FLAG_enable_ool_constant_pool. |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 236 | const Register r7 = { kRegister_r7_Code }; |
| 237 | // Used as context register. |
| 238 | const Register r8 = { kRegister_r8_Code }; |
| 239 | // Used as lithium codegen scratch register. |
| 240 | const Register r9 = { kRegister_r9_Code }; |
| 241 | // Used as roots register. |
| 242 | const Register r10 = { kRegister_r10_Code }; |
| 243 | const Register fp = { kRegister_fp_Code }; |
| 244 | const Register ip = { kRegister_ip_Code }; |
| 245 | const Register sp = { kRegister_sp_Code }; |
| 246 | const Register lr = { kRegister_lr_Code }; |
| 247 | const Register pc = { kRegister_pc_Code }; |
| 248 | |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 249 | // Single word VFP register. |
| 250 | struct SwVfpRegister { |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 251 | static const int kSizeInBytes = 4; |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 252 | bool is_valid() const { return 0 <= code_ && code_ < 32; } |
| 253 | bool is(SwVfpRegister reg) const { return code_ == reg.code_; } |
| 254 | int code() const { |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 255 | ASSERT(is_valid()); |
| 256 | return code_; |
| 257 | } |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 258 | int bit() const { |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 259 | ASSERT(is_valid()); |
| 260 | return 1 << code_; |
| 261 | } |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 262 | void split_code(int* vm, int* m) const { |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 263 | ASSERT(is_valid()); |
| 264 | *m = code_ & 0x1; |
| 265 | *vm = code_ >> 1; |
| 266 | } |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 267 | |
| 268 | int code_; |
| 269 | }; |
| 270 | |
| 271 | |
| 272 | // Double word VFP register. |
| 273 | struct DwVfpRegister { |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 274 | static const int kMaxNumRegisters = 32; |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 275 | // A few double registers are reserved: one as a scratch register and one to |
| 276 | // hold 0.0, that does not fit in the immediate field of vmov instructions. |
| 277 | // d14: 0.0 |
| 278 | // d15: scratch register. |
| 279 | static const int kNumReservedRegisters = 2; |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 280 | static const int kMaxNumAllocatableRegisters = kMaxNumRegisters - |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 281 | kNumReservedRegisters; |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 282 | static const int kSizeInBytes = 8; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 283 | |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 284 | // Note: the number of registers can be different at snapshot and run-time. |
| 285 | // Any code included in the snapshot must be able to run both with 16 or 32 |
| 286 | // registers. |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 287 | inline static int NumRegisters(); |
| 288 | inline static int NumAllocatableRegisters(); |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 289 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 290 | inline static int ToAllocationIndex(DwVfpRegister reg); |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 291 | static const char* AllocationIndexToString(int index); |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 292 | inline static DwVfpRegister FromAllocationIndex(int index); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 293 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 294 | static DwVfpRegister from_code(int code) { |
| 295 | DwVfpRegister r = { code }; |
| 296 | return r; |
| 297 | } |
| 298 | |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 299 | bool is_valid() const { |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 300 | return 0 <= code_ && code_ < kMaxNumRegisters; |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 301 | } |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 302 | bool is(DwVfpRegister reg) const { return code_ == reg.code_; } |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 303 | int code() const { |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 304 | ASSERT(is_valid()); |
| 305 | return code_; |
| 306 | } |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 307 | int bit() const { |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 308 | ASSERT(is_valid()); |
| 309 | return 1 << code_; |
| 310 | } |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 311 | void split_code(int* vm, int* m) const { |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 312 | ASSERT(is_valid()); |
| 313 | *m = (code_ & 0x10) >> 4; |
| 314 | *vm = code_ & 0x0F; |
| 315 | } |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 316 | |
| 317 | int code_; |
| 318 | }; |
| 319 | |
| 320 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 321 | typedef DwVfpRegister DoubleRegister; |
| 322 | |
| 323 | |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 324 | // Double word VFP register d0-15. |
| 325 | struct LowDwVfpRegister { |
| 326 | public: |
| 327 | static const int kMaxNumLowRegisters = 16; |
| 328 | operator DwVfpRegister() const { |
| 329 | DwVfpRegister r = { code_ }; |
| 330 | return r; |
| 331 | } |
| 332 | static LowDwVfpRegister from_code(int code) { |
| 333 | LowDwVfpRegister r = { code }; |
| 334 | return r; |
| 335 | } |
| 336 | |
| 337 | bool is_valid() const { |
| 338 | return 0 <= code_ && code_ < kMaxNumLowRegisters; |
| 339 | } |
| 340 | bool is(DwVfpRegister reg) const { return code_ == reg.code_; } |
| 341 | bool is(LowDwVfpRegister reg) const { return code_ == reg.code_; } |
| 342 | int code() const { |
| 343 | ASSERT(is_valid()); |
| 344 | return code_; |
| 345 | } |
| 346 | SwVfpRegister low() const { |
| 347 | SwVfpRegister reg; |
| 348 | reg.code_ = code_ * 2; |
| 349 | |
| 350 | ASSERT(reg.is_valid()); |
| 351 | return reg; |
| 352 | } |
| 353 | SwVfpRegister high() const { |
| 354 | SwVfpRegister reg; |
| 355 | reg.code_ = (code_ * 2) + 1; |
| 356 | |
| 357 | ASSERT(reg.is_valid()); |
| 358 | return reg; |
| 359 | } |
| 360 | |
| 361 | int code_; |
| 362 | }; |
| 363 | |
| 364 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 365 | // Quad word NEON register. |
| 366 | struct QwNeonRegister { |
| 367 | static const int kMaxNumRegisters = 16; |
| 368 | |
| 369 | static QwNeonRegister from_code(int code) { |
| 370 | QwNeonRegister r = { code }; |
| 371 | return r; |
| 372 | } |
| 373 | |
| 374 | bool is_valid() const { |
| 375 | return (0 <= code_) && (code_ < kMaxNumRegisters); |
| 376 | } |
| 377 | bool is(QwNeonRegister reg) const { return code_ == reg.code_; } |
| 378 | int code() const { |
| 379 | ASSERT(is_valid()); |
| 380 | return code_; |
| 381 | } |
| 382 | void split_code(int* vm, int* m) const { |
| 383 | ASSERT(is_valid()); |
| 384 | *m = (code_ & 0x10) >> 4; |
| 385 | *vm = code_ & 0x0F; |
| 386 | } |
| 387 | |
| 388 | int code_; |
| 389 | }; |
| 390 | |
| 391 | |
| 392 | typedef QwNeonRegister QuadRegister; |
| 393 | |
| 394 | |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 395 | // Support for the VFP registers s0 to s31 (d0 to d15). |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 396 | // Note that "s(N):s(N+1)" is the same as "d(N/2)". |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 397 | const SwVfpRegister s0 = { 0 }; |
| 398 | const SwVfpRegister s1 = { 1 }; |
| 399 | const SwVfpRegister s2 = { 2 }; |
| 400 | const SwVfpRegister s3 = { 3 }; |
| 401 | const SwVfpRegister s4 = { 4 }; |
| 402 | const SwVfpRegister s5 = { 5 }; |
| 403 | const SwVfpRegister s6 = { 6 }; |
| 404 | const SwVfpRegister s7 = { 7 }; |
| 405 | const SwVfpRegister s8 = { 8 }; |
| 406 | const SwVfpRegister s9 = { 9 }; |
| 407 | const SwVfpRegister s10 = { 10 }; |
| 408 | const SwVfpRegister s11 = { 11 }; |
| 409 | const SwVfpRegister s12 = { 12 }; |
| 410 | const SwVfpRegister s13 = { 13 }; |
| 411 | const SwVfpRegister s14 = { 14 }; |
| 412 | const SwVfpRegister s15 = { 15 }; |
| 413 | const SwVfpRegister s16 = { 16 }; |
| 414 | const SwVfpRegister s17 = { 17 }; |
| 415 | const SwVfpRegister s18 = { 18 }; |
| 416 | const SwVfpRegister s19 = { 19 }; |
| 417 | const SwVfpRegister s20 = { 20 }; |
| 418 | const SwVfpRegister s21 = { 21 }; |
| 419 | const SwVfpRegister s22 = { 22 }; |
| 420 | const SwVfpRegister s23 = { 23 }; |
| 421 | const SwVfpRegister s24 = { 24 }; |
| 422 | const SwVfpRegister s25 = { 25 }; |
| 423 | const SwVfpRegister s26 = { 26 }; |
| 424 | const SwVfpRegister s27 = { 27 }; |
| 425 | const SwVfpRegister s28 = { 28 }; |
| 426 | const SwVfpRegister s29 = { 29 }; |
| 427 | const SwVfpRegister s30 = { 30 }; |
| 428 | const SwVfpRegister s31 = { 31 }; |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 429 | |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 430 | const DwVfpRegister no_dreg = { -1 }; |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 431 | const LowDwVfpRegister d0 = { 0 }; |
| 432 | const LowDwVfpRegister d1 = { 1 }; |
| 433 | const LowDwVfpRegister d2 = { 2 }; |
| 434 | const LowDwVfpRegister d3 = { 3 }; |
| 435 | const LowDwVfpRegister d4 = { 4 }; |
| 436 | const LowDwVfpRegister d5 = { 5 }; |
| 437 | const LowDwVfpRegister d6 = { 6 }; |
| 438 | const LowDwVfpRegister d7 = { 7 }; |
| 439 | const LowDwVfpRegister d8 = { 8 }; |
| 440 | const LowDwVfpRegister d9 = { 9 }; |
| 441 | const LowDwVfpRegister d10 = { 10 }; |
| 442 | const LowDwVfpRegister d11 = { 11 }; |
| 443 | const LowDwVfpRegister d12 = { 12 }; |
| 444 | const LowDwVfpRegister d13 = { 13 }; |
| 445 | const LowDwVfpRegister d14 = { 14 }; |
| 446 | const LowDwVfpRegister d15 = { 15 }; |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 447 | const DwVfpRegister d16 = { 16 }; |
| 448 | const DwVfpRegister d17 = { 17 }; |
| 449 | const DwVfpRegister d18 = { 18 }; |
| 450 | const DwVfpRegister d19 = { 19 }; |
| 451 | const DwVfpRegister d20 = { 20 }; |
| 452 | const DwVfpRegister d21 = { 21 }; |
| 453 | const DwVfpRegister d22 = { 22 }; |
| 454 | const DwVfpRegister d23 = { 23 }; |
| 455 | const DwVfpRegister d24 = { 24 }; |
| 456 | const DwVfpRegister d25 = { 25 }; |
| 457 | const DwVfpRegister d26 = { 26 }; |
| 458 | const DwVfpRegister d27 = { 27 }; |
| 459 | const DwVfpRegister d28 = { 28 }; |
| 460 | const DwVfpRegister d29 = { 29 }; |
| 461 | const DwVfpRegister d30 = { 30 }; |
| 462 | const DwVfpRegister d31 = { 31 }; |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 463 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 464 | const QwNeonRegister q0 = { 0 }; |
| 465 | const QwNeonRegister q1 = { 1 }; |
| 466 | const QwNeonRegister q2 = { 2 }; |
| 467 | const QwNeonRegister q3 = { 3 }; |
| 468 | const QwNeonRegister q4 = { 4 }; |
| 469 | const QwNeonRegister q5 = { 5 }; |
| 470 | const QwNeonRegister q6 = { 6 }; |
| 471 | const QwNeonRegister q7 = { 7 }; |
| 472 | const QwNeonRegister q8 = { 8 }; |
| 473 | const QwNeonRegister q9 = { 9 }; |
| 474 | const QwNeonRegister q10 = { 10 }; |
| 475 | const QwNeonRegister q11 = { 11 }; |
| 476 | const QwNeonRegister q12 = { 12 }; |
| 477 | const QwNeonRegister q13 = { 13 }; |
| 478 | const QwNeonRegister q14 = { 14 }; |
| 479 | const QwNeonRegister q15 = { 15 }; |
| 480 | |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 481 | |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 482 | // Aliases for double registers. Defined using #define instead of |
| 483 | // "static const DwVfpRegister&" because Clang complains otherwise when a |
| 484 | // compilation unit that includes this header doesn't use the variables. |
| 485 | #define kFirstCalleeSavedDoubleReg d8 |
| 486 | #define kLastCalleeSavedDoubleReg d15 |
| 487 | #define kDoubleRegZero d14 |
| 488 | #define kScratchDoubleReg d15 |
lrn@chromium.org | ac2828d | 2011-06-23 06:29:21 +0000 | [diff] [blame] | 489 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 490 | |
| 491 | // Coprocessor register |
| 492 | struct CRegister { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 493 | bool is_valid() const { return 0 <= code_ && code_ < 16; } |
| 494 | bool is(CRegister creg) const { return code_ == creg.code_; } |
| 495 | int code() const { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 496 | ASSERT(is_valid()); |
| 497 | return code_; |
| 498 | } |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 499 | int bit() const { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 500 | ASSERT(is_valid()); |
| 501 | return 1 << code_; |
| 502 | } |
| 503 | |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 504 | // Unfortunately we can't make this private in a struct. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 505 | int code_; |
| 506 | }; |
| 507 | |
| 508 | |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 509 | const CRegister no_creg = { -1 }; |
| 510 | |
| 511 | const CRegister cr0 = { 0 }; |
| 512 | const CRegister cr1 = { 1 }; |
| 513 | const CRegister cr2 = { 2 }; |
| 514 | const CRegister cr3 = { 3 }; |
| 515 | const CRegister cr4 = { 4 }; |
| 516 | const CRegister cr5 = { 5 }; |
| 517 | const CRegister cr6 = { 6 }; |
| 518 | const CRegister cr7 = { 7 }; |
| 519 | const CRegister cr8 = { 8 }; |
| 520 | const CRegister cr9 = { 9 }; |
| 521 | const CRegister cr10 = { 10 }; |
| 522 | const CRegister cr11 = { 11 }; |
| 523 | const CRegister cr12 = { 12 }; |
| 524 | const CRegister cr13 = { 13 }; |
| 525 | const CRegister cr14 = { 14 }; |
| 526 | const CRegister cr15 = { 15 }; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 527 | |
| 528 | |
| 529 | // Coprocessor number |
| 530 | enum Coprocessor { |
| 531 | p0 = 0, |
| 532 | p1 = 1, |
| 533 | p2 = 2, |
| 534 | p3 = 3, |
| 535 | p4 = 4, |
| 536 | p5 = 5, |
| 537 | p6 = 6, |
| 538 | p7 = 7, |
| 539 | p8 = 8, |
| 540 | p9 = 9, |
| 541 | p10 = 10, |
| 542 | p11 = 11, |
| 543 | p12 = 12, |
| 544 | p13 = 13, |
| 545 | p14 = 14, |
| 546 | p15 = 15 |
| 547 | }; |
| 548 | |
| 549 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 550 | // ----------------------------------------------------------------------------- |
| 551 | // Machine instruction Operands |
| 552 | |
| 553 | // Class Operand represents a shifter operand in data processing instructions |
| 554 | class Operand BASE_EMBEDDED { |
| 555 | public: |
| 556 | // immediate |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 557 | INLINE(explicit Operand(int32_t immediate, |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 558 | RelocInfo::Mode rmode = RelocInfo::NONE32)); |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 559 | INLINE(static Operand Zero()) { |
| 560 | return Operand(static_cast<int32_t>(0)); |
| 561 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 562 | INLINE(explicit Operand(const ExternalReference& f)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 563 | explicit Operand(Handle<Object> handle); |
| 564 | INLINE(explicit Operand(Smi* value)); |
| 565 | |
| 566 | // rm |
| 567 | INLINE(explicit Operand(Register rm)); |
| 568 | |
| 569 | // rm <shift_op> shift_imm |
| 570 | explicit Operand(Register rm, ShiftOp shift_op, int shift_imm); |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 571 | INLINE(static Operand SmiUntag(Register rm)) { |
| 572 | return Operand(rm, ASR, kSmiTagSize); |
| 573 | } |
| 574 | INLINE(static Operand PointerOffsetFromSmiKey(Register key)) { |
| 575 | STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize < kPointerSizeLog2); |
| 576 | return Operand(key, LSL, kPointerSizeLog2 - kSmiTagSize); |
| 577 | } |
| 578 | INLINE(static Operand DoubleOffsetFromSmiKey(Register key)) { |
| 579 | STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize < kDoubleSizeLog2); |
| 580 | return Operand(key, LSL, kDoubleSizeLog2 - kSmiTagSize); |
| 581 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 582 | |
| 583 | // rm <shift_op> rs |
| 584 | explicit Operand(Register rm, ShiftOp shift_op, Register rs); |
| 585 | |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 586 | // Return true if this is a register operand. |
| 587 | INLINE(bool is_reg() const); |
| 588 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 589 | // Return true if this operand fits in one instruction so that no |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 590 | // 2-instruction solution with a load into the ip register is necessary. If |
| 591 | // the instruction this operand is used for is a MOV or MVN instruction the |
| 592 | // actual instruction to use is required for this calculation. For other |
| 593 | // instructions instr is ignored. |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 594 | bool is_single_instruction(const Assembler* assembler, Instr instr = 0) const; |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 595 | bool must_output_reloc_info(const Assembler* assembler) const; |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 596 | |
| 597 | inline int32_t immediate() const { |
| 598 | ASSERT(!rm_.is_valid()); |
| 599 | return imm32_; |
| 600 | } |
| 601 | |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 602 | Register rm() const { return rm_; } |
fschneider@chromium.org | ed78ffd | 2010-07-21 11:05:19 +0000 | [diff] [blame] | 603 | Register rs() const { return rs_; } |
| 604 | ShiftOp shift_op() const { return shift_op_; } |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 605 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 606 | private: |
| 607 | Register rm_; |
| 608 | Register rs_; |
| 609 | ShiftOp shift_op_; |
| 610 | int shift_imm_; // valid if rm_ != no_reg && rs_ == no_reg |
| 611 | int32_t imm32_; // valid if rm_ == no_reg |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 612 | RelocInfo::Mode rmode_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 613 | |
| 614 | friend class Assembler; |
| 615 | }; |
| 616 | |
| 617 | |
| 618 | // Class MemOperand represents a memory operand in load and store instructions |
| 619 | class MemOperand BASE_EMBEDDED { |
| 620 | public: |
| 621 | // [rn +/- offset] Offset/NegOffset |
| 622 | // [rn +/- offset]! PreIndex/NegPreIndex |
| 623 | // [rn], +/- offset PostIndex/NegPostIndex |
| 624 | // offset is any signed 32-bit value; offset is first loaded to register ip if |
| 625 | // it does not fit the addressing mode (12-bit unsigned and sign bit) |
| 626 | explicit MemOperand(Register rn, int32_t offset = 0, AddrMode am = Offset); |
| 627 | |
| 628 | // [rn +/- rm] Offset/NegOffset |
| 629 | // [rn +/- rm]! PreIndex/NegPreIndex |
| 630 | // [rn], +/- rm PostIndex/NegPostIndex |
| 631 | explicit MemOperand(Register rn, Register rm, AddrMode am = Offset); |
| 632 | |
| 633 | // [rn +/- rm <shift_op> shift_imm] Offset/NegOffset |
| 634 | // [rn +/- rm <shift_op> shift_imm]! PreIndex/NegPreIndex |
| 635 | // [rn], +/- rm <shift_op> shift_imm PostIndex/NegPostIndex |
| 636 | explicit MemOperand(Register rn, Register rm, |
| 637 | ShiftOp shift_op, int shift_imm, AddrMode am = Offset); |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 638 | INLINE(static MemOperand PointerAddressFromSmiKey(Register array, |
| 639 | Register key, |
| 640 | AddrMode am = Offset)) { |
| 641 | STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize < kPointerSizeLog2); |
| 642 | return MemOperand(array, key, LSL, kPointerSizeLog2 - kSmiTagSize, am); |
| 643 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 644 | |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 645 | void set_offset(int32_t offset) { |
| 646 | ASSERT(rm_.is(no_reg)); |
| 647 | offset_ = offset; |
| 648 | } |
| 649 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 650 | uint32_t offset() const { |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 651 | ASSERT(rm_.is(no_reg)); |
| 652 | return offset_; |
| 653 | } |
| 654 | |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 655 | Register rn() const { return rn_; } |
| 656 | Register rm() const { return rm_; } |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 657 | AddrMode am() const { return am_; } |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 658 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 659 | bool OffsetIsUint12Encodable() const { |
| 660 | return offset_ >= 0 ? is_uint12(offset_) : is_uint12(-offset_); |
| 661 | } |
| 662 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 663 | private: |
| 664 | Register rn_; // base |
| 665 | Register rm_; // register offset |
| 666 | int32_t offset_; // valid if rm_ == no_reg |
| 667 | ShiftOp shift_op_; |
| 668 | int shift_imm_; // valid if rm_ != no_reg && rs_ == no_reg |
| 669 | AddrMode am_; // bits P, U, and W |
| 670 | |
| 671 | friend class Assembler; |
| 672 | }; |
| 673 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 674 | |
| 675 | // Class NeonMemOperand represents a memory operand in load and |
| 676 | // store NEON instructions |
| 677 | class NeonMemOperand BASE_EMBEDDED { |
| 678 | public: |
| 679 | // [rn {:align}] Offset |
| 680 | // [rn {:align}]! PostIndex |
| 681 | explicit NeonMemOperand(Register rn, AddrMode am = Offset, int align = 0); |
| 682 | |
| 683 | // [rn {:align}], rm PostIndex |
| 684 | explicit NeonMemOperand(Register rn, Register rm, int align = 0); |
| 685 | |
| 686 | Register rn() const { return rn_; } |
| 687 | Register rm() const { return rm_; } |
| 688 | int align() const { return align_; } |
| 689 | |
| 690 | private: |
| 691 | void SetAlignment(int align); |
| 692 | |
| 693 | Register rn_; // base |
| 694 | Register rm_; // register increment |
| 695 | int align_; |
| 696 | }; |
| 697 | |
| 698 | |
| 699 | // Class NeonListOperand represents a list of NEON registers |
| 700 | class NeonListOperand BASE_EMBEDDED { |
| 701 | public: |
| 702 | explicit NeonListOperand(DoubleRegister base, int registers_count = 1); |
| 703 | DoubleRegister base() const { return base_; } |
| 704 | NeonListType type() const { return type_; } |
| 705 | private: |
| 706 | DoubleRegister base_; |
| 707 | NeonListType type_; |
| 708 | }; |
| 709 | |
ager@chromium.org | 4af710e | 2009-09-15 12:20:11 +0000 | [diff] [blame] | 710 | extern const Instr kMovLrPc; |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 711 | extern const Instr kLdrPCMask; |
ager@chromium.org | 4af710e | 2009-09-15 12:20:11 +0000 | [diff] [blame] | 712 | extern const Instr kLdrPCPattern; |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 713 | extern const Instr kBlxRegMask; |
| 714 | extern const Instr kBlxRegPattern; |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 715 | extern const Instr kBlxIp; |
ager@chromium.org | 4af710e | 2009-09-15 12:20:11 +0000 | [diff] [blame] | 716 | |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 717 | extern const Instr kMovMvnMask; |
| 718 | extern const Instr kMovMvnPattern; |
| 719 | extern const Instr kMovMvnFlip; |
| 720 | |
ricow@chromium.org | 5ad5ace | 2010-06-23 09:06:43 +0000 | [diff] [blame] | 721 | extern const Instr kMovLeaveCCMask; |
| 722 | extern const Instr kMovLeaveCCPattern; |
| 723 | extern const Instr kMovwMask; |
| 724 | extern const Instr kMovwPattern; |
| 725 | extern const Instr kMovwLeaveCCFlip; |
| 726 | |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 727 | extern const Instr kCmpCmnMask; |
| 728 | extern const Instr kCmpCmnPattern; |
| 729 | extern const Instr kCmpCmnFlip; |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 730 | extern const Instr kAddSubFlip; |
| 731 | extern const Instr kAndBicFlip; |
ager@chromium.org | 4af710e | 2009-09-15 12:20:11 +0000 | [diff] [blame] | 732 | |
ulan@chromium.org | 6ba1fd0 | 2013-02-14 14:56:11 +0000 | [diff] [blame] | 733 | struct VmovIndex { |
| 734 | unsigned char index; |
| 735 | }; |
| 736 | const VmovIndex VmovIndexLo = { 0 }; |
| 737 | const VmovIndex VmovIndexHi = { 1 }; |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 738 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 739 | class Assembler : public AssemblerBase { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 740 | public: |
| 741 | // Create an assembler. Instructions and relocation information are emitted |
| 742 | // into a buffer, with the instructions starting from the beginning and the |
| 743 | // relocation information starting from the end of the buffer. See CodeDesc |
| 744 | // for a detailed comment on the layout (globals.h). |
| 745 | // |
| 746 | // If the provided buffer is NULL, the assembler allocates and grows its own |
| 747 | // buffer, and buffer_size determines the initial buffer size. The buffer is |
| 748 | // owned by the assembler and deallocated upon destruction of the assembler. |
| 749 | // |
| 750 | // If the provided buffer is not NULL, the assembler uses the provided buffer |
| 751 | // for code generation and assumes its size to be buffer_size. If the buffer |
| 752 | // is too small, a fatal error occurs. No deallocation of the buffer is done |
| 753 | // upon destruction of the assembler. |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 754 | Assembler(Isolate* isolate, void* buffer, int buffer_size); |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 755 | virtual ~Assembler(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 756 | |
| 757 | // GetCode emits any pending (non-emitted) code and fills the descriptor |
| 758 | // desc. GetCode() is idempotent; it returns the same result if no other |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 759 | // Assembler functions are invoked in between GetCode() calls. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 760 | void GetCode(CodeDesc* desc); |
| 761 | |
| 762 | // Label operations & relative jumps (PPUM Appendix D) |
| 763 | // |
| 764 | // Takes a branch opcode (cc) and a label (L) and generates |
| 765 | // either a backward branch or a forward branch and links it |
| 766 | // to the label fixup chain. Usage: |
| 767 | // |
| 768 | // Label L; // unbound label |
| 769 | // j(cc, &L); // forward branch to unbound label |
| 770 | // bind(&L); // bind label to the current pc |
| 771 | // j(cc, &L); // backward branch to bound label |
| 772 | // bind(&L); // illegal: a label may be bound only once |
| 773 | // |
| 774 | // Note: The same Label can be used for forward and backward branches |
| 775 | // but it may be bound only once. |
| 776 | |
| 777 | void bind(Label* L); // binds an unbound label L to the current code position |
| 778 | |
| 779 | // Returns the branch offset to the given label from the current code position |
| 780 | // Links the label to the current position if it is still unbound |
mads.s.ager@gmail.com | 769cc96 | 2008-08-06 10:02:49 +0000 | [diff] [blame] | 781 | // Manages the jump elimination optimization if the second parameter is true. |
| 782 | int branch_offset(Label* L, bool jump_elimination_allowed); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 783 | |
| 784 | // Return the address in the constant pool of the code target address used by |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 785 | // the branch/call instruction at pc, or the object in a mov. |
| 786 | INLINE(static Address target_pointer_address_at(Address pc)); |
| 787 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 788 | // Read/Modify the code target address in the branch/call instruction at pc. |
| 789 | INLINE(static Address target_address_at(Address pc)); |
| 790 | INLINE(static void set_target_address_at(Address pc, Address target)); |
| 791 | |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 792 | // Return the code target address at a call site from the return address |
| 793 | // of that call in the instruction stream. |
| 794 | INLINE(static Address target_address_from_return_address(Address pc)); |
| 795 | |
| 796 | // Given the address of the beginning of a call, return the address |
| 797 | // in the instruction stream that the call will return from. |
| 798 | INLINE(static Address return_address_from_call_start(Address pc)); |
| 799 | |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 800 | // This sets the branch destination (which is in the constant pool on ARM). |
| 801 | // This is for calls and branches within generated code. |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 802 | inline static void deserialization_set_special_target_at( |
| 803 | Address constant_pool_entry, Address target); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 804 | |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 805 | // This sets the branch destination (which is in the constant pool on ARM). |
| 806 | // This is for calls and branches to runtime code. |
| 807 | inline static void set_external_target_at(Address constant_pool_entry, |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 808 | Address target); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 809 | |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 810 | // Here we are patching the address in the constant pool, not the actual call |
| 811 | // instruction. The address in the constant pool is the same size as a |
| 812 | // pointer. |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 813 | static const int kSpecialTargetSize = kPointerSize; |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 814 | |
ager@chromium.org | 4af710e | 2009-09-15 12:20:11 +0000 | [diff] [blame] | 815 | // Size of an instruction. |
| 816 | static const int kInstrSize = sizeof(Instr); |
| 817 | |
sgjesse@chromium.org | 911335c | 2009-08-19 12:59:44 +0000 | [diff] [blame] | 818 | // Distance between start of patched return sequence and the emitted address |
| 819 | // to jump to. |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 820 | // Patched return sequence is: |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 821 | // ldr ip, [pc, #0] @ emited address and start |
| 822 | // blx ip |
| 823 | static const int kPatchReturnSequenceAddressOffset = 0 * kInstrSize; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 824 | |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 825 | // Distance between start of patched debug break slot and the emitted address |
| 826 | // to jump to. |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 827 | // Patched debug break slot code is: |
| 828 | // ldr ip, [pc, #0] @ emited address and start |
| 829 | // blx ip |
| 830 | static const int kPatchDebugBreakSlotAddressOffset = 0 * kInstrSize; |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 831 | |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 832 | static const int kPatchDebugBreakSlotReturnOffset = 2 * kInstrSize; |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 833 | |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 834 | // Difference between address of current opcode and value read from pc |
| 835 | // register. |
| 836 | static const int kPcLoadDelta = 8; |
| 837 | |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 838 | static const int kJSReturnSequenceInstructions = 4; |
| 839 | static const int kDebugBreakSlotInstructions = 3; |
| 840 | static const int kDebugBreakSlotLength = |
| 841 | kDebugBreakSlotInstructions * kInstrSize; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 842 | |
| 843 | // --------------------------------------------------------------------------- |
| 844 | // Code generation |
| 845 | |
| 846 | // Insert the smallest number of nop instructions |
| 847 | // possible to align the pc offset to a multiple |
| 848 | // of m. m must be a power of 2 (>= 4). |
| 849 | void Align(int m); |
ricow@chromium.org | 5ad5ace | 2010-06-23 09:06:43 +0000 | [diff] [blame] | 850 | // Aligns code to something that's optimal for a jump target for the platform. |
| 851 | void CodeTargetAlign(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 852 | |
| 853 | // Branch instructions |
| 854 | void b(int branch_offset, Condition cond = al); |
| 855 | void bl(int branch_offset, Condition cond = al); |
| 856 | void blx(int branch_offset); // v5 and above |
| 857 | void blx(Register target, Condition cond = al); // v5 and above |
| 858 | void bx(Register target, Condition cond = al); // v5 and above, plus v4t |
| 859 | |
| 860 | // Convenience branch instructions using labels |
mads.s.ager@gmail.com | 769cc96 | 2008-08-06 10:02:49 +0000 | [diff] [blame] | 861 | void b(Label* L, Condition cond = al) { |
| 862 | b(branch_offset(L, cond == al), cond); |
| 863 | } |
| 864 | void b(Condition cond, Label* L) { b(branch_offset(L, cond == al), cond); } |
| 865 | void bl(Label* L, Condition cond = al) { bl(branch_offset(L, false), cond); } |
| 866 | void bl(Condition cond, Label* L) { bl(branch_offset(L, false), cond); } |
| 867 | void blx(Label* L) { blx(branch_offset(L, false)); } // v5 and above |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 868 | |
| 869 | // Data-processing instructions |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 870 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 871 | void and_(Register dst, Register src1, const Operand& src2, |
| 872 | SBit s = LeaveCC, Condition cond = al); |
| 873 | |
| 874 | void eor(Register dst, Register src1, const Operand& src2, |
| 875 | SBit s = LeaveCC, Condition cond = al); |
| 876 | |
| 877 | void sub(Register dst, Register src1, const Operand& src2, |
| 878 | SBit s = LeaveCC, Condition cond = al); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 879 | void sub(Register dst, Register src1, Register src2, |
| 880 | SBit s = LeaveCC, Condition cond = al) { |
| 881 | sub(dst, src1, Operand(src2), s, cond); |
| 882 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 883 | |
| 884 | void rsb(Register dst, Register src1, const Operand& src2, |
| 885 | SBit s = LeaveCC, Condition cond = al); |
| 886 | |
| 887 | void add(Register dst, Register src1, const Operand& src2, |
| 888 | SBit s = LeaveCC, Condition cond = al); |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 889 | void add(Register dst, Register src1, Register src2, |
| 890 | SBit s = LeaveCC, Condition cond = al) { |
| 891 | add(dst, src1, Operand(src2), s, cond); |
| 892 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 893 | |
| 894 | void adc(Register dst, Register src1, const Operand& src2, |
| 895 | SBit s = LeaveCC, Condition cond = al); |
| 896 | |
| 897 | void sbc(Register dst, Register src1, const Operand& src2, |
| 898 | SBit s = LeaveCC, Condition cond = al); |
| 899 | |
| 900 | void rsc(Register dst, Register src1, const Operand& src2, |
| 901 | SBit s = LeaveCC, Condition cond = al); |
| 902 | |
| 903 | void tst(Register src1, const Operand& src2, Condition cond = al); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 904 | void tst(Register src1, Register src2, Condition cond = al) { |
| 905 | tst(src1, Operand(src2), cond); |
| 906 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 907 | |
| 908 | void teq(Register src1, const Operand& src2, Condition cond = al); |
| 909 | |
| 910 | void cmp(Register src1, const Operand& src2, Condition cond = al); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 911 | void cmp(Register src1, Register src2, Condition cond = al) { |
| 912 | cmp(src1, Operand(src2), cond); |
| 913 | } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 914 | void cmp_raw_immediate(Register src1, int raw_immediate, Condition cond = al); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 915 | |
| 916 | void cmn(Register src1, const Operand& src2, Condition cond = al); |
| 917 | |
| 918 | void orr(Register dst, Register src1, const Operand& src2, |
| 919 | SBit s = LeaveCC, Condition cond = al); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 920 | void orr(Register dst, Register src1, Register src2, |
| 921 | SBit s = LeaveCC, Condition cond = al) { |
| 922 | orr(dst, src1, Operand(src2), s, cond); |
| 923 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 924 | |
| 925 | void mov(Register dst, const Operand& src, |
| 926 | SBit s = LeaveCC, Condition cond = al); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 927 | void mov(Register dst, Register src, SBit s = LeaveCC, Condition cond = al) { |
| 928 | mov(dst, Operand(src), s, cond); |
| 929 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 930 | |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 931 | // Load the position of the label relative to the generated code object |
| 932 | // pointer in a register. |
| 933 | void mov_label_offset(Register dst, Label* label); |
| 934 | |
ricow@chromium.org | 5ad5ace | 2010-06-23 09:06:43 +0000 | [diff] [blame] | 935 | // ARMv7 instructions for loading a 32 bit immediate in two instructions. |
| 936 | // This may actually emit a different mov instruction, but on an ARMv7 it |
| 937 | // is guaranteed to only emit one instruction. |
| 938 | void movw(Register reg, uint32_t immediate, Condition cond = al); |
| 939 | // The constant for movt should be in the range 0-0xffff. |
| 940 | void movt(Register reg, uint32_t immediate, Condition cond = al); |
| 941 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 942 | void bic(Register dst, Register src1, const Operand& src2, |
| 943 | SBit s = LeaveCC, Condition cond = al); |
| 944 | |
| 945 | void mvn(Register dst, const Operand& src, |
| 946 | SBit s = LeaveCC, Condition cond = al); |
| 947 | |
| 948 | // Multiply instructions |
| 949 | |
| 950 | void mla(Register dst, Register src1, Register src2, Register srcA, |
| 951 | SBit s = LeaveCC, Condition cond = al); |
| 952 | |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 953 | void mls(Register dst, Register src1, Register src2, Register srcA, |
| 954 | Condition cond = al); |
| 955 | |
| 956 | void sdiv(Register dst, Register src1, Register src2, |
| 957 | Condition cond = al); |
| 958 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 959 | void mul(Register dst, Register src1, Register src2, |
| 960 | SBit s = LeaveCC, Condition cond = al); |
| 961 | |
| 962 | void smlal(Register dstL, Register dstH, Register src1, Register src2, |
| 963 | SBit s = LeaveCC, Condition cond = al); |
| 964 | |
| 965 | void smull(Register dstL, Register dstH, Register src1, Register src2, |
| 966 | SBit s = LeaveCC, Condition cond = al); |
| 967 | |
| 968 | void umlal(Register dstL, Register dstH, Register src1, Register src2, |
| 969 | SBit s = LeaveCC, Condition cond = al); |
| 970 | |
| 971 | void umull(Register dstL, Register dstH, Register src1, Register src2, |
| 972 | SBit s = LeaveCC, Condition cond = al); |
| 973 | |
| 974 | // Miscellaneous arithmetic instructions |
| 975 | |
| 976 | void clz(Register dst, Register src, Condition cond = al); // v5 and above |
| 977 | |
fschneider@chromium.org | ed78ffd | 2010-07-21 11:05:19 +0000 | [diff] [blame] | 978 | // Saturating instructions. v6 and above. |
| 979 | |
| 980 | // Unsigned saturate. |
| 981 | // |
| 982 | // Saturate an optionally shifted signed value to an unsigned range. |
| 983 | // |
| 984 | // usat dst, #satpos, src |
| 985 | // usat dst, #satpos, src, lsl #sh |
| 986 | // usat dst, #satpos, src, asr #sh |
| 987 | // |
| 988 | // Register dst will contain: |
| 989 | // |
| 990 | // 0, if s < 0 |
| 991 | // (1 << satpos) - 1, if s > ((1 << satpos) - 1) |
| 992 | // s, otherwise |
| 993 | // |
| 994 | // where s is the contents of src after shifting (if used.) |
| 995 | void usat(Register dst, int satpos, const Operand& src, Condition cond = al); |
| 996 | |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 997 | // Bitfield manipulation instructions. v7 and above. |
| 998 | |
| 999 | void ubfx(Register dst, Register src, int lsb, int width, |
| 1000 | Condition cond = al); |
| 1001 | |
| 1002 | void sbfx(Register dst, Register src, int lsb, int width, |
| 1003 | Condition cond = al); |
| 1004 | |
| 1005 | void bfc(Register dst, int lsb, int width, Condition cond = al); |
| 1006 | |
| 1007 | void bfi(Register dst, Register src, int lsb, int width, |
| 1008 | Condition cond = al); |
| 1009 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1010 | void pkhbt(Register dst, Register src1, const Operand& src2, |
| 1011 | Condition cond = al); |
| 1012 | |
| 1013 | void pkhtb(Register dst, Register src1, const Operand& src2, |
| 1014 | Condition cond = al); |
| 1015 | |
| 1016 | void uxtb(Register dst, const Operand& src, Condition cond = al); |
| 1017 | |
| 1018 | void uxtab(Register dst, Register src1, const Operand& src2, |
| 1019 | Condition cond = al); |
| 1020 | |
| 1021 | void uxtb16(Register dst, const Operand& src, Condition cond = al); |
| 1022 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1023 | // Status register access instructions |
| 1024 | |
| 1025 | void mrs(Register dst, SRegister s, Condition cond = al); |
| 1026 | void msr(SRegisterFieldMask fields, const Operand& src, Condition cond = al); |
| 1027 | |
| 1028 | // Load/Store instructions |
| 1029 | void ldr(Register dst, const MemOperand& src, Condition cond = al); |
| 1030 | void str(Register src, const MemOperand& dst, Condition cond = al); |
| 1031 | void ldrb(Register dst, const MemOperand& src, Condition cond = al); |
| 1032 | void strb(Register src, const MemOperand& dst, Condition cond = al); |
| 1033 | void ldrh(Register dst, const MemOperand& src, Condition cond = al); |
| 1034 | void strh(Register src, const MemOperand& dst, Condition cond = al); |
| 1035 | void ldrsb(Register dst, const MemOperand& src, Condition cond = al); |
| 1036 | void ldrsh(Register dst, const MemOperand& src, Condition cond = al); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1037 | void ldrd(Register dst1, |
| 1038 | Register dst2, |
| 1039 | const MemOperand& src, Condition cond = al); |
| 1040 | void strd(Register src1, |
| 1041 | Register src2, |
| 1042 | const MemOperand& dst, Condition cond = al); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1043 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1044 | // Preload instructions |
| 1045 | void pld(const MemOperand& address); |
| 1046 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1047 | // Load/Store multiple instructions |
| 1048 | void ldm(BlockAddrMode am, Register base, RegList dst, Condition cond = al); |
| 1049 | void stm(BlockAddrMode am, Register base, RegList src, Condition cond = al); |
| 1050 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1051 | // Exception-generating instructions and debugging support |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 1052 | void stop(const char* msg, |
| 1053 | Condition cond = al, |
| 1054 | int32_t code = kDefaultStopCode); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1055 | |
| 1056 | void bkpt(uint32_t imm16); // v5 and above |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 1057 | void svc(uint32_t imm24, Condition cond = al); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1058 | |
| 1059 | // Coprocessor instructions |
| 1060 | |
| 1061 | void cdp(Coprocessor coproc, int opcode_1, |
| 1062 | CRegister crd, CRegister crn, CRegister crm, |
| 1063 | int opcode_2, Condition cond = al); |
| 1064 | |
| 1065 | void cdp2(Coprocessor coproc, int opcode_1, |
| 1066 | CRegister crd, CRegister crn, CRegister crm, |
| 1067 | int opcode_2); // v5 and above |
| 1068 | |
| 1069 | void mcr(Coprocessor coproc, int opcode_1, |
| 1070 | Register rd, CRegister crn, CRegister crm, |
| 1071 | int opcode_2 = 0, Condition cond = al); |
| 1072 | |
| 1073 | void mcr2(Coprocessor coproc, int opcode_1, |
| 1074 | Register rd, CRegister crn, CRegister crm, |
| 1075 | int opcode_2 = 0); // v5 and above |
| 1076 | |
| 1077 | void mrc(Coprocessor coproc, int opcode_1, |
| 1078 | Register rd, CRegister crn, CRegister crm, |
| 1079 | int opcode_2 = 0, Condition cond = al); |
| 1080 | |
| 1081 | void mrc2(Coprocessor coproc, int opcode_1, |
| 1082 | Register rd, CRegister crn, CRegister crm, |
| 1083 | int opcode_2 = 0); // v5 and above |
| 1084 | |
| 1085 | void ldc(Coprocessor coproc, CRegister crd, const MemOperand& src, |
| 1086 | LFlag l = Short, Condition cond = al); |
| 1087 | void ldc(Coprocessor coproc, CRegister crd, Register base, int option, |
| 1088 | LFlag l = Short, Condition cond = al); |
| 1089 | |
| 1090 | void ldc2(Coprocessor coproc, CRegister crd, const MemOperand& src, |
| 1091 | LFlag l = Short); // v5 and above |
| 1092 | void ldc2(Coprocessor coproc, CRegister crd, Register base, int option, |
| 1093 | LFlag l = Short); // v5 and above |
| 1094 | |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 1095 | // Support for VFP. |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 1096 | // All these APIs support S0 to S31 and D0 to D31. |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 1097 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1098 | void vldr(const DwVfpRegister dst, |
| 1099 | const Register base, |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1100 | int offset, |
| 1101 | const Condition cond = al); |
| 1102 | void vldr(const DwVfpRegister dst, |
| 1103 | const MemOperand& src, |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1104 | const Condition cond = al); |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1105 | |
| 1106 | void vldr(const SwVfpRegister dst, |
| 1107 | const Register base, |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1108 | int offset, |
| 1109 | const Condition cond = al); |
| 1110 | void vldr(const SwVfpRegister dst, |
| 1111 | const MemOperand& src, |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1112 | const Condition cond = al); |
| 1113 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1114 | void vstr(const DwVfpRegister src, |
| 1115 | const Register base, |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1116 | int offset, |
| 1117 | const Condition cond = al); |
| 1118 | void vstr(const DwVfpRegister src, |
| 1119 | const MemOperand& dst, |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1120 | const Condition cond = al); |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 1121 | |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 1122 | void vstr(const SwVfpRegister src, |
| 1123 | const Register base, |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1124 | int offset, |
| 1125 | const Condition cond = al); |
| 1126 | void vstr(const SwVfpRegister src, |
| 1127 | const MemOperand& dst, |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 1128 | const Condition cond = al); |
| 1129 | |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 1130 | void vldm(BlockAddrMode am, |
| 1131 | Register base, |
| 1132 | DwVfpRegister first, |
| 1133 | DwVfpRegister last, |
| 1134 | Condition cond = al); |
| 1135 | |
| 1136 | void vstm(BlockAddrMode am, |
| 1137 | Register base, |
| 1138 | DwVfpRegister first, |
| 1139 | DwVfpRegister last, |
| 1140 | Condition cond = al); |
| 1141 | |
| 1142 | void vldm(BlockAddrMode am, |
| 1143 | Register base, |
| 1144 | SwVfpRegister first, |
| 1145 | SwVfpRegister last, |
| 1146 | Condition cond = al); |
| 1147 | |
| 1148 | void vstm(BlockAddrMode am, |
| 1149 | Register base, |
| 1150 | SwVfpRegister first, |
| 1151 | SwVfpRegister last, |
| 1152 | Condition cond = al); |
| 1153 | |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 1154 | void vmov(const DwVfpRegister dst, |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 1155 | double imm, |
mstarzinger@chromium.org | 71fc346 | 2013-02-27 09:34:27 +0000 | [diff] [blame] | 1156 | const Register scratch = no_reg); |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 1157 | void vmov(const SwVfpRegister dst, |
| 1158 | const SwVfpRegister src, |
| 1159 | const Condition cond = al); |
| 1160 | void vmov(const DwVfpRegister dst, |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 1161 | const DwVfpRegister src, |
| 1162 | const Condition cond = al); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 1163 | void vmov(const DwVfpRegister dst, |
ulan@chromium.org | 6ba1fd0 | 2013-02-14 14:56:11 +0000 | [diff] [blame] | 1164 | const VmovIndex index, |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 1165 | const Register src, |
| 1166 | const Condition cond = al); |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 1167 | void vmov(const Register dst, |
| 1168 | const VmovIndex index, |
| 1169 | const DwVfpRegister src, |
| 1170 | const Condition cond = al); |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 1171 | void vmov(const DwVfpRegister dst, |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 1172 | const Register src1, |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 1173 | const Register src2, |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 1174 | const Condition cond = al); |
| 1175 | void vmov(const Register dst1, |
| 1176 | const Register dst2, |
| 1177 | const DwVfpRegister src, |
| 1178 | const Condition cond = al); |
| 1179 | void vmov(const SwVfpRegister dst, |
| 1180 | const Register src, |
| 1181 | const Condition cond = al); |
| 1182 | void vmov(const Register dst, |
| 1183 | const SwVfpRegister src, |
| 1184 | const Condition cond = al); |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1185 | void vcvt_f64_s32(const DwVfpRegister dst, |
| 1186 | const SwVfpRegister src, |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1187 | VFPConversionMode mode = kDefaultRoundToZero, |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1188 | const Condition cond = al); |
| 1189 | void vcvt_f32_s32(const SwVfpRegister dst, |
| 1190 | const SwVfpRegister src, |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1191 | VFPConversionMode mode = kDefaultRoundToZero, |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1192 | const Condition cond = al); |
| 1193 | void vcvt_f64_u32(const DwVfpRegister dst, |
| 1194 | const SwVfpRegister src, |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1195 | VFPConversionMode mode = kDefaultRoundToZero, |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1196 | const Condition cond = al); |
| 1197 | void vcvt_s32_f64(const SwVfpRegister dst, |
| 1198 | const DwVfpRegister src, |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1199 | VFPConversionMode mode = kDefaultRoundToZero, |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1200 | const Condition cond = al); |
| 1201 | void vcvt_u32_f64(const SwVfpRegister dst, |
| 1202 | const DwVfpRegister src, |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1203 | VFPConversionMode mode = kDefaultRoundToZero, |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1204 | const Condition cond = al); |
| 1205 | void vcvt_f64_f32(const DwVfpRegister dst, |
| 1206 | const SwVfpRegister src, |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1207 | VFPConversionMode mode = kDefaultRoundToZero, |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1208 | const Condition cond = al); |
| 1209 | void vcvt_f32_f64(const SwVfpRegister dst, |
| 1210 | const DwVfpRegister src, |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1211 | VFPConversionMode mode = kDefaultRoundToZero, |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1212 | const Condition cond = al); |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 1213 | void vcvt_f64_s32(const DwVfpRegister dst, |
| 1214 | int fraction_bits, |
| 1215 | const Condition cond = al); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 1216 | |
ricow@chromium.org | badaffc | 2011-03-17 12:15:27 +0000 | [diff] [blame] | 1217 | void vneg(const DwVfpRegister dst, |
| 1218 | const DwVfpRegister src, |
| 1219 | const Condition cond = al); |
whesse@chromium.org | 7a392b3 | 2011-01-31 11:30:36 +0000 | [diff] [blame] | 1220 | void vabs(const DwVfpRegister dst, |
| 1221 | const DwVfpRegister src, |
| 1222 | const Condition cond = al); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 1223 | void vadd(const DwVfpRegister dst, |
| 1224 | const DwVfpRegister src1, |
| 1225 | const DwVfpRegister src2, |
| 1226 | const Condition cond = al); |
| 1227 | void vsub(const DwVfpRegister dst, |
| 1228 | const DwVfpRegister src1, |
| 1229 | const DwVfpRegister src2, |
| 1230 | const Condition cond = al); |
| 1231 | void vmul(const DwVfpRegister dst, |
| 1232 | const DwVfpRegister src1, |
| 1233 | const DwVfpRegister src2, |
| 1234 | const Condition cond = al); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1235 | void vmla(const DwVfpRegister dst, |
| 1236 | const DwVfpRegister src1, |
| 1237 | const DwVfpRegister src2, |
| 1238 | const Condition cond = al); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1239 | void vmls(const DwVfpRegister dst, |
| 1240 | const DwVfpRegister src1, |
| 1241 | const DwVfpRegister src2, |
| 1242 | const Condition cond = al); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 1243 | void vdiv(const DwVfpRegister dst, |
| 1244 | const DwVfpRegister src1, |
| 1245 | const DwVfpRegister src2, |
| 1246 | const Condition cond = al); |
| 1247 | void vcmp(const DwVfpRegister src1, |
| 1248 | const DwVfpRegister src2, |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 1249 | const Condition cond = al); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 1250 | void vcmp(const DwVfpRegister src1, |
| 1251 | const double src2, |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 1252 | const Condition cond = al); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 1253 | void vmrs(const Register dst, |
| 1254 | const Condition cond = al); |
ager@chromium.org | 01fe7df | 2010-11-10 11:59:11 +0000 | [diff] [blame] | 1255 | void vmsr(const Register dst, |
| 1256 | const Condition cond = al); |
lrn@chromium.org | 32d961d | 2010-06-30 09:09:34 +0000 | [diff] [blame] | 1257 | void vsqrt(const DwVfpRegister dst, |
| 1258 | const DwVfpRegister src, |
| 1259 | const Condition cond = al); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 1260 | |
danno@chromium.org | 169691d | 2013-07-15 08:01:13 +0000 | [diff] [blame] | 1261 | // Support for NEON. |
| 1262 | // All these APIs support D0 to D31 and Q0 to Q15. |
| 1263 | |
| 1264 | void vld1(NeonSize size, |
| 1265 | const NeonListOperand& dst, |
| 1266 | const NeonMemOperand& src); |
| 1267 | void vst1(NeonSize size, |
| 1268 | const NeonListOperand& src, |
| 1269 | const NeonMemOperand& dst); |
| 1270 | void vmovl(NeonDataType dt, QwNeonRegister dst, DwVfpRegister src); |
| 1271 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1272 | // Pseudo instructions |
ager@chromium.org | beb2571 | 2010-11-29 08:02:25 +0000 | [diff] [blame] | 1273 | |
| 1274 | // Different nop operations are used by the code generator to detect certain |
| 1275 | // states of the generated code. |
| 1276 | enum NopMarkerTypes { |
| 1277 | NON_MARKING_NOP = 0, |
| 1278 | DEBUG_BREAK_NOP, |
| 1279 | // IC markers. |
| 1280 | PROPERTY_ACCESS_INLINED, |
| 1281 | PROPERTY_ACCESS_INLINED_CONTEXT, |
| 1282 | PROPERTY_ACCESS_INLINED_CONTEXT_DONT_DELETE, |
| 1283 | // Helper values. |
| 1284 | LAST_CODE_MARKER, |
| 1285 | FIRST_IC_MARKER = PROPERTY_ACCESS_INLINED |
| 1286 | }; |
| 1287 | |
| 1288 | void nop(int type = 0); // 0 is the default non-marking type. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1289 | |
kasperl@chromium.org | b3284ad | 2009-05-18 06:12:45 +0000 | [diff] [blame] | 1290 | void push(Register src, Condition cond = al) { |
| 1291 | str(src, MemOperand(sp, 4, NegPreIndex), cond); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1292 | } |
| 1293 | |
sgjesse@chromium.org | c514574 | 2009-10-07 09:00:33 +0000 | [diff] [blame] | 1294 | void pop(Register dst, Condition cond = al) { |
| 1295 | ldr(dst, MemOperand(sp, 4, PostIndex), cond); |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 1296 | } |
| 1297 | |
| 1298 | void pop() { |
| 1299 | add(sp, sp, Operand(kPointerSize)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1300 | } |
| 1301 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1302 | // Jump unconditionally to given label. |
| 1303 | void jmp(Label* L) { b(L, al); } |
| 1304 | |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 1305 | static bool use_immediate_embedded_pointer_loads( |
| 1306 | const Assembler* assembler) { |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 1307 | return CpuFeatures::IsSupported(MOVW_MOVT_IMMEDIATE_LOADS) && |
| 1308 | (assembler == NULL || !assembler->predictable_code_size()); |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 1309 | } |
| 1310 | |
ager@chromium.org | 4af710e | 2009-09-15 12:20:11 +0000 | [diff] [blame] | 1311 | // Check the code size generated from label to here. |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1312 | int SizeOfCodeGeneratedSince(Label* label) { |
| 1313 | return pc_offset() - label->pos(); |
| 1314 | } |
| 1315 | |
| 1316 | // Check the number of instructions generated from label to here. |
| 1317 | int InstructionsGeneratedSince(Label* label) { |
| 1318 | return SizeOfCodeGeneratedSince(label) / kInstrSize; |
ager@chromium.org | 4af710e | 2009-09-15 12:20:11 +0000 | [diff] [blame] | 1319 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1320 | |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 1321 | // Check whether an immediate fits an addressing mode 1 instruction. |
| 1322 | bool ImmediateFitsAddrMode1Instruction(int32_t imm32); |
| 1323 | |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 1324 | // Class for scoping postponing the constant pool generation. |
| 1325 | class BlockConstPoolScope { |
| 1326 | public: |
| 1327 | explicit BlockConstPoolScope(Assembler* assem) : assem_(assem) { |
| 1328 | assem_->StartBlockConstPool(); |
| 1329 | } |
| 1330 | ~BlockConstPoolScope() { |
| 1331 | assem_->EndBlockConstPool(); |
| 1332 | } |
| 1333 | |
| 1334 | private: |
| 1335 | Assembler* assem_; |
| 1336 | |
| 1337 | DISALLOW_IMPLICIT_CONSTRUCTORS(BlockConstPoolScope); |
| 1338 | }; |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 1339 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1340 | // Debugging |
| 1341 | |
ager@chromium.org | 4af710e | 2009-09-15 12:20:11 +0000 | [diff] [blame] | 1342 | // Mark address of the ExitJSFrame code. |
| 1343 | void RecordJSReturn(); |
| 1344 | |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 1345 | // Mark address of a debug break slot. |
| 1346 | void RecordDebugBreakSlot(); |
| 1347 | |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1348 | // Record the AST id of the CallIC being compiled, so that it can be placed |
| 1349 | // in the relocation information. |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1350 | void SetRecordedAstId(TypeFeedbackId ast_id) { |
| 1351 | ASSERT(recorded_ast_id_.IsNone()); |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 1352 | recorded_ast_id_ = ast_id; |
| 1353 | } |
| 1354 | |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1355 | TypeFeedbackId RecordedAstId() { |
| 1356 | ASSERT(!recorded_ast_id_.IsNone()); |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 1357 | return recorded_ast_id_; |
| 1358 | } |
| 1359 | |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1360 | void ClearRecordedAstId() { recorded_ast_id_ = TypeFeedbackId::None(); } |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1361 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1362 | // Record a comment relocation entry that can be used by a disassembler. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1363 | // Use --code-comments to enable. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1364 | void RecordComment(const char* msg); |
| 1365 | |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 1366 | // Record the emission of a constant pool. |
| 1367 | // |
| 1368 | // The emission of constant pool depends on the size of the code generated and |
| 1369 | // the number of RelocInfo recorded. |
| 1370 | // The Debug mechanism needs to map code offsets between two versions of a |
| 1371 | // function, compiled with and without debugger support (see for example |
| 1372 | // Debug::PrepareForBreakPoints()). |
| 1373 | // Compiling functions with debugger support generates additional code |
| 1374 | // (Debug::GenerateSlot()). This may affect the emission of the constant |
| 1375 | // pools and cause the version of the code with debugger support to have |
| 1376 | // constant pools generated in different places. |
| 1377 | // Recording the position and size of emitted constant pools allows to |
| 1378 | // correctly compute the offset mappings between the different versions of a |
| 1379 | // function in all situations. |
| 1380 | // |
| 1381 | // The parameter indicates the size of the constant pool (in bytes), including |
| 1382 | // the marker and branch over the data. |
| 1383 | void RecordConstPool(int size); |
| 1384 | |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 1385 | // Writes a single byte or word of data in the code stream. Used |
| 1386 | // for inline tables, e.g., jump-tables. The constant pool should be |
| 1387 | // emitted before any use of db and dd to ensure that constant pools |
| 1388 | // are not emitted as part of the tables generated. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1389 | void db(uint8_t data); |
| 1390 | void dd(uint32_t data); |
| 1391 | |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 1392 | // Emits the address of the code stub's first instruction. |
| 1393 | void emit_code_stub_address(Code* stub); |
| 1394 | |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 1395 | PositionsRecorder* positions_recorder() { return &positions_recorder_; } |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 1396 | |
| 1397 | // Read/patch instructions |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1398 | Instr instr_at(int pos) { return *reinterpret_cast<Instr*>(buffer_ + pos); } |
| 1399 | void instr_at_put(int pos, Instr instr) { |
| 1400 | *reinterpret_cast<Instr*>(buffer_ + pos) = instr; |
| 1401 | } |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 1402 | static Instr instr_at(byte* pc) { return *reinterpret_cast<Instr*>(pc); } |
| 1403 | static void instr_at_put(byte* pc, Instr instr) { |
| 1404 | *reinterpret_cast<Instr*>(pc) = instr; |
| 1405 | } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1406 | static Condition GetCondition(Instr instr); |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 1407 | static bool IsBranch(Instr instr); |
| 1408 | static int GetBranchOffset(Instr instr); |
| 1409 | static bool IsLdrRegisterImmediate(Instr instr); |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 1410 | static bool IsVldrDRegisterImmediate(Instr instr); |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 1411 | static int GetLdrRegisterImmediateOffset(Instr instr); |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 1412 | static int GetVldrDRegisterImmediateOffset(Instr instr); |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 1413 | static Instr SetLdrRegisterImmediateOffset(Instr instr, int offset); |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 1414 | static Instr SetVldrDRegisterImmediateOffset(Instr instr, int offset); |
whesse@chromium.org | ba5a61b | 2010-07-26 11:44:40 +0000 | [diff] [blame] | 1415 | static bool IsStrRegisterImmediate(Instr instr); |
| 1416 | static Instr SetStrRegisterImmediateOffset(Instr instr, int offset); |
| 1417 | static bool IsAddRegisterImmediate(Instr instr); |
| 1418 | static Instr SetAddRegisterImmediateOffset(Instr instr, int offset); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 1419 | static Register GetRd(Instr instr); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1420 | static Register GetRn(Instr instr); |
| 1421 | static Register GetRm(Instr instr); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 1422 | static bool IsPush(Instr instr); |
| 1423 | static bool IsPop(Instr instr); |
| 1424 | static bool IsStrRegFpOffset(Instr instr); |
| 1425 | static bool IsLdrRegFpOffset(Instr instr); |
| 1426 | static bool IsStrRegFpNegOffset(Instr instr); |
| 1427 | static bool IsLdrRegFpNegOffset(Instr instr); |
ager@chromium.org | beb2571 | 2010-11-29 08:02:25 +0000 | [diff] [blame] | 1428 | static bool IsLdrPcImmediateOffset(Instr instr); |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 1429 | static bool IsVldrDPcImmediateOffset(Instr instr); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1430 | static bool IsTstImmediate(Instr instr); |
| 1431 | static bool IsCmpRegister(Instr instr); |
| 1432 | static bool IsCmpImmediate(Instr instr); |
| 1433 | static Register GetCmpImmediateRegister(Instr instr); |
| 1434 | static int GetCmpImmediateRawImmediate(Instr instr); |
ager@chromium.org | beb2571 | 2010-11-29 08:02:25 +0000 | [diff] [blame] | 1435 | static bool IsNop(Instr instr, int type = NON_MARKING_NOP); |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 1436 | static bool IsMovT(Instr instr); |
| 1437 | static bool IsMovW(Instr instr); |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 1438 | |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1439 | // Constants in pools are accessed via pc relative addressing, which can |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 1440 | // reach +/-4KB for integer PC-relative loads and +/-1KB for floating-point |
| 1441 | // PC-relative loads, thereby defining a maximum distance between the |
| 1442 | // instruction and the accessed constant. |
| 1443 | static const int kMaxDistToIntPool = 4*KB; |
| 1444 | static const int kMaxDistToFPPool = 1*KB; |
| 1445 | // All relocations could be integer, it therefore acts as the limit. |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame^] | 1446 | static const int kMaxNumPending32RelocInfo = kMaxDistToIntPool/kInstrSize; |
| 1447 | static const int kMaxNumPending64RelocInfo = kMaxDistToFPPool/kInstrSize; |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1448 | |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1449 | // Postpone the generation of the constant pool for the specified number of |
| 1450 | // instructions. |
| 1451 | void BlockConstPoolFor(int instructions); |
| 1452 | |
| 1453 | // Check if is time to emit a constant pool. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1454 | void CheckConstPool(bool force_emit, bool require_jump); |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 1455 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1456 | protected: |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1457 | // Relocation for a type-recording IC has the AST id added to it. This |
| 1458 | // member variable is a way to pass the information from the call site to |
| 1459 | // the relocation info. |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1460 | TypeFeedbackId recorded_ast_id_; |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1461 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1462 | int buffer_space() const { return reloc_info_writer.pos() - pc_; } |
| 1463 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1464 | // Decode branch instruction at pos and return branch target pos |
| 1465 | int target_at(int pos); |
| 1466 | |
| 1467 | // Patch branch instruction at pos to branch to given branch target pos |
| 1468 | void target_at_put(int pos, int target_pos); |
| 1469 | |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1470 | // Prevent contant pool emission until EndBlockConstPool is called. |
| 1471 | // Call to this function can be nested but must be followed by an equal |
| 1472 | // number of call to EndBlockConstpool. |
| 1473 | void StartBlockConstPool() { |
| 1474 | if (const_pool_blocked_nesting_++ == 0) { |
| 1475 | // Prevent constant pool checks happening by setting the next check to |
| 1476 | // the biggest possible offset. |
| 1477 | next_buffer_check_ = kMaxInt; |
| 1478 | } |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 1479 | } |
| 1480 | |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1481 | // Resume constant pool emission. Need to be called as many time as |
| 1482 | // StartBlockConstPool to have an effect. |
lrn@chromium.org | c34f580 | 2010-04-28 12:53:43 +0000 | [diff] [blame] | 1483 | void EndBlockConstPool() { |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1484 | if (--const_pool_blocked_nesting_ == 0) { |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame^] | 1485 | #ifdef DEBUG |
| 1486 | // Max pool start (if we need a jump and an alignment). |
| 1487 | int start = pc_offset() + kInstrSize + 2 * kPointerSize; |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1488 | // Check the constant pool hasn't been blocked for too long. |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame^] | 1489 | ASSERT((num_pending_32_bit_reloc_info_ == 0) || |
| 1490 | (start + num_pending_64_bit_reloc_info_ * kDoubleSize < |
| 1491 | (first_const_pool_32_use_ + kMaxDistToIntPool))); |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 1492 | ASSERT((num_pending_64_bit_reloc_info_ == 0) || |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame^] | 1493 | (start < (first_const_pool_64_use_ + kMaxDistToFPPool))); |
| 1494 | #endif |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1495 | // Two cases: |
| 1496 | // * no_const_pool_before_ >= next_buffer_check_ and the emission is |
| 1497 | // still blocked |
| 1498 | // * no_const_pool_before_ < next_buffer_check_ and the next emit will |
| 1499 | // trigger a check. |
| 1500 | next_buffer_check_ = no_const_pool_before_; |
| 1501 | } |
lrn@chromium.org | c34f580 | 2010-04-28 12:53:43 +0000 | [diff] [blame] | 1502 | } |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1503 | |
| 1504 | bool is_const_pool_blocked() const { |
| 1505 | return (const_pool_blocked_nesting_ > 0) || |
| 1506 | (pc_offset() < no_const_pool_before_); |
| 1507 | } |
lrn@chromium.org | c34f580 | 2010-04-28 12:53:43 +0000 | [diff] [blame] | 1508 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1509 | private: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1510 | int next_buffer_check_; // pc offset of next buffer check |
| 1511 | |
| 1512 | // Code generation |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1513 | // The relocation writer's position is at least kGap bytes below the end of |
| 1514 | // the generated instructions. This is so that multi-instruction sequences do |
| 1515 | // not have to check for overflow. The same is true for writes of large |
| 1516 | // relocation info entries. |
| 1517 | static const int kGap = 32; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1518 | |
| 1519 | // Constant pool generation |
| 1520 | // Pools are emitted in the instruction stream, preferably after unconditional |
| 1521 | // jumps or after returns from functions (in dead code locations). |
| 1522 | // If a long code sequence does not contain unconditional jumps, it is |
| 1523 | // necessary to emit the constant pool before the pool gets too far from the |
| 1524 | // location it is accessed from. In this case, we emit a jump over the emitted |
| 1525 | // constant pool. |
| 1526 | // Constants in the pool may be addresses of functions that gets relocated; |
| 1527 | // if so, a relocation info entry is associated to the constant pool entry. |
| 1528 | |
| 1529 | // Repeated checking whether the constant pool should be emitted is rather |
| 1530 | // expensive. By default we only check again once a number of instructions |
| 1531 | // has been generated. That also means that the sizing of the buffers is not |
| 1532 | // an exact science, and that we rely on some slop to not overrun buffers. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1533 | static const int kCheckPoolIntervalInst = 32; |
| 1534 | static const int kCheckPoolInterval = kCheckPoolIntervalInst * kInstrSize; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1535 | |
| 1536 | |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 1537 | // Emission of the constant pool may be blocked in some code sequences. |
| 1538 | int const_pool_blocked_nesting_; // Block emission if this is not zero. |
| 1539 | int no_const_pool_before_; // Block emission before this pc offset. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1540 | |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1541 | // Keep track of the first instruction requiring a constant pool entry |
| 1542 | // since the previous constant pool was emitted. |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame^] | 1543 | int first_const_pool_32_use_; |
| 1544 | int first_const_pool_64_use_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1545 | |
| 1546 | // Relocation info generation |
| 1547 | // Each relocation is encoded as a variable size value |
| 1548 | static const int kMaxRelocSize = RelocInfoWriter::kMaxSize; |
| 1549 | RelocInfoWriter reloc_info_writer; |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1550 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1551 | // Relocation info records are also used during code generation as temporary |
| 1552 | // containers for constants and code target addresses until they are emitted |
| 1553 | // to the constant pool. These pending relocation info records are temporarily |
| 1554 | // stored in a separate buffer until a constant pool is emitted. |
| 1555 | // If every instruction in a long sequence is accessing the pool, we need one |
| 1556 | // pending relocation entry per instruction. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1557 | |
machenbach@chromium.org | ea46888 | 2013-11-18 08:53:19 +0000 | [diff] [blame^] | 1558 | // The buffers of pending relocation info. |
| 1559 | RelocInfo pending_32_bit_reloc_info_[kMaxNumPending32RelocInfo]; |
| 1560 | RelocInfo pending_64_bit_reloc_info_[kMaxNumPending64RelocInfo]; |
| 1561 | // Number of pending reloc info entries in the 32 bits buffer. |
| 1562 | int num_pending_32_bit_reloc_info_; |
| 1563 | // Number of pending reloc info entries in the 64 bits buffer. |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 1564 | int num_pending_64_bit_reloc_info_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1565 | |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 1566 | // The bound position, before this we cannot do instruction elimination. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1567 | int last_bound_pos_; |
| 1568 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1569 | // Code emission |
| 1570 | inline void CheckBuffer(); |
| 1571 | void GrowBuffer(); |
| 1572 | inline void emit(Instr x); |
| 1573 | |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 1574 | // 32-bit immediate values |
| 1575 | void move_32_bit_immediate(Condition cond, |
| 1576 | Register rd, |
| 1577 | SBit s, |
| 1578 | const Operand& x); |
| 1579 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1580 | // Instruction generation |
| 1581 | void addrmod1(Instr instr, Register rn, Register rd, const Operand& x); |
| 1582 | void addrmod2(Instr instr, Register rd, const MemOperand& x); |
| 1583 | void addrmod3(Instr instr, Register rd, const MemOperand& x); |
| 1584 | void addrmod4(Instr instr, Register rn, RegList rl); |
| 1585 | void addrmod5(Instr instr, CRegister crd, const MemOperand& x); |
| 1586 | |
| 1587 | // Labels |
| 1588 | void print(Label* L); |
| 1589 | void bind_to(Label* L, int pos); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1590 | void next(Label* L); |
| 1591 | |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 1592 | enum UseConstantPoolMode { |
| 1593 | USE_CONSTANT_POOL, |
| 1594 | DONT_USE_CONSTANT_POOL |
| 1595 | }; |
| 1596 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1597 | // Record reloc info for current pc_ |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 1598 | void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0, |
| 1599 | UseConstantPoolMode mode = USE_CONSTANT_POOL); |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 1600 | void RecordRelocInfo(double data); |
| 1601 | void RecordRelocInfoConstantPoolEntryHelper(const RelocInfo& rinfo); |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 1602 | |
ager@chromium.org | 4af710e | 2009-09-15 12:20:11 +0000 | [diff] [blame] | 1603 | friend class RelocInfo; |
| 1604 | friend class CodePatcher; |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 1605 | friend class BlockConstPoolScope; |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 1606 | |
| 1607 | PositionsRecorder positions_recorder_; |
| 1608 | friend class PositionsRecorder; |
| 1609 | friend class EnsureSpace; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1610 | }; |
| 1611 | |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 1612 | |
| 1613 | class EnsureSpace BASE_EMBEDDED { |
| 1614 | public: |
| 1615 | explicit EnsureSpace(Assembler* assembler) { |
| 1616 | assembler->CheckBuffer(); |
| 1617 | } |
| 1618 | }; |
| 1619 | |
| 1620 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1621 | } } // namespace v8::internal |
| 1622 | |
ager@chromium.org | 5ec4892 | 2009-05-05 07:25:34 +0000 | [diff] [blame] | 1623 | #endif // V8_ARM_ASSEMBLER_ARM_H_ |