]>
git.saurik.com Git - apple/javascriptcore.git/blob - jit/RegisterSet.cpp
2 * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
27 #include "RegisterSet.h"
32 #include "MacroAssembler.h"
33 #include "JSCInlines.h"
34 #include <wtf/CommaPrinter.h>
38 RegisterSet
RegisterSet::stackRegisters()
41 MacroAssembler::stackPointerRegister
,
42 MacroAssembler::framePointerRegister
);
45 RegisterSet
RegisterSet::reservedHardwareRegisters()
48 return RegisterSet(ARM64Registers::lr
);
54 RegisterSet
RegisterSet::runtimeRegisters()
57 return RegisterSet(GPRInfo::tagTypeNumberRegister
, GPRInfo::tagMaskRegister
);
63 RegisterSet
RegisterSet::specialRegisters()
66 stackRegisters(), reservedHardwareRegisters(), runtimeRegisters());
69 RegisterSet
RegisterSet::calleeSaveRegisters()
73 result
.set(X86Registers::ebx
);
74 result
.set(X86Registers::ebp
);
75 result
.set(X86Registers::edi
);
76 result
.set(X86Registers::esi
);
78 result
.set(X86Registers::ebx
);
79 result
.set(X86Registers::ebp
);
80 result
.set(X86Registers::r12
);
81 result
.set(X86Registers::r13
);
82 result
.set(X86Registers::r14
);
83 result
.set(X86Registers::r15
);
85 result
.set(ARMRegisters::r4
);
86 result
.set(ARMRegisters::r5
);
87 result
.set(ARMRegisters::r6
);
88 result
.set(ARMRegisters::r8
);
89 result
.set(ARMRegisters::r10
);
90 result
.set(ARMRegisters::r11
);
92 // We don't include LR in the set of callee-save registers even though it technically belongs
93 // there. This is because we use this set to describe the set of registers that need to be saved
94 // beyond what you would save by the platform-agnostic "preserve return address" and "restore
95 // return address" operations in CCallHelpers.
97 ARM64Registers::RegisterID reg
= ARM64Registers::x19
;
98 reg
<= ARM64Registers::x28
;
99 reg
= static_cast<ARM64Registers::RegisterID
>(reg
+ 1))
101 result
.set(ARM64Registers::fp
);
103 ARM64Registers::FPRegisterID reg
= ARM64Registers::q8
;
104 reg
<= ARM64Registers::q15
;
105 reg
= static_cast<ARM64Registers::FPRegisterID
>(reg
+ 1))
108 UNREACHABLE_FOR_PLATFORM();
113 RegisterSet
RegisterSet::allGPRs()
116 for (MacroAssembler::RegisterID reg
= MacroAssembler::firstRegister(); reg
<= MacroAssembler::lastRegister(); reg
= static_cast<MacroAssembler::RegisterID
>(reg
+ 1))
121 RegisterSet
RegisterSet::allFPRs()
124 for (MacroAssembler::FPRegisterID reg
= MacroAssembler::firstFPRegister(); reg
<= MacroAssembler::lastFPRegister(); reg
= static_cast<MacroAssembler::FPRegisterID
>(reg
+ 1))
129 RegisterSet
RegisterSet::allRegisters()
132 result
.merge(allGPRs());
133 result
.merge(allFPRs());
137 size_t RegisterSet::numberOfSetGPRs() const
139 RegisterSet temp
= *this;
140 temp
.filter(allGPRs());
141 return temp
.numberOfSetRegisters();
144 size_t RegisterSet::numberOfSetFPRs() const
146 RegisterSet temp
= *this;
147 temp
.filter(allFPRs());
148 return temp
.numberOfSetRegisters();
151 void RegisterSet::dump(PrintStream
& out
) const
155 for (Reg reg
= Reg::first(); reg
<= Reg::last(); reg
= reg
.next()) {
157 out
.print(comma
, reg
);
164 #endif // ENABLE(JIT)