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
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 /*
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
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
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
26 import static com.oracle.graal.sparc.SPARC.*;
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.api.code.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
31 import com.oracle.graal.api.code.CallingConvention.Type;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
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
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.*;
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
38
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
39 public class SPARCHotSpotRegisterConfig implements RegisterConfig {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
40
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
41 private final Architecture architecture;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
42
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
43 private final Register[] allocatable;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
44
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
45 private final HashMap<PlatformKind, Register[]> categorized = new HashMap<>();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
46
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
47 private final RegisterAttributes[] attributesMap;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
48
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
49 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
50 public Register[] getAllocatableRegisters() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
51 return allocatable.clone();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
52 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
53
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
54 public Register[] getAllocatableRegisters(PlatformKind kind) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
55 if (categorized.containsKey(kind)) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
56 return categorized.get(kind);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
57 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
58
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
59 ArrayList<Register> list = new ArrayList<>();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
60 for (Register reg : getAllocatableRegisters()) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
75 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
76 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
77
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
78 Register[] ret = list.toArray(new Register[0]);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
79 categorized.put(kind, ret);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
80 return ret;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
81 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
82
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
83 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
84 public RegisterAttributes[] getAttributesMap() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
85 return attributesMap.clone();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
86 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
87
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
88 private final Register[] cpuCallerParameterRegisters = {o0, o1, o2, o3, o4, o5};
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
89 private final Register[] cpuCalleeParameterRegisters = {i0, i1, i2, i3, i4, i5};
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
90
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
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
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
102
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
103 /**
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
104 * 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
105 * 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
106 */
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
109 private final CalleeSaveLayout csl;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
110
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
111 private static Register findRegister(String name, Register[] all) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
112 for (Register reg : all) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
113 if (reg.name.equals(name)) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
114 return reg;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
115 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
116 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
117 throw new IllegalArgumentException("register " + name + " is not allocatable");
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
118 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
119
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
120 private static Register[] initAllocatable(boolean reserveForHeapBase) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
121 Register[] registers = null;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
122 if (reserveForHeapBase) {
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15259
diff changeset
123 // @formatter:off
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15259
diff changeset
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
131 l0, l1, l2, l3, l4, l5, l6, l7,
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
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
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15259
diff changeset
139 };
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15259
diff changeset
140 // @formatter:on
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
141 } else {
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15259
diff changeset
142 // @formatter:off
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15259
diff changeset
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
146 l0, l1, l2, l3, l4, l5, l6, l7,
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
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
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15259
diff changeset
154 };
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15259
diff changeset
155 // @formatter:on
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
156 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
157
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
158 if (RegisterPressure.getValue() != null) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
159 String[] names = RegisterPressure.getValue().split(",");
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
160 Register[] regs = new Register[names.length];
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
161 for (int i = 0; i < names.length; i++) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
162 regs[i] = findRegister(names[i], registers);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
163 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
164 return regs;
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 return registers;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
168 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
179 attributesMap = RegisterAttributes.createMap(this, SPARC.allRegisters);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
180 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
181
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
182 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
183 public Register[] getCallerSaveRegisters() {
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10459
diff changeset
184 return callerSaveRegisters;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
185 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
186
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
193 public Register getRegisterForRole(int index) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
194 throw new UnsupportedOperationException();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
195 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
196
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
197 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
198 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
199 if (type == Type.JavaCall || type == Type.NativeCall) {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
200 return callingConvention(cpuCallerParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
201 }
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
202 if (type == Type.JavaCallee) {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
203 return callingConvention(cpuCalleeParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
204 }
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
205 throw GraalInternalError.shouldNotReachHere();
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
206 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
207
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
208 public Register[] getCallingConventionRegisters(Type type, Kind kind) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
209 if (architecture.canStoreValue(FPU, kind)) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
210 return fpuParameterRegisters;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
211 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
212 assert architecture.canStoreValue(CPU, kind);
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
213 return type == Type.JavaCallee ? cpuCalleeParameterRegisters : cpuCallerParameterRegisters;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
214 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
215
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
216 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
217 AllocatableValue[] locations = new AllocatableValue[parameterTypes.length];
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
218
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
219 int currentGeneral = 0;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
222
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
223 for (int i = 0; i < parameterTypes.length; i++) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
224 final Kind kind = parameterTypes[i].getKind();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
225
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 Byte:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
228 case Boolean:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
229 case Short:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
230 case Char:
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:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
234 if (!stackOnly && currentGeneral < generalParameterRegisters.length) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
237 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
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>
parents: 16321 16094
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
250 case Float:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
251 if (!stackOnly && currentFloating < fpuParameterRegisters.length) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
254 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
255 break;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
256 default:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
257 throw GraalInternalError.shouldNotReachHere();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
258 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
259
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
266 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
267 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
268
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
271 return new CallingConvention(currentStackOffset, returnLocation, locations);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
272 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
273
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
274 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
280 switch (kind) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
281 case Boolean:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
282 case Byte:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
283 case Char:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
284 case Short:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
285 case Int:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
286 case Long:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
289 case Float:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
290 case Double:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
291 return f0;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
292 case Void:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
293 case Illegal:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
294 return null;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
295 default:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
296 throw new UnsupportedOperationException("no return register for type " + kind);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
297 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
298 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
299
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
300 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
301 public Register getFrameRegister() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
302 return sp;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
303 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
304
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
305 public CalleeSaveLayout getCalleeSaveLayout() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
306 return csl;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
307 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
308
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
309 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
310 public String toString() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
311 return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave: " + Arrays.toString(getCallerSaveRegisters()) + "%n");
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
312 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
313 }