annotate graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java @ 10854:e1fcdda22831

SPARC: can compile some stubs now but they don't work yet
author twisti
date Mon, 22 Jul 2013 22:26:49 -0700
parents 7a8d6ba83a04
children c3b09d69dfde
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.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
36
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
37 public class SPARCHotSpotRegisterConfig implements RegisterConfig {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
38
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
39 private final Architecture architecture;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
40
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
41 private final Register[] allocatable;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
42
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
43 private final HashMap<PlatformKind, Register[]> categorized = new HashMap<>();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
44
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
45 private final RegisterAttributes[] attributesMap;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
46
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
47 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
48 public Register[] getAllocatableRegisters() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
49 return allocatable.clone();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
50 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
51
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
52 public Register[] getAllocatableRegisters(PlatformKind kind) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
53 if (categorized.containsKey(kind)) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
54 return categorized.get(kind);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
55 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
56
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
57 ArrayList<Register> list = new ArrayList<>();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
58 for (Register reg : getAllocatableRegisters()) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
59 if (architecture.canStoreValue(reg.getRegisterCategory(), kind)) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
60 list.add(reg);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
61 }
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 Register[] ret = list.toArray(new Register[0]);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
65 categorized.put(kind, ret);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
66 return ret;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
67 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
68
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
69 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
70 public RegisterAttributes[] getAttributesMap() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
71 return attributesMap.clone();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
72 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
73
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
74 private final Register[] cpuCallerParameterRegisters = {o0, o1, o2, o3, o4, o5};
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
75 private final Register[] cpuCalleeParameterRegisters = {i0, i1, i2, i3, i4, i5};
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
76
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
77 private final Register[] fpuParameterRegisters = {f0, f1, f2, f3, f4, f5, f6, f7};
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
78
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10459
diff changeset
79 private final Register[] callerSaveRegisters = {g1, g3, g4, g5, o0, o1, o2, o3, o4, o5, o7};
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10459
diff changeset
80 private final Register[] calleeSaveRegisters = {l0, l1, l2, l3, l4, l5, l6, l7, i0, i1, i2, i3, i4, i5, i6, i7};
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10459
diff changeset
81
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
82 private final CalleeSaveLayout csl;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
83
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
84 private static Register findRegister(String name, Register[] all) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
85 for (Register reg : all) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
86 if (reg.name.equals(name)) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
87 return reg;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
88 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
89 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
90 throw new IllegalArgumentException("register " + name + " is not allocatable");
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
91 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
92
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
93 private static Register[] initAllocatable(boolean reserveForHeapBase) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
94 Register[] registers = null;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
95 // @formatter:off
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
96 if (reserveForHeapBase) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
97 registers = new Register[] {
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
98 // TODO this is not complete
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
99 o0, o1, o2, o3, o4, o5, /*o6,*/ o7,
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
100 l0, l1, l2, l3, l4, l5, l6, l7,
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
101 i0, i1, i2, i3, i4, i5, /*i6,*/ i7,
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
102 f0, f1, f2, f3, f4, f5, f6, f7
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
103 };
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
104 } else {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
105 registers = new Register[] {
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
106 // TODO this is not complete
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
107 o0, o1, o2, o3, o4, o5, /*o6,*/ o7,
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
108 l0, l1, l2, l3, l4, l5, l6, l7,
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
109 i0, i1, i2, i3, i4, i5, /*i6,*/ i7,
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
110 f0, f1, f2, f3, f4, f5, f6, f7
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
111 };
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
112 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
113 // @formatter:on
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
114
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
115 if (RegisterPressure.getValue() != null) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
116 String[] names = RegisterPressure.getValue().split(",");
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
117 Register[] regs = new Register[names.length];
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
118 for (int i = 0; i < names.length; i++) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
119 regs[i] = findRegister(names[i], registers);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
120 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
121 return regs;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
122 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
123
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
124 return registers;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
125 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
126
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
127 public SPARCHotSpotRegisterConfig(Architecture architecture, HotSpotVMConfig config) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
128 this.architecture = architecture;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
129
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10459
diff changeset
130 csl = new CalleeSaveLayout(architecture, -1, -1, architecture.getWordSize(), calleeSaveRegisters);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
131 allocatable = initAllocatable(config.useCompressedOops);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
132 attributesMap = RegisterAttributes.createMap(this, SPARC.allRegisters);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
133 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
134
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
135 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
136 public Register[] getCallerSaveRegisters() {
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10459
diff changeset
137 return callerSaveRegisters;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
138 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
139
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
140 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
141 public Register getRegisterForRole(int index) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
142 throw new UnsupportedOperationException();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
143 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
144
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
145 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
146 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
147 if (type == Type.JavaCall || type == Type.NativeCall) {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
148 return callingConvention(cpuCallerParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
149 }
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
150 if (type == Type.JavaCallee) {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
151 return callingConvention(cpuCalleeParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
152 }
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
153 throw GraalInternalError.shouldNotReachHere();
10459
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 public Register[] getCallingConventionRegisters(Type type, Kind kind) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
157 if (architecture.canStoreValue(FPU, kind)) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
158 return fpuParameterRegisters;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
159 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
160 assert architecture.canStoreValue(CPU, kind);
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
161 return type == Type.JavaCallee ? cpuCalleeParameterRegisters : cpuCallerParameterRegisters;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
162 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
163
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
164 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
165 AllocatableValue[] locations = new AllocatableValue[parameterTypes.length];
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
166
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
167 int currentGeneral = 0;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
168 int currentFloating = 0;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
169 int currentStackOffset = 0;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
170
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
171 for (int i = 0; i < parameterTypes.length; i++) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
172 final Kind kind = parameterTypes[i].getKind();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
173
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
174 switch (kind) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
175 case Byte:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
176 case Boolean:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
177 case Short:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
178 case Char:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
179 case Int:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
180 case Long:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
181 case Object:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
182 if (!stackOnly && currentGeneral < generalParameterRegisters.length) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
183 Register register = generalParameterRegisters[currentGeneral++];
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
184 locations[i] = register.asValue(kind);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
185 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
186 break;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
187 case Float:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
188 case Double:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
189 if (!stackOnly && currentFloating < fpuParameterRegisters.length) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
190 Register register = fpuParameterRegisters[currentFloating++];
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
191 locations[i] = register.asValue(kind);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
192 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
193 break;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
194 default:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
195 throw GraalInternalError.shouldNotReachHere();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
196 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
197
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
198 if (locations[i] == null) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
199 locations[i] = StackSlot.get(kind.getStackKind(), currentStackOffset, !type.out);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
200 currentStackOffset += Math.max(target.arch.getSizeInBytes(kind), target.wordSize);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
201 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
202 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
203
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
204 Kind returnKind = returnType == null ? Kind.Void : returnType.getKind();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
205 AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(returnKind);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
206 return new CallingConvention(currentStackOffset, returnLocation, locations);
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 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
210 public Register getReturnRegister(Kind kind) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
211 switch (kind) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
212 case Boolean:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
213 case Byte:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
214 case Char:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
215 case Short:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
216 case Int:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
217 case Long:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
218 case Object:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
219 return i0;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
220 case Float:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
221 case Double:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
222 return f0;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
223 case Void:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
224 case Illegal:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
225 return null;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
226 default:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
227 throw new UnsupportedOperationException("no return register for type " + kind);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
228 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
229 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
230
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
231 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
232 public Register getFrameRegister() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
233 return sp;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
234 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
235
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
236 public CalleeSaveLayout getCalleeSaveLayout() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
237 return csl;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
238 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
239
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
240 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
241 public String toString() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
242 return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave: " + Arrays.toString(getCallerSaveRegisters()) + "%n");
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
243 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
244 }