annotate graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java @ 14614:abf7cf57df5e

added RegisterConfig.areAllAllocatableRegistersCallerSaved()
author Doug Simon <doug.simon@oracle.com>
date Wed, 19 Mar 2014 12:42:43 +0100
parents 883fbd3e06e0
children 64dcb92ee75a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
1 /*
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
4 *
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
7 * published by the Free Software Foundation.
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
8 *
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
13 * accompanied this code).
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
14 *
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
18 *
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
21 * questions.
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
22 */
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
23 package com.oracle.graal.hotspot.sparc;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
24
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
25 import static com.oracle.graal.sparc.SPARC.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
26 import static com.oracle.graal.phases.GraalOptions.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
27
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
28 import java.util.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
29
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
30 import com.oracle.graal.sparc.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
31 import com.oracle.graal.api.code.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
32 import com.oracle.graal.api.code.CallingConvention.Type;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
33 import com.oracle.graal.api.meta.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
34 import com.oracle.graal.graph.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
35 import com.oracle.graal.hotspot.*;
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
36 import com.oracle.graal.lir.*;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
37
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
38 public class SPARCHotSpotRegisterConfig implements RegisterConfig {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
39
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
40 private final Architecture architecture;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
41
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
42 private final Register[] allocatable;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
43
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
44 private final HashMap<PlatformKind, Register[]> categorized = new HashMap<>();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
45
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
46 private final RegisterAttributes[] attributesMap;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
47
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
48 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
49 public Register[] getAllocatableRegisters() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
50 return allocatable.clone();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
51 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
52
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
53 public Register[] getAllocatableRegisters(PlatformKind kind) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
54 if (categorized.containsKey(kind)) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
55 return categorized.get(kind);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
56 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
57
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
58 ArrayList<Register> list = new ArrayList<>();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
59 for (Register reg : getAllocatableRegisters()) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
60 if (architecture.canStoreValue(reg.getRegisterCategory(), kind)) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
61 list.add(reg);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
62 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
63 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
64
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
65 Register[] ret = list.toArray(new Register[0]);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
66 categorized.put(kind, ret);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
67 return ret;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
68 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
69
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
70 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
71 public RegisterAttributes[] getAttributesMap() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
72 return attributesMap.clone();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
73 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
74
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
75 private final Register[] cpuCallerParameterRegisters = {o0, o1, o2, o3, o4, o5};
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
76 private final Register[] cpuCalleeParameterRegisters = {i0, i1, i2, i3, i4, i5};
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
77
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
78 private final Register[] fpuParameterRegisters = {f0, f1, f2, f3, f4, f5, f6, f7};
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
79
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10459
diff changeset
80 private final Register[] callerSaveRegisters = {g1, g3, g4, g5, o0, o1, o2, o3, o4, o5, o7};
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
81
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
82 /**
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
83 * Registers saved by the callee. This lists all L and I registers which are saved in the
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
84 * register window. {@link FrameMap} uses this array to calculate the spill area size.
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
85 */
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
86 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
87
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
88 private final CalleeSaveLayout csl;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
89
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
90 private static Register findRegister(String name, Register[] all) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
91 for (Register reg : all) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
92 if (reg.name.equals(name)) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
93 return reg;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
94 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
95 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
96 throw new IllegalArgumentException("register " + name + " is not allocatable");
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
97 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
98
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
99 private static Register[] initAllocatable(boolean reserveForHeapBase) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
100 Register[] registers = null;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
101 // @formatter:off
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
102 if (reserveForHeapBase) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
103 registers = new Register[] {
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
104 // TODO this is not complete
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
105 o0, o1, o2, o3, o4, o5, /*o6,*/ o7,
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
106 l0, l1, l2, l3, l4, l5, l6, l7,
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
107 i0, i1, i2, i3, i4, i5, /*i6,*/ /*i7,*/
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
108 f0, f1, f2, f3, f4, f5, f6, f7
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
109 };
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
110 } else {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
111 registers = new Register[] {
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
112 // TODO this is not complete
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
113 o0, o1, o2, o3, o4, o5, /*o6,*/ o7,
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
114 l0, l1, l2, l3, l4, l5, l6, l7,
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
115 i0, i1, i2, i3, i4, i5, /*i6,*/ /*i7,*/
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
116 f0, f1, f2, f3, f4, f5, f6, f7
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
117 };
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
118 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
119 // @formatter:on
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
120
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
121 if (RegisterPressure.getValue() != null) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
122 String[] names = RegisterPressure.getValue().split(",");
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
123 Register[] regs = new Register[names.length];
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
124 for (int i = 0; i < names.length; i++) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
125 regs[i] = findRegister(names[i], registers);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
126 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
127 return regs;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
128 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
129
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
130 return registers;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
131 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
132
14559
883fbd3e06e0 Make size of PlatformKind overridable by VM specific code.
Roland Schatz <roland.schatz@oracle.com>
parents: 14003
diff changeset
133 public SPARCHotSpotRegisterConfig(TargetDescription target, HotSpotVMConfig config) {
883fbd3e06e0 Make size of PlatformKind overridable by VM specific code.
Roland Schatz <roland.schatz@oracle.com>
parents: 14003
diff changeset
134 this.architecture = target.arch;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
135
14559
883fbd3e06e0 Make size of PlatformKind overridable by VM specific code.
Roland Schatz <roland.schatz@oracle.com>
parents: 14003
diff changeset
136 csl = new CalleeSaveLayout(target, -1, -1, target.arch.getWordSize(), calleeSaveRegisters);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
137 allocatable = initAllocatable(config.useCompressedOops);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
138 attributesMap = RegisterAttributes.createMap(this, SPARC.allRegisters);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
139 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
140
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
141 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
142 public Register[] getCallerSaveRegisters() {
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10459
diff changeset
143 return callerSaveRegisters;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
144 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
145
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
146 @Override
14614
abf7cf57df5e added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents: 14559
diff changeset
147 public boolean areAllAllocatableRegistersCallerSaved() {
abf7cf57df5e added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents: 14559
diff changeset
148 return false;
abf7cf57df5e added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents: 14559
diff changeset
149 }
abf7cf57df5e added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents: 14559
diff changeset
150
abf7cf57df5e added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents: 14559
diff changeset
151 @Override
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
152 public Register getRegisterForRole(int index) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
153 throw new UnsupportedOperationException();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
154 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
155
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
156 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
157 public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target, boolean stackOnly) {
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
158 if (type == Type.JavaCall || type == Type.NativeCall) {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
159 return callingConvention(cpuCallerParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
160 }
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
161 if (type == Type.JavaCallee) {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
162 return callingConvention(cpuCalleeParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
163 }
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
164 throw GraalInternalError.shouldNotReachHere();
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
165 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
166
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
167 public Register[] getCallingConventionRegisters(Type type, Kind kind) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
168 if (architecture.canStoreValue(FPU, kind)) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
169 return fpuParameterRegisters;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
170 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
171 assert architecture.canStoreValue(CPU, kind);
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
172 return type == Type.JavaCallee ? cpuCalleeParameterRegisters : cpuCallerParameterRegisters;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
173 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
174
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
175 private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, Type type, TargetDescription target, boolean stackOnly) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
176 AllocatableValue[] locations = new AllocatableValue[parameterTypes.length];
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
177
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
178 int currentGeneral = 0;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
179 int currentFloating = 0;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
180 int currentStackOffset = 0;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
181
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
182 for (int i = 0; i < parameterTypes.length; i++) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
183 final Kind kind = parameterTypes[i].getKind();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
184
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
185 switch (kind) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
186 case Byte:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
187 case Boolean:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
188 case Short:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
189 case Char:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
190 case Int:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
191 case Long:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
192 case Object:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
193 if (!stackOnly && currentGeneral < generalParameterRegisters.length) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
194 Register register = generalParameterRegisters[currentGeneral++];
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
195 locations[i] = register.asValue(kind);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
196 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
197 break;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
198 case Float:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
199 case Double:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
200 if (!stackOnly && currentFloating < fpuParameterRegisters.length) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
201 Register register = fpuParameterRegisters[currentFloating++];
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
202 locations[i] = register.asValue(kind);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
203 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
204 break;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
205 default:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
206 throw GraalInternalError.shouldNotReachHere();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
207 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
208
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
209 if (locations[i] == null) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
210 locations[i] = StackSlot.get(kind.getStackKind(), currentStackOffset, !type.out);
14559
883fbd3e06e0 Make size of PlatformKind overridable by VM specific code.
Roland Schatz <roland.schatz@oracle.com>
parents: 14003
diff changeset
211 currentStackOffset += Math.max(target.getSizeInBytes(kind), target.wordSize);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
212 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
213 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
214
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
215 Kind returnKind = returnType == null ? Kind.Void : returnType.getKind();
14003
0c38906450a0 Make conversion from Stamp to PlatformKind extensible by backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 11233
diff changeset
216 AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind, type).asValue(returnKind.getStackKind());
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
217 return new CallingConvention(currentStackOffset, returnLocation, locations);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
218 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
219
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
220 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
221 public Register getReturnRegister(Kind kind) {
10871
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10854
diff changeset
222 return getReturnRegister(kind, Type.JavaCallee);
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10854
diff changeset
223 }
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10854
diff changeset
224
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10854
diff changeset
225 private static Register getReturnRegister(Kind kind, Type type) {
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
226 switch (kind) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
227 case Boolean:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
228 case Byte:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
229 case Char:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
230 case Short:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
231 case Int:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
232 case Long:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
233 case Object:
10871
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10854
diff changeset
234 return type == Type.JavaCallee ? i0 : o0;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
235 case Float:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
236 case Double:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
237 return f0;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
238 case Void:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
239 case Illegal:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
240 return null;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
241 default:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
242 throw new UnsupportedOperationException("no return register for type " + kind);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
243 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
244 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
245
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
246 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
247 public Register getFrameRegister() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
248 return sp;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
249 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
250
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
251 public CalleeSaveLayout getCalleeSaveLayout() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
252 return csl;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
253 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
254
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
255 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
256 public String toString() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
257 return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave: " + Arrays.toString(getCallerSaveRegisters()) + "%n");
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
258 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
259 }