]>
Commit | Line | Data |
---|---|---|
14957cd0 A |
1 | /* |
2 | * Copyright (C) 2011 Apple Inc. All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions | |
6 | * are met: | |
7 | * 1. Redistributions of source code must retain the above copyright | |
8 | * notice, this list of conditions and the following disclaimer. | |
9 | * 2. Redistributions in binary form must reproduce the above copyright | |
10 | * notice, this list of conditions and the following disclaimer in the | |
11 | * documentation and/or other materials provided with the distribution. | |
12 | * | |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | |
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | |
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 | */ | |
25 | ||
26 | #ifndef DFGGPRInfo_h | |
27 | #define DFGGPRInfo_h | |
28 | ||
29 | #if ENABLE(DFG_JIT) | |
30 | ||
31 | #include <assembler/MacroAssembler.h> | |
32 | #include <dfg/DFGRegisterBank.h> | |
33 | ||
34 | namespace JSC { namespace DFG { | |
35 | ||
36 | typedef MacroAssembler::RegisterID GPRReg; | |
37 | #define InvalidGPRReg ((GPRReg)-1) | |
38 | ||
39 | class GPRInfo { | |
40 | public: | |
41 | typedef GPRReg RegisterType; | |
42 | static const unsigned numberOfRegisters = 9; | |
43 | ||
44 | // These registers match the old JIT. | |
45 | static const GPRReg timeoutCheckRegister = X86Registers::r12; | |
46 | static const GPRReg callFrameRegister = X86Registers::r13; | |
47 | static const GPRReg tagTypeNumberRegister = X86Registers::r14; | |
48 | static const GPRReg tagMaskRegister = X86Registers::r15; | |
49 | // Temporary registers. | |
50 | static const GPRReg regT0 = X86Registers::eax; | |
51 | static const GPRReg regT1 = X86Registers::edx; | |
52 | static const GPRReg regT2 = X86Registers::ecx; | |
53 | static const GPRReg regT3 = X86Registers::ebx; | |
54 | static const GPRReg regT4 = X86Registers::edi; | |
55 | static const GPRReg regT5 = X86Registers::esi; | |
56 | static const GPRReg regT6 = X86Registers::r8; | |
57 | static const GPRReg regT7 = X86Registers::r9; | |
58 | static const GPRReg regT8 = X86Registers::r10; | |
59 | // These constants provide the names for the general purpose argument & return value registers. | |
60 | static const GPRReg argumentGPR0 = X86Registers::edi; // regT4 | |
61 | static const GPRReg argumentGPR1 = X86Registers::esi; // regT5 | |
62 | static const GPRReg argumentGPR2 = X86Registers::edx; // regT1 | |
63 | static const GPRReg argumentGPR3 = X86Registers::ecx; // regT2 | |
64 | static const GPRReg returnValueGPR = X86Registers::eax; // regT0 | |
65 | static const GPRReg returnValueGPR2 = X86Registers::edx; // regT1 | |
66 | ||
67 | static GPRReg toRegister(unsigned index) | |
68 | { | |
69 | ASSERT(index < numberOfRegisters); | |
70 | static const GPRReg registerForIndex[numberOfRegisters] = { regT0, regT1, regT2, regT3, regT4, regT5, regT6, regT7, regT8 }; | |
71 | return registerForIndex[index]; | |
72 | } | |
73 | ||
74 | static unsigned toIndex(GPRReg reg) | |
75 | { | |
76 | ASSERT(reg != InvalidGPRReg); | |
77 | ASSERT(reg < 16); | |
78 | static const unsigned indexForRegister[16] = { 0, 2, 1, 3, InvalidIndex, InvalidIndex, 5, 4, 6, 7, 8, InvalidIndex, InvalidIndex, InvalidIndex, InvalidIndex, InvalidIndex }; | |
79 | unsigned result = indexForRegister[reg]; | |
80 | ASSERT(result != InvalidIndex); | |
81 | return result; | |
82 | } | |
83 | ||
84 | #ifndef NDEBUG | |
85 | static const char* debugName(GPRReg reg) | |
86 | { | |
87 | ASSERT(reg != InvalidGPRReg); | |
88 | ASSERT(reg < 16); | |
89 | static const char* nameForRegister[16] = { | |
90 | "rax", "rcx", "rdx", "rbx", | |
91 | "rsp", "rbp", "rsi", "rdi", | |
92 | "r8", "r9", "r10", "r11", | |
93 | "r12", "r13", "r14", "r15" | |
94 | }; | |
95 | return nameForRegister[reg]; | |
96 | } | |
97 | #endif | |
98 | private: | |
99 | ||
100 | static const unsigned InvalidIndex = 0xffffffff; | |
101 | }; | |
102 | ||
103 | typedef RegisterBank<GPRInfo>::iterator gpr_iterator; | |
104 | ||
105 | } } // namespace JSC::DFG | |
106 | ||
107 | #endif | |
108 | #endif |