Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java @ 16995:4feac7e51f42
[SPARC] Fixing float register allocation
author | Stefan Anzinger <stefan.anzinger@oracle.com> |
---|---|
date | Thu, 28 Aug 2014 15:43:44 -0700 |
parents | 4d77f938aa02 |
children | 9a11c4086341 |
rev | line source |
---|---|
10459 | 1 /* |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15345
diff
changeset
|
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
10459 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.graal.hotspot.sparc; | |
24 | |
15259
d90e5c22ba55
Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
25 import static com.oracle.graal.compiler.common.GraalOptions.*; |
10459 | 26 import static com.oracle.graal.sparc.SPARC.*; |
27 | |
28 import java.util.*; | |
29 | |
30 import com.oracle.graal.api.code.*; | |
31 import com.oracle.graal.api.code.CallingConvention.Type; | |
32 import com.oracle.graal.api.meta.*; | |
16932
4d77f938aa02
[SPARC] Exclude AMD64 tests from SPARC testrun, always use tmp register when using StrategySwitch, using registerSaver in EnterUnpackStackFrame, LeaveCurrentStackframe, adding guarantee to load offsets when doing load reg+imm13 when the imm value does not fit in 13 bit, assertions for scratch register usage (tmp/def)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16929
diff
changeset
|
33 import com.oracle.graal.asm.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15011
diff
changeset
|
34 import com.oracle.graal.compiler.common.*; |
10459 | 35 import com.oracle.graal.hotspot.*; |
11233 | 36 import com.oracle.graal.lir.*; |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14614
diff
changeset
|
37 import com.oracle.graal.sparc.*; |
10459 | 38 |
39 public class SPARCHotSpotRegisterConfig implements RegisterConfig { | |
40 | |
41 private final Architecture architecture; | |
42 | |
43 private final Register[] allocatable; | |
44 | |
45 private final HashMap<PlatformKind, Register[]> categorized = new HashMap<>(); | |
46 | |
47 private final RegisterAttributes[] attributesMap; | |
48 | |
49 @Override | |
50 public Register[] getAllocatableRegisters() { | |
51 return allocatable.clone(); | |
52 } | |
53 | |
54 public Register[] getAllocatableRegisters(PlatformKind kind) { | |
55 if (categorized.containsKey(kind)) { | |
56 return categorized.get(kind); | |
57 } | |
58 | |
59 ArrayList<Register> list = new ArrayList<>(); | |
60 for (Register reg : getAllocatableRegisters()) { | |
61 if (architecture.canStoreValue(reg.getRegisterCategory(), kind)) { | |
16321
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
62 // Special treatment for double precision |
16664
62f295bdea36
[SPARC] Fixing compare of short/char with constants, using half of single float registers as of now, otherwise it would overlap with double registers
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16654
diff
changeset
|
63 // TODO: This is wasteful it uses only half of the registers as float. |
16995
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
64 if (kind == Kind.Double) { |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
65 if (reg.name.startsWith("d")) { |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
66 list.add(reg); |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
67 } |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
68 } else if (kind == Kind.Float) { |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
69 if (reg.name.startsWith("f")) { |
16321
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
70 list.add(reg); |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
71 } |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
72 } else { |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
73 list.add(reg); |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
74 } |
10459 | 75 } |
76 } | |
77 | |
78 Register[] ret = list.toArray(new Register[0]); | |
79 categorized.put(kind, ret); | |
80 return ret; | |
81 } | |
82 | |
83 @Override | |
84 public RegisterAttributes[] getAttributesMap() { | |
85 return attributesMap.clone(); | |
86 } | |
87 | |
10792 | 88 private final Register[] cpuCallerParameterRegisters = {o0, o1, o2, o3, o4, o5}; |
89 private final Register[] cpuCalleeParameterRegisters = {i0, i1, i2, i3, i4, i5}; | |
90 | |
10459 | 91 private final Register[] fpuParameterRegisters = {f0, f1, f2, f3, f4, f5, f6, f7}; |
16929
5dc533f7565a
[SPARC] Adding registers f0...f31 to callee saved; fixing allocator test, removing direct acquisition of Unsafe from SPARCHotspotBackend
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16664
diff
changeset
|
92 // @formatter:off |
5dc533f7565a
[SPARC] Adding registers f0...f31 to callee saved; fixing allocator test, removing direct acquisition of Unsafe from SPARCHotspotBackend
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16664
diff
changeset
|
93 private final Register[] callerSaveRegisters = |
5dc533f7565a
[SPARC] Adding registers f0...f31 to callee saved; fixing allocator test, removing direct acquisition of Unsafe from SPARCHotspotBackend
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16664
diff
changeset
|
94 {g1, g3, g4, g5, o0, o1, o2, o3, o4, o5, o7, |
5dc533f7565a
[SPARC] Adding registers f0...f31 to callee saved; fixing allocator test, removing direct acquisition of Unsafe from SPARCHotspotBackend
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16664
diff
changeset
|
95 f0, f1, f2, f3, f4, f5, f6, f7, |
5dc533f7565a
[SPARC] Adding registers f0...f31 to callee saved; fixing allocator test, removing direct acquisition of Unsafe from SPARCHotspotBackend
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16664
diff
changeset
|
96 f8, f9, f10, f11, f12, f13, f14, f15, |
5dc533f7565a
[SPARC] Adding registers f0...f31 to callee saved; fixing allocator test, removing direct acquisition of Unsafe from SPARCHotspotBackend
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16664
diff
changeset
|
97 f16, f17, f18, f19, f20, f21, f22, f23, |
16995
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
98 f24, f25, f26, f27, f28, f29, f30, f31, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
99 d32, d34, d36, d38, d40, d42, d44, d46, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
100 d48, d50, d52, d54, d56, d58, d60, d62}; |
16929
5dc533f7565a
[SPARC] Adding registers f0...f31 to callee saved; fixing allocator test, removing direct acquisition of Unsafe from SPARCHotspotBackend
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16664
diff
changeset
|
101 // @formatter:on |
11233 | 102 |
103 /** | |
104 * Registers saved by the callee. This lists all L and I registers which are saved in the | |
105 * register window. {@link FrameMap} uses this array to calculate the spill area size. | |
106 */ | |
107 private final Register[] calleeSaveRegisters = {l0, l1, l2, l3, l4, l5, l6, l7, i0, i1, i2, i3, i4, i5, i6, i7}; | |
10686
73122b5edf6a
SPARC: Can compile simple methods and do static calls.
twisti
parents:
10459
diff
changeset
|
108 |
10459 | 109 private final CalleeSaveLayout csl; |
110 | |
111 private static Register findRegister(String name, Register[] all) { | |
112 for (Register reg : all) { | |
113 if (reg.name.equals(name)) { | |
114 return reg; | |
115 } | |
116 } | |
117 throw new IllegalArgumentException("register " + name + " is not allocatable"); | |
118 } | |
119 | |
120 private static Register[] initAllocatable(boolean reserveForHeapBase) { | |
121 Register[] registers = null; | |
122 if (reserveForHeapBase) { | |
15345 | 123 // @formatter:off |
124 registers = new Register[]{ | |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
125 // TODO this is not complete |
16524
a08a58d0736b
[SPARC] Emit compareAndSwap for AtomicInteger and AtomicLong, Removing o7 register from usable ones, as this register is always overwritten, when using Call or JumpAndLink instructions in SPARC, even callee does not overwrite explicitly, implicit exception is defined when doing integer division, parameter constraint narrowed to only register on Unary2Op, Fix SPARCTestOp, as it did a compare instead of an and with condition codes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16430
diff
changeset
|
126 // o7 cannot be used as register because it is always overwritten on call |
a08a58d0736b
[SPARC] Emit compareAndSwap for AtomicInteger and AtomicLong, Removing o7 register from usable ones, as this register is always overwritten, when using Call or JumpAndLink instructions in SPARC, even callee does not overwrite explicitly, implicit exception is defined when doing integer division, parameter constraint narrowed to only register on Unary2Op, Fix SPARCTestOp, as it did a compare instead of an and with condition codes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16430
diff
changeset
|
127 // and the current register handler would ignore this fact if the called |
a08a58d0736b
[SPARC] Emit compareAndSwap for AtomicInteger and AtomicLong, Removing o7 register from usable ones, as this register is always overwritten, when using Call or JumpAndLink instructions in SPARC, even callee does not overwrite explicitly, implicit exception is defined when doing integer division, parameter constraint narrowed to only register on Unary2Op, Fix SPARCTestOp, as it did a compare instead of an and with condition codes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16430
diff
changeset
|
128 // method still does not modify registers, in fact o7 is modified by the Call instruction |
a08a58d0736b
[SPARC] Emit compareAndSwap for AtomicInteger and AtomicLong, Removing o7 register from usable ones, as this register is always overwritten, when using Call or JumpAndLink instructions in SPARC, even callee does not overwrite explicitly, implicit exception is defined when doing integer division, parameter constraint narrowed to only register on Unary2Op, Fix SPARCTestOp, as it did a compare instead of an and with condition codes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16430
diff
changeset
|
129 // There would be some extra handlin necessary to be able to handle the o7 properly for local usage |
a08a58d0736b
[SPARC] Emit compareAndSwap for AtomicInteger and AtomicLong, Removing o7 register from usable ones, as this register is always overwritten, when using Call or JumpAndLink instructions in SPARC, even callee does not overwrite explicitly, implicit exception is defined when doing integer division, parameter constraint narrowed to only register on Unary2Op, Fix SPARCTestOp, as it did a compare instead of an and with condition codes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16430
diff
changeset
|
130 o0, o1, o2, o3, o4, o5, /*o6, o7,*/ |
10459 | 131 l0, l1, l2, l3, l4, l5, l6, l7, |
11233 | 132 i0, i1, i2, i3, i4, i5, /*i6,*/ /*i7,*/ |
16995
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
133 //f0, f1, f2, f3, f4, f5, f6, f7, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
134 f8, f9, f10, f11, f12, f13, f14, f15, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
135 f16, f17, f18, f19, f20, f21, f22, f23, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
136 f24, f25, f26, f27, f28, f29, f30, f31, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
137 d32, d34, d36, d38, d40, d42, d44, d46, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
138 d48, d50, d52, d54, d56, d58, d60, d62 |
15345 | 139 }; |
140 // @formatter:on | |
10459 | 141 } else { |
15345 | 142 // @formatter:off |
143 registers = new Register[]{ | |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
144 // TODO this is not complete |
16524
a08a58d0736b
[SPARC] Emit compareAndSwap for AtomicInteger and AtomicLong, Removing o7 register from usable ones, as this register is always overwritten, when using Call or JumpAndLink instructions in SPARC, even callee does not overwrite explicitly, implicit exception is defined when doing integer division, parameter constraint narrowed to only register on Unary2Op, Fix SPARCTestOp, as it did a compare instead of an and with condition codes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16430
diff
changeset
|
145 o0, o1, o2, o3, o4, o5, /*o6, o7,*/ |
10459 | 146 l0, l1, l2, l3, l4, l5, l6, l7, |
11233 | 147 i0, i1, i2, i3, i4, i5, /*i6,*/ /*i7,*/ |
16995
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
148 // f0, f1, f2, f3, f4, f5, f6, f7 |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
149 f8, f9, f10, f11, f12, f13, f14, f15, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
150 f16, f17, f18, f19, f20, f21, f22, f23, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
151 f24, f25, f26, f27, f28, f29, f30, f31, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
152 d32, d34, d36, d38, d40, d42, d44, d46, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
153 d48, d50, d52, d54, d56, d58, d60, d62 |
15345 | 154 }; |
155 // @formatter:on | |
10459 | 156 } |
157 | |
158 if (RegisterPressure.getValue() != null) { | |
159 String[] names = RegisterPressure.getValue().split(","); | |
160 Register[] regs = new Register[names.length]; | |
161 for (int i = 0; i < names.length; i++) { | |
162 regs[i] = findRegister(names[i], registers); | |
163 } | |
164 return regs; | |
165 } | |
166 | |
167 return registers; | |
168 } | |
169 | |
14559
883fbd3e06e0
Make size of PlatformKind overridable by VM specific code.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
170 public SPARCHotSpotRegisterConfig(TargetDescription target, HotSpotVMConfig config) { |
15011
c8e575742f36
allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
171 this(target, initAllocatable(config.useCompressedOops)); |
c8e575742f36
allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
172 } |
c8e575742f36
allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
173 |
c8e575742f36
allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
174 public SPARCHotSpotRegisterConfig(TargetDescription target, Register[] allocatable) { |
14559
883fbd3e06e0
Make size of PlatformKind overridable by VM specific code.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
175 this.architecture = target.arch; |
10459 | 176 |
14559
883fbd3e06e0
Make size of PlatformKind overridable by VM specific code.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
177 csl = new CalleeSaveLayout(target, -1, -1, target.arch.getWordSize(), calleeSaveRegisters); |
15011
c8e575742f36
allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
178 this.allocatable = allocatable.clone(); |
10459 | 179 attributesMap = RegisterAttributes.createMap(this, SPARC.allRegisters); |
180 } | |
181 | |
182 @Override | |
183 public Register[] getCallerSaveRegisters() { | |
10686
73122b5edf6a
SPARC: Can compile simple methods and do static calls.
twisti
parents:
10459
diff
changeset
|
184 return callerSaveRegisters; |
10459 | 185 } |
186 | |
187 @Override | |
14614
abf7cf57df5e
added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents:
14559
diff
changeset
|
188 public boolean areAllAllocatableRegistersCallerSaved() { |
abf7cf57df5e
added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents:
14559
diff
changeset
|
189 return false; |
abf7cf57df5e
added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents:
14559
diff
changeset
|
190 } |
abf7cf57df5e
added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents:
14559
diff
changeset
|
191 |
abf7cf57df5e
added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents:
14559
diff
changeset
|
192 @Override |
10459 | 193 public Register getRegisterForRole(int index) { |
194 throw new UnsupportedOperationException(); | |
195 } | |
196 | |
197 @Override | |
198 public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target, boolean stackOnly) { | |
10792 | 199 if (type == Type.JavaCall || type == Type.NativeCall) { |
200 return callingConvention(cpuCallerParameterRegisters, returnType, parameterTypes, type, target, stackOnly); | |
10459 | 201 } |
10792 | 202 if (type == Type.JavaCallee) { |
203 return callingConvention(cpuCalleeParameterRegisters, returnType, parameterTypes, type, target, stackOnly); | |
204 } | |
205 throw GraalInternalError.shouldNotReachHere(); | |
10459 | 206 } |
207 | |
208 public Register[] getCallingConventionRegisters(Type type, Kind kind) { | |
209 if (architecture.canStoreValue(FPU, kind)) { | |
210 return fpuParameterRegisters; | |
211 } | |
212 assert architecture.canStoreValue(CPU, kind); | |
10792 | 213 return type == Type.JavaCallee ? cpuCalleeParameterRegisters : cpuCallerParameterRegisters; |
10459 | 214 } |
215 | |
216 private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, Type type, TargetDescription target, boolean stackOnly) { | |
217 AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; | |
218 | |
219 int currentGeneral = 0; | |
220 int currentFloating = 0; | |
16637
eda09bc52ab9
[SPARC] Fix handling of overflow parameter on stack.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16634
diff
changeset
|
221 int currentStackOffset = 0; |
10459 | 222 |
223 for (int i = 0; i < parameterTypes.length; i++) { | |
224 final Kind kind = parameterTypes[i].getKind(); | |
225 | |
226 switch (kind) { | |
227 case Byte: | |
228 case Boolean: | |
229 case Short: | |
230 case Char: | |
231 case Int: | |
232 case Long: | |
233 case Object: | |
234 if (!stackOnly && currentGeneral < generalParameterRegisters.length) { | |
235 Register register = generalParameterRegisters[currentGeneral++]; | |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15345
diff
changeset
|
236 locations[i] = register.asValue(target.getLIRKind(kind)); |
10459 | 237 } |
238 break; | |
16321
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
239 case Double: |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
240 if (!stackOnly && currentFloating < fpuParameterRegisters.length) { |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
241 if (currentFloating % 2 != 0) { |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
242 // Make register number even to be a double reg |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
243 currentFloating++; |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
244 } |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
245 Register register = fpuParameterRegisters[currentFloating]; |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
246 currentFloating += 2; // Only every second is a double register |
16327
5f01f7c48d40
Merge with 5cdcb94a7cf7d9782107cc582f3e4b50000d5d1f
Stefan Anzinger <stefan.anzinger@gmail.com>
diff
changeset
|
247 locations[i] = register.asValue(target.getLIRKind(kind)); |
16321
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
248 } |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
249 break; |
10459 | 250 case Float: |
251 if (!stackOnly && currentFloating < fpuParameterRegisters.length) { | |
252 Register register = fpuParameterRegisters[currentFloating++]; | |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15345
diff
changeset
|
253 locations[i] = register.asValue(target.getLIRKind(kind)); |
10459 | 254 } |
255 break; | |
256 default: | |
257 throw GraalInternalError.shouldNotReachHere(); | |
258 } | |
259 | |
260 if (locations[i] == null) { | |
16654
8aa938ab4ac8
[SPARC] Spill slots must be 4 byte aligned
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16637
diff
changeset
|
261 // Stack slot is always aligned to its size in bytes but minimum wordsize |
8aa938ab4ac8
[SPARC] Spill slots must be 4 byte aligned
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16637
diff
changeset
|
262 int typeSize = SPARC.spillSlotSize(target, kind); |
16932
4d77f938aa02
[SPARC] Exclude AMD64 tests from SPARC testrun, always use tmp register when using StrategySwitch, using registerSaver in EnterUnpackStackFrame, LeaveCurrentStackframe, adding guarantee to load offsets when doing load reg+imm13 when the imm value does not fit in 13 bit, assertions for scratch register usage (tmp/def)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16929
diff
changeset
|
263 currentStackOffset = NumUtil.roundUp(currentStackOffset, typeSize); |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15345
diff
changeset
|
264 locations[i] = StackSlot.get(target.getLIRKind(kind.getStackKind()), currentStackOffset, !type.out); |
16637
eda09bc52ab9
[SPARC] Fix handling of overflow parameter on stack.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16634
diff
changeset
|
265 currentStackOffset += typeSize; |
10459 | 266 } |
267 } | |
268 | |
269 Kind returnKind = returnType == null ? Kind.Void : returnType.getKind(); | |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15345
diff
changeset
|
270 AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind, type).asValue(target.getLIRKind(returnKind.getStackKind())); |
10459 | 271 return new CallingConvention(currentStackOffset, returnLocation, locations); |
272 } | |
273 | |
274 @Override | |
275 public Register getReturnRegister(Kind kind) { | |
10871
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
276 return getReturnRegister(kind, Type.JavaCallee); |
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
277 } |
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
278 |
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
279 private static Register getReturnRegister(Kind kind, Type type) { |
10459 | 280 switch (kind) { |
281 case Boolean: | |
282 case Byte: | |
283 case Char: | |
284 case Short: | |
285 case Int: | |
286 case Long: | |
287 case Object: | |
10871
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
288 return type == Type.JavaCallee ? i0 : o0; |
10459 | 289 case Float: |
290 case Double: | |
291 return f0; | |
292 case Void: | |
293 case Illegal: | |
294 return null; | |
295 default: | |
296 throw new UnsupportedOperationException("no return register for type " + kind); | |
297 } | |
298 } | |
299 | |
300 @Override | |
301 public Register getFrameRegister() { | |
302 return sp; | |
303 } | |
304 | |
305 public CalleeSaveLayout getCalleeSaveLayout() { | |
306 return csl; | |
307 } | |
308 | |
309 @Override | |
310 public String toString() { | |
311 return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave: " + Arrays.toString(getCallerSaveRegisters()) + "%n"); | |
312 } | |
313 } |