annotate graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java @ 21543:93c50cefb9e8

moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Mon, 25 May 2015 23:30:34 +0200
parents 1da7aef31a08
children 5324104ac4f3
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
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
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
27 import java.util.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
28
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
29 import com.oracle.graal.api.code.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
30 import com.oracle.graal.api.code.CallingConvention.Type;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
31 import com.oracle.graal.api.meta.*;
16932
4d77f938aa02 [SPARC] Exclude AMD64 tests from SPARC testrun, always use tmp register when using StrategySwitch, using registerSaver in EnterUnpackStackFrame, LeaveCurrentStackframe, adding guarantee to load offsets when doing load reg+imm13 when the imm value does not fit in 13 bit, assertions for scratch register usage (tmp/def)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16929
diff changeset
32 import com.oracle.graal.asm.*;
21526
1da7aef31a08 created com.oracle.graal.hotspot.jvmci package and moved classes destined for future JVMCI module into it (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 20916
diff changeset
33 import com.oracle.graal.hotspot.jvmci.*;
18443
1c92d437179b FrameMapBuilder: move into package.
Josef Eisl <josef.eisl@jku.at>
parents: 18355
diff changeset
34 import com.oracle.graal.lir.framemap.*;
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14614
diff changeset
35 import com.oracle.graal.sparc.*;
21543
93c50cefb9e8 moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
36 import com.oracle.jvmci.common.*;
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 RegisterAttributes[] attributesMap;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
45
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
46 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
47 public Register[] getAllocatableRegisters() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
48 return allocatable.clone();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
49 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
50
20916
661ed7d3d10d RegisterConfig: rename getAllocatableRegisters(PK,R[) to filterAllocatableRegisters and remove caching from implementors.
Josef Eisl <josef.eisl@jku.at>
parents: 20913
diff changeset
51 public Register[] filterAllocatableRegisters(PlatformKind kind, Register[] registers) {
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
52 ArrayList<Register> list = new ArrayList<>();
20913
9b6ea36013c4 RegisterConfig: pass registers array to getAllocatableRegisters(PlatformKind).
Josef Eisl <josef.eisl@jku.at>
parents: 20149
diff changeset
53 for (Register reg : registers) {
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
54 if (architecture.canStoreValue(reg.getRegisterCategory(), kind)) {
16321
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15345
diff changeset
55 // Special treatment for double precision
16664
62f295bdea36 [SPARC] Fixing compare of short/char with constants, using half of single float registers as of now, otherwise it would overlap with double registers
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16654
diff changeset
56 // TODO: This is wasteful it uses only half of the registers as float.
16995
4feac7e51f42 [SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16932
diff changeset
57 if (kind == Kind.Double) {
4feac7e51f42 [SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16932
diff changeset
58 if (reg.name.startsWith("d")) {
4feac7e51f42 [SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16932
diff changeset
59 list.add(reg);
4feac7e51f42 [SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16932
diff changeset
60 }
4feac7e51f42 [SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16932
diff changeset
61 } else if (kind == Kind.Float) {
4feac7e51f42 [SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16932
diff changeset
62 if (reg.name.startsWith("f")) {
16321
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15345
diff changeset
63 list.add(reg);
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15345
diff changeset
64 }
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15345
diff changeset
65 } else {
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15345
diff changeset
66 list.add(reg);
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15345
diff changeset
67 }
10459
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
18355
9a11c4086341 size array appropriately when creating categorized register array
Doug Simon <doug.simon@oracle.com>
parents: 16995
diff changeset
71 Register[] ret = list.toArray(new Register[list.size()]);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
72 return ret;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
73 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
74
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
75 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
76 public RegisterAttributes[] getAttributesMap() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
77 return attributesMap.clone();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
78 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
79
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
80 private final Register[] cpuCallerParameterRegisters = {o0, o1, o2, o3, o4, o5};
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
81 private final Register[] cpuCalleeParameterRegisters = {i0, i1, i2, i3, i4, i5};
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
82
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
83 private final Register[] fpuParameterRegisters = {f0, f1, f2, f3, f4, f5, f6, f7};
20149
b1a8928fc4b9 [SPARC] Implement new instructions in assembler/enhance assertion error-message in MoveResolver
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19531
diff changeset
84 private final Register[] fpuDoubleParameterRegisters = {d0, null, d2, null, d4, null, d6, null};
16929
5dc533f7565a [SPARC] Adding registers f0...f31 to callee saved; fixing allocator test, removing direct acquisition of Unsafe from SPARCHotspotBackend
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
85 // @formatter:off
5dc533f7565a [SPARC] Adding registers f0...f31 to callee saved; fixing allocator test, removing direct acquisition of Unsafe from SPARCHotspotBackend
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
86 private final Register[] callerSaveRegisters =
19531
9299e71df12a [SPARC] Save all registers for foreign calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 18630
diff changeset
87 {g1, g2, g3, g4, g5, g6, g7,
9299e71df12a [SPARC] Save all registers for foreign calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 18630
diff changeset
88 o0, o1, o2, o3, o4, o5, o7,
16929
5dc533f7565a [SPARC] Adding registers f0...f31 to callee saved; fixing allocator test, removing direct acquisition of Unsafe from SPARCHotspotBackend
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
89 f0, f1, f2, f3, f4, f5, f6, f7,
5dc533f7565a [SPARC] Adding registers f0...f31 to callee saved; fixing allocator test, removing direct acquisition of Unsafe from SPARCHotspotBackend
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
90 f8, f9, f10, f11, f12, f13, f14, f15,
5dc533f7565a [SPARC] Adding registers f0...f31 to callee saved; fixing allocator test, removing direct acquisition of Unsafe from SPARCHotspotBackend
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
91 f16, f17, f18, f19, f20, f21, f22, f23,
16995
4feac7e51f42 [SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16932
diff changeset
92 f24, f25, f26, f27, f28, f29, f30, f31,
4feac7e51f42 [SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16932
diff changeset
93 d32, d34, d36, d38, d40, d42, d44, d46,
4feac7e51f42 [SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16932
diff changeset
94 d48, d50, d52, d54, d56, d58, d60, d62};
16929
5dc533f7565a [SPARC] Adding registers f0...f31 to callee saved; fixing allocator test, removing direct acquisition of Unsafe from SPARCHotspotBackend
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
95 // @formatter:on
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
96
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
97 /**
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
98 * 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
99 * 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
100 */
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
101 private final Register[] calleeSaveRegisters = {l0, l1, l2, l3, l4, l5, l6, l7, i0, i1, i2, i3, i4, i5, i6, i7};
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10459
diff changeset
102
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
103 private final CalleeSaveLayout csl;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
104
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
105 private static Register[] initAllocatable(boolean reserveForHeapBase) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
106 Register[] registers = null;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
107 if (reserveForHeapBase) {
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15259
diff changeset
108 // @formatter:off
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15259
diff changeset
109 registers = new Register[]{
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
110 // TODO this is not complete
16524
a08a58d0736b [SPARC] Emit compareAndSwap for AtomicInteger and AtomicLong, Removing o7 register from usable ones, as this register is always overwritten, when using Call or JumpAndLink instructions in SPARC, even callee does not overwrite explicitly, implicit exception is defined when doing integer division, parameter constraint narrowed to only register on Unary2Op, Fix SPARCTestOp, as it did a compare instead of an and with condition codes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16430
diff changeset
111 // o7 cannot be used as register because it is always overwritten on call
a08a58d0736b [SPARC] Emit compareAndSwap for AtomicInteger and AtomicLong, Removing o7 register from usable ones, as this register is always overwritten, when using Call or JumpAndLink instructions in SPARC, even callee does not overwrite explicitly, implicit exception is defined when doing integer division, parameter constraint narrowed to only register on Unary2Op, Fix SPARCTestOp, as it did a compare instead of an and with condition codes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16430
diff changeset
112 // and the current register handler would ignore this fact if the called
a08a58d0736b [SPARC] Emit compareAndSwap for AtomicInteger and AtomicLong, Removing o7 register from usable ones, as this register is always overwritten, when using Call or JumpAndLink instructions in SPARC, even callee does not overwrite explicitly, implicit exception is defined when doing integer division, parameter constraint narrowed to only register on Unary2Op, Fix SPARCTestOp, as it did a compare instead of an and with condition codes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16430
diff changeset
113 // method still does not modify registers, in fact o7 is modified by the Call instruction
a08a58d0736b [SPARC] Emit compareAndSwap for AtomicInteger and AtomicLong, Removing o7 register from usable ones, as this register is always overwritten, when using Call or JumpAndLink instructions in SPARC, even callee does not overwrite explicitly, implicit exception is defined when doing integer division, parameter constraint narrowed to only register on Unary2Op, Fix SPARCTestOp, as it did a compare instead of an and with condition codes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16430
diff changeset
114 // There would be some extra handlin necessary to be able to handle the o7 properly for local usage
a08a58d0736b [SPARC] Emit compareAndSwap for AtomicInteger and AtomicLong, Removing o7 register from usable ones, as this register is always overwritten, when using Call or JumpAndLink instructions in SPARC, even callee does not overwrite explicitly, implicit exception is defined when doing integer division, parameter constraint narrowed to only register on Unary2Op, Fix SPARCTestOp, as it did a compare instead of an and with condition codes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16430
diff changeset
115 o0, o1, o2, o3, o4, o5, /*o6, o7,*/
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
116 l0, l1, l2, l3, l4, l5, l6, l7,
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
117 i0, i1, i2, i3, i4, i5, /*i6,*/ /*i7,*/
16995
4feac7e51f42 [SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16932
diff changeset
118 //f0, f1, f2, f3, f4, f5, f6, f7,
4feac7e51f42 [SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16932
diff changeset
119 f8, f9, f10, f11, f12, f13, f14, f15,
4feac7e51f42 [SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16932
diff changeset
120 f16, f17, f18, f19, f20, f21, f22, f23,
4feac7e51f42 [SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16932
diff changeset
121 f24, f25, f26, f27, f28, f29, f30, f31,
4feac7e51f42 [SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16932
diff changeset
122 d32, d34, d36, d38, d40, d42, d44, d46,
4feac7e51f42 [SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 16932
diff changeset
123 d48, d50, d52, d54, d56, d58, d60, d62
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15259
diff changeset
124 };
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15259
diff changeset
125 // @formatter:on
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
126 } else {
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15259
diff changeset
127 // @formatter:off
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15259
diff changeset
128 registers = new Register[]{
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
129 // TODO this is not complete
16524
a08a58d0736b [SPARC] Emit compareAndSwap for AtomicInteger and AtomicLong, Removing o7 register from usable ones, as this register is always overwritten, when using Call or JumpAndLink instructions in SPARC, even callee does not overwrite explicitly, implicit exception is defined when doing integer division, parameter constraint narrowed to only register on Unary2Op, Fix SPARCTestOp, as it did a compare instead of an and with condition codes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16430
diff changeset
130 o0, o1, o2, o3, o4, o5, /*o6, o7,*/
10459
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 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
142
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
143 return registers;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
144 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
145
14559
883fbd3e06e0 Make size of PlatformKind overridable by VM specific code.
Roland Schatz <roland.schatz@oracle.com>
parents: 14003
diff changeset
146 public SPARCHotSpotRegisterConfig(TargetDescription target, HotSpotVMConfig config) {
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14991
diff changeset
147 this(target, initAllocatable(config.useCompressedOops));
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14991
diff changeset
148 }
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14991
diff changeset
149
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14991
diff changeset
150 public SPARCHotSpotRegisterConfig(TargetDescription target, Register[] allocatable) {
14559
883fbd3e06e0 Make size of PlatformKind overridable by VM specific code.
Roland Schatz <roland.schatz@oracle.com>
parents: 14003
diff changeset
151 this.architecture = target.arch;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
152
14559
883fbd3e06e0 Make size of PlatformKind overridable by VM specific code.
Roland Schatz <roland.schatz@oracle.com>
parents: 14003
diff changeset
153 csl = new CalleeSaveLayout(target, -1, -1, target.arch.getWordSize(), calleeSaveRegisters);
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14991
diff changeset
154 this.allocatable = allocatable.clone();
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
155 attributesMap = RegisterAttributes.createMap(this, SPARC.allRegisters);
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 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
159 public Register[] getCallerSaveRegisters() {
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10459
diff changeset
160 return callerSaveRegisters;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
161 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
162
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
163 @Override
14614
abf7cf57df5e added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents: 14559
diff changeset
164 public boolean areAllAllocatableRegistersCallerSaved() {
abf7cf57df5e added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents: 14559
diff changeset
165 return false;
abf7cf57df5e added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents: 14559
diff changeset
166 }
abf7cf57df5e added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents: 14559
diff changeset
167
abf7cf57df5e added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents: 14559
diff changeset
168 @Override
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
169 public Register getRegisterForRole(int index) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
170 throw new UnsupportedOperationException();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
171 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
172
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
173 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
174 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
175 if (type == Type.JavaCall || type == Type.NativeCall) {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
176 return callingConvention(cpuCallerParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
177 }
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
178 if (type == Type.JavaCallee) {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
179 return callingConvention(cpuCalleeParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
180 }
21543
93c50cefb9e8 moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
181 throw JVMCIError.shouldNotReachHere();
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
182 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
183
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
184 public Register[] getCallingConventionRegisters(Type type, Kind kind) {
20149
b1a8928fc4b9 [SPARC] Implement new instructions in assembler/enhance assertion error-message in MoveResolver
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19531
diff changeset
185 if (architecture.canStoreValue(FPUs, kind) || architecture.canStoreValue(FPUd, kind)) {
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
186 return fpuParameterRegisters;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
187 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
188 assert architecture.canStoreValue(CPU, kind);
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10686
diff changeset
189 return type == Type.JavaCallee ? cpuCalleeParameterRegisters : cpuCallerParameterRegisters;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
190 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
191
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
192 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
193 AllocatableValue[] locations = new AllocatableValue[parameterTypes.length];
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
194
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
195 int currentGeneral = 0;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
196 int currentFloating = 0;
16637
eda09bc52ab9 [SPARC] Fix handling of overflow parameter on stack.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16634
diff changeset
197 int currentStackOffset = 0;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
198
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
199 for (int i = 0; i < parameterTypes.length; i++) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
200 final Kind kind = parameterTypes[i].getKind();
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
201
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
202 switch (kind) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
203 case Byte:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
204 case Boolean:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
205 case Short:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
206 case Char:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
207 case Int:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
208 case Long:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
209 case Object:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
210 if (!stackOnly && currentGeneral < generalParameterRegisters.length) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
211 Register register = generalParameterRegisters[currentGeneral++];
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 15345
diff changeset
212 locations[i] = register.asValue(target.getLIRKind(kind));
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
213 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
214 break;
16321
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15345
diff changeset
215 case Double:
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15345
diff changeset
216 if (!stackOnly && currentFloating < fpuParameterRegisters.length) {
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15345
diff changeset
217 if (currentFloating % 2 != 0) {
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15345
diff changeset
218 // Make register number even to be a double reg
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15345
diff changeset
219 currentFloating++;
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15345
diff changeset
220 }
20149
b1a8928fc4b9 [SPARC] Implement new instructions in assembler/enhance assertion error-message in MoveResolver
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19531
diff changeset
221 Register register = fpuDoubleParameterRegisters[currentFloating];
16321
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15345
diff changeset
222 currentFloating += 2; // Only every second is a double register
16327
5f01f7c48d40 Merge with 5cdcb94a7cf7d9782107cc582f3e4b50000d5d1f
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16321 16094
diff changeset
223 locations[i] = register.asValue(target.getLIRKind(kind));
16321
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15345
diff changeset
224 }
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15345
diff changeset
225 break;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
226 case Float:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
227 if (!stackOnly && currentFloating < fpuParameterRegisters.length) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
228 Register register = fpuParameterRegisters[currentFloating++];
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 15345
diff changeset
229 locations[i] = register.asValue(target.getLIRKind(kind));
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
230 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
231 break;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
232 default:
21543
93c50cefb9e8 moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
233 throw JVMCIError.shouldNotReachHere();
10459
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 if (locations[i] == null) {
16654
8aa938ab4ac8 [SPARC] Spill slots must be 4 byte aligned
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16637
diff changeset
237 // Stack slot is always aligned to its size in bytes but minimum wordsize
8aa938ab4ac8 [SPARC] Spill slots must be 4 byte aligned
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16637
diff changeset
238 int typeSize = SPARC.spillSlotSize(target, kind);
16932
4d77f938aa02 [SPARC] Exclude AMD64 tests from SPARC testrun, always use tmp register when using StrategySwitch, using registerSaver in EnterUnpackStackFrame, LeaveCurrentStackframe, adding guarantee to load offsets when doing load reg+imm13 when the imm value does not fit in 13 bit, assertions for scratch register usage (tmp/def)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16929
diff changeset
239 currentStackOffset = NumUtil.roundUp(currentStackOffset, typeSize);
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 15345
diff changeset
240 locations[i] = StackSlot.get(target.getLIRKind(kind.getStackKind()), currentStackOffset, !type.out);
16637
eda09bc52ab9 [SPARC] Fix handling of overflow parameter on stack.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16634
diff changeset
241 currentStackOffset += typeSize;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
242 }
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 Kind returnKind = returnType == null ? Kind.Void : returnType.getKind();
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 15345
diff changeset
246 AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind, type).asValue(target.getLIRKind(returnKind.getStackKind()));
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
247 return new CallingConvention(currentStackOffset, returnLocation, locations);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
248 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
249
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
250 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
251 public Register getReturnRegister(Kind kind) {
10871
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10854
diff changeset
252 return getReturnRegister(kind, Type.JavaCallee);
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10854
diff changeset
253 }
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10854
diff changeset
254
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10854
diff changeset
255 private static Register getReturnRegister(Kind kind, Type type) {
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
256 switch (kind) {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
257 case Boolean:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
258 case Byte:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
259 case Char:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
260 case Short:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
261 case Int:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
262 case Long:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
263 case Object:
10871
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10854
diff changeset
264 return type == Type.JavaCallee ? i0 : o0;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
265 case Float:
20149
b1a8928fc4b9 [SPARC] Implement new instructions in assembler/enhance assertion error-message in MoveResolver
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19531
diff changeset
266 return f0;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
267 case Double:
20149
b1a8928fc4b9 [SPARC] Implement new instructions in assembler/enhance assertion error-message in MoveResolver
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19531
diff changeset
268 return d0;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
269 case Void:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
270 case Illegal:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
271 return null;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
272 default:
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
273 throw new UnsupportedOperationException("no return register for type " + kind);
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
274 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
275 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
276
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
277 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
278 public Register getFrameRegister() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
279 return sp;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
280 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
281
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
282 public CalleeSaveLayout getCalleeSaveLayout() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
283 return csl;
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
284 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
285
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
286 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
287 public String toString() {
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
288 return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave: " + Arrays.toString(getCallerSaveRegisters()) + "%n");
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
289 }
f78079947084 some basic SPARC arithmetic works
twisti
parents:
diff changeset
290 }