michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef jit_arm_Architecture_arm_h michael@0: #define jit_arm_Architecture_arm_h michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #include "js/Utility.h" michael@0: michael@0: // gcc appears to use __ARM_PCS_VFP to denote that the target is a hard-float target. michael@0: #if defined(__ARM_PCS_VFP) michael@0: #define JS_CODEGEN_ARM_HARDFP michael@0: #endif michael@0: michael@0: namespace js { michael@0: namespace jit { michael@0: michael@0: // In bytes: slots needed for potential memory->memory move spills. michael@0: // +8 for cycles michael@0: // +4 for gpr spills michael@0: // +8 for double spills michael@0: static const uint32_t ION_FRAME_SLACK_SIZE = 20; michael@0: michael@0: // These offsets are specific to nunboxing, and capture offsets into the michael@0: // components of a js::Value. michael@0: static const int32_t NUNBOX32_TYPE_OFFSET = 4; michael@0: static const int32_t NUNBOX32_PAYLOAD_OFFSET = 0; michael@0: michael@0: static const uint32_t ShadowStackSpace = 0; michael@0: //// michael@0: // These offsets are related to bailouts. michael@0: //// michael@0: michael@0: // Size of each bailout table entry. On arm, this is presently michael@0: // a single call (which is wrong!). the call clobbers lr. michael@0: // For now, I've dealt with this by ensuring that we never allocate to lr. michael@0: // it should probably be 8 bytes, a mov of an immediate into r12 (not michael@0: // allocated presently, or ever) followed by a branch to the apropriate code. michael@0: static const uint32_t BAILOUT_TABLE_ENTRY_SIZE = 4; michael@0: michael@0: class Registers michael@0: { michael@0: public: michael@0: enum RegisterID { michael@0: r0 = 0, michael@0: r1, michael@0: r2, michael@0: r3, michael@0: S0 = r3, michael@0: r4, michael@0: r5, michael@0: r6, michael@0: r7, michael@0: r8, michael@0: S1 = r8, michael@0: r9, michael@0: r10, michael@0: r11, michael@0: r12, michael@0: ip = r12, michael@0: r13, michael@0: sp = r13, michael@0: r14, michael@0: lr = r14, michael@0: r15, michael@0: pc = r15, michael@0: invalid_reg michael@0: }; michael@0: typedef RegisterID Code; michael@0: michael@0: static const char *GetName(Code code) { michael@0: static const char * const Names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", michael@0: "r8", "r9", "r10", "r11", "r12", "sp", "r14", "pc"}; michael@0: return Names[code]; michael@0: } michael@0: static const char *GetName(uint32_t i) { michael@0: MOZ_ASSERT(i < Total); michael@0: return GetName(Code(i)); michael@0: } michael@0: michael@0: static Code FromName(const char *name); michael@0: michael@0: static const Code StackPointer = sp; michael@0: static const Code Invalid = invalid_reg; michael@0: michael@0: static const uint32_t Total = 16; michael@0: static const uint32_t Allocatable = 13; michael@0: michael@0: static const uint32_t AllMask = (1 << Total) - 1; michael@0: static const uint32_t ArgRegMask = (1 << r0) | (1 << r1) | (1 << r2) | (1 << r3); michael@0: michael@0: static const uint32_t VolatileMask = michael@0: (1 << r0) | michael@0: (1 << r1) | michael@0: (1 << Registers::r2) | michael@0: (1 << Registers::r3); michael@0: michael@0: static const uint32_t NonVolatileMask = michael@0: (1 << Registers::r4) | michael@0: (1 << Registers::r5) | michael@0: (1 << Registers::r6) | michael@0: (1 << Registers::r7) | michael@0: (1 << Registers::r8) | michael@0: (1 << Registers::r9) | michael@0: (1 << Registers::r10) | michael@0: (1 << Registers::r11) | michael@0: (1 << Registers::r12) | michael@0: (1 << Registers::r14); michael@0: michael@0: static const uint32_t WrapperMask = michael@0: VolatileMask | // = arguments michael@0: (1 << Registers::r4) | // = outReg michael@0: (1 << Registers::r5); // = argBase michael@0: michael@0: static const uint32_t SingleByteRegs = michael@0: VolatileMask | NonVolatileMask; michael@0: michael@0: static const uint32_t NonAllocatableMask = michael@0: (1 << Registers::sp) | michael@0: (1 << Registers::r12) | // r12 = ip = scratch michael@0: (1 << Registers::lr) | michael@0: (1 << Registers::pc); michael@0: michael@0: // Registers that can be allocated without being saved, generally. michael@0: static const uint32_t TempMask = VolatileMask & ~NonAllocatableMask; michael@0: michael@0: // Registers returned from a JS -> JS call. michael@0: static const uint32_t JSCallMask = michael@0: (1 << Registers::r2) | michael@0: (1 << Registers::r3); michael@0: michael@0: // Registers returned from a JS -> C call. michael@0: static const uint32_t CallMask = michael@0: (1 << Registers::r0) | michael@0: (1 << Registers::r1); // used for double-size returns michael@0: michael@0: static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask; michael@0: }; michael@0: michael@0: // Smallest integer type that can hold a register bitmask. michael@0: typedef uint16_t PackedRegisterMask; michael@0: michael@0: class FloatRegisters michael@0: { michael@0: public: michael@0: enum FPRegisterID { michael@0: d0, michael@0: d1, michael@0: d2, michael@0: d3, michael@0: d4, michael@0: d5, michael@0: d6, michael@0: d7, michael@0: d8, michael@0: d9, michael@0: d10, michael@0: d11, michael@0: d12, michael@0: d13, michael@0: d14, michael@0: d15, michael@0: d16, michael@0: d17, michael@0: d18, michael@0: d19, michael@0: d20, michael@0: d21, michael@0: d22, michael@0: d23, michael@0: d24, michael@0: d25, michael@0: d26, michael@0: d27, michael@0: d28, michael@0: d29, michael@0: d30, michael@0: invalid_freg michael@0: }; michael@0: typedef FPRegisterID Code; michael@0: michael@0: static const char *GetName(Code code) { michael@0: static const char * const Names[] = { "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", michael@0: "d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15"}; michael@0: return Names[code]; michael@0: } michael@0: static const char *GetName(uint32_t i) { michael@0: JS_ASSERT(i < Total); michael@0: return GetName(Code(i)); michael@0: } michael@0: michael@0: static Code FromName(const char *name); michael@0: michael@0: static const Code Invalid = invalid_freg; michael@0: michael@0: static const uint32_t Total = 16; michael@0: static const uint32_t Allocatable = 15; michael@0: michael@0: static const uint32_t AllMask = (1 << Total) - 1; michael@0: michael@0: // d15 is the ScratchFloatReg. michael@0: static const uint32_t NonVolatileMask = michael@0: (1 << d8) | michael@0: (1 << d9) | michael@0: (1 << d10) | michael@0: (1 << d11) | michael@0: (1 << d12) | michael@0: (1 << d13) | michael@0: (1 << d14); michael@0: michael@0: static const uint32_t VolatileMask = AllMask & ~NonVolatileMask; michael@0: michael@0: static const uint32_t WrapperMask = VolatileMask; michael@0: michael@0: // d15 is the ARM scratch float register. michael@0: static const uint32_t NonAllocatableMask = (1 << d15) | (1 << invalid_freg); michael@0: michael@0: // Registers that can be allocated without being saved, generally. michael@0: static const uint32_t TempMask = VolatileMask & ~NonAllocatableMask; michael@0: michael@0: static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask; michael@0: }; michael@0: michael@0: uint32_t GetARMFlags(); michael@0: bool hasMOVWT(); michael@0: bool hasVFPv3(); michael@0: bool hasVFP(); michael@0: bool has16DP(); michael@0: bool hasIDIV(); michael@0: michael@0: // If the simulator is used then the ABI choice is dynamic. Otherwise the ABI is static michael@0: // and useHardFpABI is inlined so that unused branches can be optimized away. michael@0: #if defined(JS_ARM_SIMULATOR) michael@0: bool useHardFpABI(); michael@0: #else michael@0: static inline bool useHardFpABI() michael@0: { michael@0: #if defined(JS_CODEGEN_ARM_HARDFP) michael@0: return true; michael@0: #else michael@0: return false; michael@0: #endif michael@0: } michael@0: #endif michael@0: michael@0: } // namespace jit michael@0: } // namespace js michael@0: michael@0: #endif /* jit_arm_Architecture_arm_h */