Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java @ 20916:661ed7d3d10d
RegisterConfig: rename getAllocatableRegisters(PK,R[) to filterAllocatableRegisters and remove caching from implementors.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Mon, 13 Apr 2015 16:50:27 +0200 |
parents | 9b6ea36013c4 |
children | 1da7aef31a08 |
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 | |
25 import static com.oracle.graal.sparc.SPARC.*; | |
26 | |
27 import java.util.*; | |
28 | |
29 import com.oracle.graal.api.code.*; | |
30 import com.oracle.graal.api.code.CallingConvention.Type; | |
31 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
|
32 import com.oracle.graal.asm.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15011
diff
changeset
|
33 import com.oracle.graal.compiler.common.*; |
10459 | 34 import com.oracle.graal.hotspot.*; |
18443
1c92d437179b
FrameMapBuilder: move into package.
Josef Eisl <josef.eisl@jku.at>
parents:
18355
diff
changeset
|
35 import com.oracle.graal.lir.framemap.*; |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14614
diff
changeset
|
36 import com.oracle.graal.sparc.*; |
10459 | 37 |
38 public class SPARCHotSpotRegisterConfig implements RegisterConfig { | |
39 | |
40 private final Architecture architecture; | |
41 | |
42 private final Register[] allocatable; | |
43 | |
44 private final RegisterAttributes[] attributesMap; | |
45 | |
46 @Override | |
47 public Register[] getAllocatableRegisters() { | |
48 return allocatable.clone(); | |
49 } | |
50 | |
20916
661ed7d3d10d
RegisterConfig: rename getAllocatableRegisters(PK,R[) to filterAllocatableRegisters and remove caching from implementors.
Josef Eisl <josef.eisl@jku.at>
parents:
20913
diff
changeset
|
51 public Register[] filterAllocatableRegisters(PlatformKind kind, Register[] registers) { |
10459 | 52 ArrayList<Register> list = new ArrayList<>(); |
20913
9b6ea36013c4
RegisterConfig: pass registers array to getAllocatableRegisters(PlatformKind).
Josef Eisl <josef.eisl@jku.at>
parents:
20149
diff
changeset
|
53 for (Register reg : registers) { |
10459 | 54 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
|
55 // 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
|
56 // 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
|
57 if (kind == Kind.Double) { |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
58 if (reg.name.startsWith("d")) { |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
59 list.add(reg); |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
60 } |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
61 } else if (kind == Kind.Float) { |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
62 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
|
63 list.add(reg); |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
64 } |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
65 } else { |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
66 list.add(reg); |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
67 } |
10459 | 68 } |
69 } | |
70 | |
18355
9a11c4086341
size array appropriately when creating categorized register array
Doug Simon <doug.simon@oracle.com>
parents:
16995
diff
changeset
|
71 Register[] ret = list.toArray(new Register[list.size()]); |
10459 | 72 return ret; |
73 } | |
74 | |
75 @Override | |
76 public RegisterAttributes[] getAttributesMap() { | |
77 return attributesMap.clone(); | |
78 } | |
79 | |
10792 | 80 private final Register[] cpuCallerParameterRegisters = {o0, o1, o2, o3, o4, o5}; |
81 private final Register[] cpuCalleeParameterRegisters = {i0, i1, i2, i3, i4, i5}; | |
82 | |
10459 | 83 private final Register[] fpuParameterRegisters = {f0, f1, f2, f3, f4, f5, f6, f7}; |
20149
b1a8928fc4b9
[SPARC] Implement new instructions in assembler/enhance assertion error-message in MoveResolver
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19531
diff
changeset
|
84 private final Register[] fpuDoubleParameterRegisters = {d0, null, d2, null, d4, null, d6, null}; |
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
|
85 // @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
|
86 private final Register[] callerSaveRegisters = |
19531
9299e71df12a
[SPARC] Save all registers for foreign calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18630
diff
changeset
|
87 {g1, g2, g3, g4, g5, g6, g7, |
9299e71df12a
[SPARC] Save all registers for foreign calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18630
diff
changeset
|
88 o0, o1, o2, o3, o4, o5, o7, |
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
|
89 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
|
90 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
|
91 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
|
92 f24, f25, f26, f27, f28, f29, f30, f31, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
93 d32, d34, d36, d38, d40, d42, d44, d46, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
94 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
|
95 // @formatter:on |
11233 | 96 |
97 /** | |
98 * Registers saved by the callee. This lists all L and I registers which are saved in the | |
99 * register window. {@link FrameMap} uses this array to calculate the spill area size. | |
100 */ | |
101 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
|
102 |
10459 | 103 private final CalleeSaveLayout csl; |
104 | |
105 private static Register[] initAllocatable(boolean reserveForHeapBase) { | |
106 Register[] registers = null; | |
107 if (reserveForHeapBase) { | |
15345 | 108 // @formatter:off |
109 registers = new Register[]{ | |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
110 // 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
|
111 // 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
|
112 // 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
|
113 // 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
|
114 // 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
|
115 o0, o1, o2, o3, o4, o5, /*o6, o7,*/ |
10459 | 116 l0, l1, l2, l3, l4, l5, l6, l7, |
11233 | 117 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
|
118 //f0, f1, f2, f3, f4, f5, f6, f7, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
119 f8, f9, f10, f11, f12, f13, f14, f15, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
120 f16, f17, f18, f19, f20, f21, f22, f23, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
121 f24, f25, f26, f27, f28, f29, f30, f31, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
122 d32, d34, d36, d38, d40, d42, d44, d46, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
123 d48, d50, d52, d54, d56, d58, d60, d62 |
15345 | 124 }; |
125 // @formatter:on | |
10459 | 126 } else { |
15345 | 127 // @formatter:off |
128 registers = new Register[]{ | |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
129 // 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
|
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 } |
142 | |
143 return registers; | |
144 } | |
145 | |
14559
883fbd3e06e0
Make size of PlatformKind overridable by VM specific code.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
146 public SPARCHotSpotRegisterConfig(TargetDescription target, HotSpotVMConfig config) { |
15011
c8e575742f36
allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
147 this(target, initAllocatable(config.useCompressedOops)); |
c8e575742f36
allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
148 } |
c8e575742f36
allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
149 |
c8e575742f36
allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
150 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
|
151 this.architecture = target.arch; |
10459 | 152 |
14559
883fbd3e06e0
Make size of PlatformKind overridable by VM specific code.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
153 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
|
154 this.allocatable = allocatable.clone(); |
10459 | 155 attributesMap = RegisterAttributes.createMap(this, SPARC.allRegisters); |
156 } | |
157 | |
158 @Override | |
159 public Register[] getCallerSaveRegisters() { | |
10686
73122b5edf6a
SPARC: Can compile simple methods and do static calls.
twisti
parents:
10459
diff
changeset
|
160 return callerSaveRegisters; |
10459 | 161 } |
162 | |
163 @Override | |
14614
abf7cf57df5e
added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents:
14559
diff
changeset
|
164 public boolean areAllAllocatableRegistersCallerSaved() { |
abf7cf57df5e
added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents:
14559
diff
changeset
|
165 return false; |
abf7cf57df5e
added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents:
14559
diff
changeset
|
166 } |
abf7cf57df5e
added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents:
14559
diff
changeset
|
167 |
abf7cf57df5e
added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents:
14559
diff
changeset
|
168 @Override |
10459 | 169 public Register getRegisterForRole(int index) { |
170 throw new UnsupportedOperationException(); | |
171 } | |
172 | |
173 @Override | |
174 public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target, boolean stackOnly) { | |
10792 | 175 if (type == Type.JavaCall || type == Type.NativeCall) { |
176 return callingConvention(cpuCallerParameterRegisters, returnType, parameterTypes, type, target, stackOnly); | |
10459 | 177 } |
10792 | 178 if (type == Type.JavaCallee) { |
179 return callingConvention(cpuCalleeParameterRegisters, returnType, parameterTypes, type, target, stackOnly); | |
180 } | |
181 throw GraalInternalError.shouldNotReachHere(); | |
10459 | 182 } |
183 | |
184 public Register[] getCallingConventionRegisters(Type type, Kind kind) { | |
20149
b1a8928fc4b9
[SPARC] Implement new instructions in assembler/enhance assertion error-message in MoveResolver
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19531
diff
changeset
|
185 if (architecture.canStoreValue(FPUs, kind) || architecture.canStoreValue(FPUd, kind)) { |
10459 | 186 return fpuParameterRegisters; |
187 } | |
188 assert architecture.canStoreValue(CPU, kind); | |
10792 | 189 return type == Type.JavaCallee ? cpuCalleeParameterRegisters : cpuCallerParameterRegisters; |
10459 | 190 } |
191 | |
192 private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, Type type, TargetDescription target, boolean stackOnly) { | |
193 AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; | |
194 | |
195 int currentGeneral = 0; | |
196 int currentFloating = 0; | |
16637
eda09bc52ab9
[SPARC] Fix handling of overflow parameter on stack.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16634
diff
changeset
|
197 int currentStackOffset = 0; |
10459 | 198 |
199 for (int i = 0; i < parameterTypes.length; i++) { | |
200 final Kind kind = parameterTypes[i].getKind(); | |
201 | |
202 switch (kind) { | |
203 case Byte: | |
204 case Boolean: | |
205 case Short: | |
206 case Char: | |
207 case Int: | |
208 case Long: | |
209 case Object: | |
210 if (!stackOnly && currentGeneral < generalParameterRegisters.length) { | |
211 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
|
212 locations[i] = register.asValue(target.getLIRKind(kind)); |
10459 | 213 } |
214 break; | |
16321
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
215 case Double: |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
216 if (!stackOnly && currentFloating < fpuParameterRegisters.length) { |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
217 if (currentFloating % 2 != 0) { |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
218 // 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
|
219 currentFloating++; |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
220 } |
20149
b1a8928fc4b9
[SPARC] Implement new instructions in assembler/enhance assertion error-message in MoveResolver
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19531
diff
changeset
|
221 Register register = fpuDoubleParameterRegisters[currentFloating]; |
16321
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
222 currentFloating += 2; // Only every second is a double register |
16327
5f01f7c48d40
Merge with 5cdcb94a7cf7d9782107cc582f3e4b50000d5d1f
Stefan Anzinger <stefan.anzinger@gmail.com>
diff
changeset
|
223 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
|
224 } |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
225 break; |
10459 | 226 case Float: |
227 if (!stackOnly && currentFloating < fpuParameterRegisters.length) { | |
228 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
|
229 locations[i] = register.asValue(target.getLIRKind(kind)); |
10459 | 230 } |
231 break; | |
232 default: | |
233 throw GraalInternalError.shouldNotReachHere(); | |
234 } | |
235 | |
236 if (locations[i] == null) { | |
16654
8aa938ab4ac8
[SPARC] Spill slots must be 4 byte aligned
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16637
diff
changeset
|
237 // 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
|
238 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
|
239 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
|
240 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
|
241 currentStackOffset += typeSize; |
10459 | 242 } |
243 } | |
244 | |
245 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
|
246 AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind, type).asValue(target.getLIRKind(returnKind.getStackKind())); |
10459 | 247 return new CallingConvention(currentStackOffset, returnLocation, locations); |
248 } | |
249 | |
250 @Override | |
251 public Register getReturnRegister(Kind kind) { | |
10871
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
252 return getReturnRegister(kind, Type.JavaCallee); |
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
253 } |
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
254 |
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
255 private static Register getReturnRegister(Kind kind, Type type) { |
10459 | 256 switch (kind) { |
257 case Boolean: | |
258 case Byte: | |
259 case Char: | |
260 case Short: | |
261 case Int: | |
262 case Long: | |
263 case Object: | |
10871
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
264 return type == Type.JavaCallee ? i0 : o0; |
10459 | 265 case Float: |
20149
b1a8928fc4b9
[SPARC] Implement new instructions in assembler/enhance assertion error-message in MoveResolver
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19531
diff
changeset
|
266 return f0; |
10459 | 267 case Double: |
20149
b1a8928fc4b9
[SPARC] Implement new instructions in assembler/enhance assertion error-message in MoveResolver
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19531
diff
changeset
|
268 return d0; |
10459 | 269 case Void: |
270 case Illegal: | |
271 return null; | |
272 default: | |
273 throw new UnsupportedOperationException("no return register for type " + kind); | |
274 } | |
275 } | |
276 | |
277 @Override | |
278 public Register getFrameRegister() { | |
279 return sp; | |
280 } | |
281 | |
282 public CalleeSaveLayout getCalleeSaveLayout() { | |
283 return csl; | |
284 } | |
285 | |
286 @Override | |
287 public String toString() { | |
288 return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave: " + Arrays.toString(getCallerSaveRegisters()) + "%n"); | |
289 } | |
290 } |