js/src/jit/arm/Architecture-arm.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * vim: set ts=8 sts=4 et sw=4 tw=99:
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef jit_arm_Architecture_arm_h
michael@0 8 #define jit_arm_Architecture_arm_h
michael@0 9
michael@0 10 #include <limits.h>
michael@0 11 #include <stdint.h>
michael@0 12
michael@0 13 #include "js/Utility.h"
michael@0 14
michael@0 15 // gcc appears to use __ARM_PCS_VFP to denote that the target is a hard-float target.
michael@0 16 #if defined(__ARM_PCS_VFP)
michael@0 17 #define JS_CODEGEN_ARM_HARDFP
michael@0 18 #endif
michael@0 19
michael@0 20 namespace js {
michael@0 21 namespace jit {
michael@0 22
michael@0 23 // In bytes: slots needed for potential memory->memory move spills.
michael@0 24 // +8 for cycles
michael@0 25 // +4 for gpr spills
michael@0 26 // +8 for double spills
michael@0 27 static const uint32_t ION_FRAME_SLACK_SIZE = 20;
michael@0 28
michael@0 29 // These offsets are specific to nunboxing, and capture offsets into the
michael@0 30 // components of a js::Value.
michael@0 31 static const int32_t NUNBOX32_TYPE_OFFSET = 4;
michael@0 32 static const int32_t NUNBOX32_PAYLOAD_OFFSET = 0;
michael@0 33
michael@0 34 static const uint32_t ShadowStackSpace = 0;
michael@0 35 ////
michael@0 36 // These offsets are related to bailouts.
michael@0 37 ////
michael@0 38
michael@0 39 // Size of each bailout table entry. On arm, this is presently
michael@0 40 // a single call (which is wrong!). the call clobbers lr.
michael@0 41 // For now, I've dealt with this by ensuring that we never allocate to lr.
michael@0 42 // it should probably be 8 bytes, a mov of an immediate into r12 (not
michael@0 43 // allocated presently, or ever) followed by a branch to the apropriate code.
michael@0 44 static const uint32_t BAILOUT_TABLE_ENTRY_SIZE = 4;
michael@0 45
michael@0 46 class Registers
michael@0 47 {
michael@0 48 public:
michael@0 49 enum RegisterID {
michael@0 50 r0 = 0,
michael@0 51 r1,
michael@0 52 r2,
michael@0 53 r3,
michael@0 54 S0 = r3,
michael@0 55 r4,
michael@0 56 r5,
michael@0 57 r6,
michael@0 58 r7,
michael@0 59 r8,
michael@0 60 S1 = r8,
michael@0 61 r9,
michael@0 62 r10,
michael@0 63 r11,
michael@0 64 r12,
michael@0 65 ip = r12,
michael@0 66 r13,
michael@0 67 sp = r13,
michael@0 68 r14,
michael@0 69 lr = r14,
michael@0 70 r15,
michael@0 71 pc = r15,
michael@0 72 invalid_reg
michael@0 73 };
michael@0 74 typedef RegisterID Code;
michael@0 75
michael@0 76 static const char *GetName(Code code) {
michael@0 77 static const char * const Names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
michael@0 78 "r8", "r9", "r10", "r11", "r12", "sp", "r14", "pc"};
michael@0 79 return Names[code];
michael@0 80 }
michael@0 81 static const char *GetName(uint32_t i) {
michael@0 82 MOZ_ASSERT(i < Total);
michael@0 83 return GetName(Code(i));
michael@0 84 }
michael@0 85
michael@0 86 static Code FromName(const char *name);
michael@0 87
michael@0 88 static const Code StackPointer = sp;
michael@0 89 static const Code Invalid = invalid_reg;
michael@0 90
michael@0 91 static const uint32_t Total = 16;
michael@0 92 static const uint32_t Allocatable = 13;
michael@0 93
michael@0 94 static const uint32_t AllMask = (1 << Total) - 1;
michael@0 95 static const uint32_t ArgRegMask = (1 << r0) | (1 << r1) | (1 << r2) | (1 << r3);
michael@0 96
michael@0 97 static const uint32_t VolatileMask =
michael@0 98 (1 << r0) |
michael@0 99 (1 << r1) |
michael@0 100 (1 << Registers::r2) |
michael@0 101 (1 << Registers::r3);
michael@0 102
michael@0 103 static const uint32_t NonVolatileMask =
michael@0 104 (1 << Registers::r4) |
michael@0 105 (1 << Registers::r5) |
michael@0 106 (1 << Registers::r6) |
michael@0 107 (1 << Registers::r7) |
michael@0 108 (1 << Registers::r8) |
michael@0 109 (1 << Registers::r9) |
michael@0 110 (1 << Registers::r10) |
michael@0 111 (1 << Registers::r11) |
michael@0 112 (1 << Registers::r12) |
michael@0 113 (1 << Registers::r14);
michael@0 114
michael@0 115 static const uint32_t WrapperMask =
michael@0 116 VolatileMask | // = arguments
michael@0 117 (1 << Registers::r4) | // = outReg
michael@0 118 (1 << Registers::r5); // = argBase
michael@0 119
michael@0 120 static const uint32_t SingleByteRegs =
michael@0 121 VolatileMask | NonVolatileMask;
michael@0 122
michael@0 123 static const uint32_t NonAllocatableMask =
michael@0 124 (1 << Registers::sp) |
michael@0 125 (1 << Registers::r12) | // r12 = ip = scratch
michael@0 126 (1 << Registers::lr) |
michael@0 127 (1 << Registers::pc);
michael@0 128
michael@0 129 // Registers that can be allocated without being saved, generally.
michael@0 130 static const uint32_t TempMask = VolatileMask & ~NonAllocatableMask;
michael@0 131
michael@0 132 // Registers returned from a JS -> JS call.
michael@0 133 static const uint32_t JSCallMask =
michael@0 134 (1 << Registers::r2) |
michael@0 135 (1 << Registers::r3);
michael@0 136
michael@0 137 // Registers returned from a JS -> C call.
michael@0 138 static const uint32_t CallMask =
michael@0 139 (1 << Registers::r0) |
michael@0 140 (1 << Registers::r1); // used for double-size returns
michael@0 141
michael@0 142 static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask;
michael@0 143 };
michael@0 144
michael@0 145 // Smallest integer type that can hold a register bitmask.
michael@0 146 typedef uint16_t PackedRegisterMask;
michael@0 147
michael@0 148 class FloatRegisters
michael@0 149 {
michael@0 150 public:
michael@0 151 enum FPRegisterID {
michael@0 152 d0,
michael@0 153 d1,
michael@0 154 d2,
michael@0 155 d3,
michael@0 156 d4,
michael@0 157 d5,
michael@0 158 d6,
michael@0 159 d7,
michael@0 160 d8,
michael@0 161 d9,
michael@0 162 d10,
michael@0 163 d11,
michael@0 164 d12,
michael@0 165 d13,
michael@0 166 d14,
michael@0 167 d15,
michael@0 168 d16,
michael@0 169 d17,
michael@0 170 d18,
michael@0 171 d19,
michael@0 172 d20,
michael@0 173 d21,
michael@0 174 d22,
michael@0 175 d23,
michael@0 176 d24,
michael@0 177 d25,
michael@0 178 d26,
michael@0 179 d27,
michael@0 180 d28,
michael@0 181 d29,
michael@0 182 d30,
michael@0 183 invalid_freg
michael@0 184 };
michael@0 185 typedef FPRegisterID Code;
michael@0 186
michael@0 187 static const char *GetName(Code code) {
michael@0 188 static const char * const Names[] = { "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
michael@0 189 "d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15"};
michael@0 190 return Names[code];
michael@0 191 }
michael@0 192 static const char *GetName(uint32_t i) {
michael@0 193 JS_ASSERT(i < Total);
michael@0 194 return GetName(Code(i));
michael@0 195 }
michael@0 196
michael@0 197 static Code FromName(const char *name);
michael@0 198
michael@0 199 static const Code Invalid = invalid_freg;
michael@0 200
michael@0 201 static const uint32_t Total = 16;
michael@0 202 static const uint32_t Allocatable = 15;
michael@0 203
michael@0 204 static const uint32_t AllMask = (1 << Total) - 1;
michael@0 205
michael@0 206 // d15 is the ScratchFloatReg.
michael@0 207 static const uint32_t NonVolatileMask =
michael@0 208 (1 << d8) |
michael@0 209 (1 << d9) |
michael@0 210 (1 << d10) |
michael@0 211 (1 << d11) |
michael@0 212 (1 << d12) |
michael@0 213 (1 << d13) |
michael@0 214 (1 << d14);
michael@0 215
michael@0 216 static const uint32_t VolatileMask = AllMask & ~NonVolatileMask;
michael@0 217
michael@0 218 static const uint32_t WrapperMask = VolatileMask;
michael@0 219
michael@0 220 // d15 is the ARM scratch float register.
michael@0 221 static const uint32_t NonAllocatableMask = (1 << d15) | (1 << invalid_freg);
michael@0 222
michael@0 223 // Registers that can be allocated without being saved, generally.
michael@0 224 static const uint32_t TempMask = VolatileMask & ~NonAllocatableMask;
michael@0 225
michael@0 226 static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask;
michael@0 227 };
michael@0 228
michael@0 229 uint32_t GetARMFlags();
michael@0 230 bool hasMOVWT();
michael@0 231 bool hasVFPv3();
michael@0 232 bool hasVFP();
michael@0 233 bool has16DP();
michael@0 234 bool hasIDIV();
michael@0 235
michael@0 236 // If the simulator is used then the ABI choice is dynamic. Otherwise the ABI is static
michael@0 237 // and useHardFpABI is inlined so that unused branches can be optimized away.
michael@0 238 #if defined(JS_ARM_SIMULATOR)
michael@0 239 bool useHardFpABI();
michael@0 240 #else
michael@0 241 static inline bool useHardFpABI()
michael@0 242 {
michael@0 243 #if defined(JS_CODEGEN_ARM_HARDFP)
michael@0 244 return true;
michael@0 245 #else
michael@0 246 return false;
michael@0 247 #endif
michael@0 248 }
michael@0 249 #endif
michael@0 250
michael@0 251 } // namespace jit
michael@0 252 } // namespace js
michael@0 253
michael@0 254 #endif /* jit_arm_Architecture_arm_h */

mercurial