Mercurial > hg > truffle
annotate graal/com.oracle.jvmci.hotspot.sparc/src/com/oracle/jvmci/hotspot/sparc/SPARCHotSpotRegisterConfig.java @ 21755:c052d68e7eac
disable ConvertDeoptimizeToGuardPhase for snippet graphs containing snippet counters to avoid (silent) deletion of counters on a path terminated by a deopt
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 05 Jun 2015 23:05:16 +0200 |
parents | e0b5d4fcd929 |
children |
rev | line source |
---|---|
10459 | 1 /* |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15345
diff
changeset
|
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
10459 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
21674
e0b5d4fcd929
moved HotSpotTargetDescription and [AMD64|SPARC]HotSpotRegisterConfig into JVMCI namespace (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21673
diff
changeset
|
23 package com.oracle.jvmci.hotspot.sparc; |
10459 | 24 |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
25 import com.oracle.jvmci.code.Architecture; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
26 import com.oracle.jvmci.code.TargetDescription; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
27 import com.oracle.jvmci.code.CallingConvention; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
28 import com.oracle.jvmci.code.CalleeSaveLayout; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
29 import com.oracle.jvmci.code.RegisterAttributes; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
30 import com.oracle.jvmci.code.StackSlot; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
31 import com.oracle.jvmci.code.RegisterConfig; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
32 import com.oracle.jvmci.code.Register; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
33 import com.oracle.jvmci.meta.Kind; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
34 import com.oracle.jvmci.meta.JavaType; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
35 import com.oracle.jvmci.meta.PlatformKind; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
36 import com.oracle.jvmci.meta.Value; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
37 import com.oracle.jvmci.meta.AllocatableValue; |
21673
5024c80224c7
moved com.oracle.graal.[amd64|sparc] to com.oracle.jvmci.[amd64|sparc] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
38 import com.oracle.jvmci.sparc.*; |
5024c80224c7
moved com.oracle.graal.[amd64|sparc] to com.oracle.jvmci.[amd64|sparc] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
39 |
5024c80224c7
moved com.oracle.graal.[amd64|sparc] to com.oracle.jvmci.[amd64|sparc] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
40 import static com.oracle.jvmci.sparc.SPARC.*; |
10459 | 41 |
42 import java.util.*; | |
43 | |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
44 import com.oracle.jvmci.code.CallingConvention.Type; |
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
|
45 import com.oracle.jvmci.common.*; |
21551
5324104ac4f3
moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21543
diff
changeset
|
46 import com.oracle.jvmci.hotspot.*; |
10459 | 47 |
48 public class SPARCHotSpotRegisterConfig implements RegisterConfig { | |
49 | |
50 private final Architecture architecture; | |
51 | |
52 private final Register[] allocatable; | |
53 | |
54 private final RegisterAttributes[] attributesMap; | |
55 | |
56 @Override | |
57 public Register[] getAllocatableRegisters() { | |
58 return allocatable.clone(); | |
59 } | |
60 | |
20916
661ed7d3d10d
RegisterConfig: rename getAllocatableRegisters(PK,R[) to filterAllocatableRegisters and remove caching from implementors.
Josef Eisl <josef.eisl@jku.at>
parents:
20913
diff
changeset
|
61 public Register[] filterAllocatableRegisters(PlatformKind kind, Register[] registers) { |
10459 | 62 ArrayList<Register> list = new ArrayList<>(); |
20913
9b6ea36013c4
RegisterConfig: pass registers array to getAllocatableRegisters(PlatformKind).
Josef Eisl <josef.eisl@jku.at>
parents:
20149
diff
changeset
|
63 for (Register reg : registers) { |
10459 | 64 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
|
65 // 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
|
66 // 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
|
67 if (kind == Kind.Double) { |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
68 if (reg.name.startsWith("d")) { |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
69 list.add(reg); |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
70 } |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
71 } else if (kind == Kind.Float) { |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
72 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
|
73 list.add(reg); |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
74 } |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
75 } else { |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
76 list.add(reg); |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
77 } |
10459 | 78 } |
79 } | |
80 | |
18355
9a11c4086341
size array appropriately when creating categorized register array
Doug Simon <doug.simon@oracle.com>
parents:
16995
diff
changeset
|
81 Register[] ret = list.toArray(new Register[list.size()]); |
10459 | 82 return ret; |
83 } | |
84 | |
85 @Override | |
86 public RegisterAttributes[] getAttributesMap() { | |
87 return attributesMap.clone(); | |
88 } | |
89 | |
10792 | 90 private final Register[] cpuCallerParameterRegisters = {o0, o1, o2, o3, o4, o5}; |
91 private final Register[] cpuCalleeParameterRegisters = {i0, i1, i2, i3, i4, i5}; | |
92 | |
10459 | 93 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
|
94 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
|
95 // @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
|
96 private final Register[] callerSaveRegisters = |
19531
9299e71df12a
[SPARC] Save all registers for foreign calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18630
diff
changeset
|
97 {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
|
98 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
|
99 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
|
100 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
|
101 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
|
102 f24, f25, f26, f27, f28, f29, f30, f31, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
103 d32, d34, d36, d38, d40, d42, d44, d46, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
104 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
|
105 // @formatter:on |
11233 | 106 |
107 /** | |
108 * Registers saved by the callee. This lists all L and I registers which are saved in the | |
21674
e0b5d4fcd929
moved HotSpotTargetDescription and [AMD64|SPARC]HotSpotRegisterConfig into JVMCI namespace (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21673
diff
changeset
|
109 * register window. |
11233 | 110 */ |
111 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
|
112 |
10459 | 113 private final CalleeSaveLayout csl; |
114 | |
115 private static Register[] initAllocatable(boolean reserveForHeapBase) { | |
116 Register[] registers = null; | |
117 if (reserveForHeapBase) { | |
15345 | 118 // @formatter:off |
119 registers = new Register[]{ | |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
120 // 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
|
121 // 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
|
122 // 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
|
123 // 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
|
124 // 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
|
125 o0, o1, o2, o3, o4, o5, /*o6, o7,*/ |
10459 | 126 l0, l1, l2, l3, l4, l5, l6, l7, |
11233 | 127 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
|
128 //f0, f1, f2, f3, f4, f5, f6, f7, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
129 f8, f9, f10, f11, f12, f13, f14, f15, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
130 f16, f17, f18, f19, f20, f21, f22, f23, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
131 f24, f25, f26, f27, f28, f29, f30, f31, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
132 d32, d34, d36, d38, d40, d42, d44, d46, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
133 d48, d50, d52, d54, d56, d58, d60, d62 |
15345 | 134 }; |
135 // @formatter:on | |
10459 | 136 } else { |
15345 | 137 // @formatter:off |
138 registers = new Register[]{ | |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
139 // 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
|
140 o0, o1, o2, o3, o4, o5, /*o6, o7,*/ |
10459 | 141 l0, l1, l2, l3, l4, l5, l6, l7, |
11233 | 142 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
|
143 // f0, f1, f2, f3, f4, f5, f6, f7 |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
144 f8, f9, f10, f11, f12, f13, f14, f15, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
145 f16, f17, f18, f19, f20, f21, f22, f23, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
146 f24, f25, f26, f27, f28, f29, f30, f31, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
147 d32, d34, d36, d38, d40, d42, d44, d46, |
4feac7e51f42
[SPARC] Fixing float register allocation
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
16932
diff
changeset
|
148 d48, d50, d52, d54, d56, d58, d60, d62 |
15345 | 149 }; |
150 // @formatter:on | |
10459 | 151 } |
152 | |
153 return registers; | |
154 } | |
155 | |
14559
883fbd3e06e0
Make size of PlatformKind overridable by VM specific code.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
156 public SPARCHotSpotRegisterConfig(TargetDescription target, HotSpotVMConfig config) { |
15011
c8e575742f36
allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
157 this(target, initAllocatable(config.useCompressedOops)); |
c8e575742f36
allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
158 } |
c8e575742f36
allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
159 |
c8e575742f36
allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
160 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
|
161 this.architecture = target.arch; |
10459 | 162 |
14559
883fbd3e06e0
Make size of PlatformKind overridable by VM specific code.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
163 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
|
164 this.allocatable = allocatable.clone(); |
10459 | 165 attributesMap = RegisterAttributes.createMap(this, SPARC.allRegisters); |
166 } | |
167 | |
168 @Override | |
169 public Register[] getCallerSaveRegisters() { | |
10686
73122b5edf6a
SPARC: Can compile simple methods and do static calls.
twisti
parents:
10459
diff
changeset
|
170 return callerSaveRegisters; |
10459 | 171 } |
172 | |
173 @Override | |
14614
abf7cf57df5e
added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents:
14559
diff
changeset
|
174 public boolean areAllAllocatableRegistersCallerSaved() { |
abf7cf57df5e
added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents:
14559
diff
changeset
|
175 return false; |
abf7cf57df5e
added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents:
14559
diff
changeset
|
176 } |
abf7cf57df5e
added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents:
14559
diff
changeset
|
177 |
abf7cf57df5e
added RegisterConfig.areAllAllocatableRegistersCallerSaved()
Doug Simon <doug.simon@oracle.com>
parents:
14559
diff
changeset
|
178 @Override |
10459 | 179 public Register getRegisterForRole(int index) { |
180 throw new UnsupportedOperationException(); | |
181 } | |
182 | |
183 @Override | |
184 public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target, boolean stackOnly) { | |
10792 | 185 if (type == Type.JavaCall || type == Type.NativeCall) { |
186 return callingConvention(cpuCallerParameterRegisters, returnType, parameterTypes, type, target, stackOnly); | |
10459 | 187 } |
10792 | 188 if (type == Type.JavaCallee) { |
189 return callingConvention(cpuCalleeParameterRegisters, returnType, parameterTypes, type, target, stackOnly); | |
190 } | |
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
|
191 throw JVMCIError.shouldNotReachHere(); |
10459 | 192 } |
193 | |
194 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
|
195 if (architecture.canStoreValue(FPUs, kind) || architecture.canStoreValue(FPUd, kind)) { |
10459 | 196 return fpuParameterRegisters; |
197 } | |
198 assert architecture.canStoreValue(CPU, kind); | |
10792 | 199 return type == Type.JavaCallee ? cpuCalleeParameterRegisters : cpuCallerParameterRegisters; |
10459 | 200 } |
201 | |
202 private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, Type type, TargetDescription target, boolean stackOnly) { | |
203 AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; | |
204 | |
205 int currentGeneral = 0; | |
206 int currentFloating = 0; | |
16637
eda09bc52ab9
[SPARC] Fix handling of overflow parameter on stack.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16634
diff
changeset
|
207 int currentStackOffset = 0; |
10459 | 208 |
209 for (int i = 0; i < parameterTypes.length; i++) { | |
210 final Kind kind = parameterTypes[i].getKind(); | |
211 | |
212 switch (kind) { | |
213 case Byte: | |
214 case Boolean: | |
215 case Short: | |
216 case Char: | |
217 case Int: | |
218 case Long: | |
219 case Object: | |
220 if (!stackOnly && currentGeneral < generalParameterRegisters.length) { | |
221 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
|
222 locations[i] = register.asValue(target.getLIRKind(kind)); |
10459 | 223 } |
224 break; | |
16321
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
225 case Double: |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
226 if (!stackOnly && currentFloating < fpuParameterRegisters.length) { |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
227 if (currentFloating % 2 != 0) { |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
228 // 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
|
229 currentFloating++; |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
230 } |
20149
b1a8928fc4b9
[SPARC] Implement new instructions in assembler/enhance assertion error-message in MoveResolver
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19531
diff
changeset
|
231 Register register = fpuDoubleParameterRegisters[currentFloating]; |
16321
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
232 currentFloating += 2; // Only every second is a double register |
16327
5f01f7c48d40
Merge with 5cdcb94a7cf7d9782107cc582f3e4b50000d5d1f
Stefan Anzinger <stefan.anzinger@gmail.com>
diff
changeset
|
233 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
|
234 } |
fac4af29aeb8
[SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15345
diff
changeset
|
235 break; |
10459 | 236 case Float: |
237 if (!stackOnly && currentFloating < fpuParameterRegisters.length) { | |
238 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
|
239 locations[i] = register.asValue(target.getLIRKind(kind)); |
10459 | 240 } |
241 break; | |
242 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
|
243 throw JVMCIError.shouldNotReachHere(); |
10459 | 244 } |
245 | |
246 if (locations[i] == null) { | |
16654
8aa938ab4ac8
[SPARC] Spill slots must be 4 byte aligned
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
16637
diff
changeset
|
247 // 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
|
248 int typeSize = SPARC.spillSlotSize(target, kind); |
21674
e0b5d4fcd929
moved HotSpotTargetDescription and [AMD64|SPARC]HotSpotRegisterConfig into JVMCI namespace (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21673
diff
changeset
|
249 currentStackOffset = roundUp(currentStackOffset, typeSize); |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15345
diff
changeset
|
250 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
|
251 currentStackOffset += typeSize; |
10459 | 252 } |
253 } | |
254 | |
255 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
|
256 AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind, type).asValue(target.getLIRKind(returnKind.getStackKind())); |
10459 | 257 return new CallingConvention(currentStackOffset, returnLocation, locations); |
258 } | |
259 | |
21674
e0b5d4fcd929
moved HotSpotTargetDescription and [AMD64|SPARC]HotSpotRegisterConfig into JVMCI namespace (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21673
diff
changeset
|
260 private static int roundUp(int number, int mod) { |
e0b5d4fcd929
moved HotSpotTargetDescription and [AMD64|SPARC]HotSpotRegisterConfig into JVMCI namespace (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21673
diff
changeset
|
261 return ((number + mod - 1) / mod) * mod; |
e0b5d4fcd929
moved HotSpotTargetDescription and [AMD64|SPARC]HotSpotRegisterConfig into JVMCI namespace (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21673
diff
changeset
|
262 } |
e0b5d4fcd929
moved HotSpotTargetDescription and [AMD64|SPARC]HotSpotRegisterConfig into JVMCI namespace (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21673
diff
changeset
|
263 |
10459 | 264 @Override |
265 public Register getReturnRegister(Kind kind) { | |
10871
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
266 return getReturnRegister(kind, Type.JavaCallee); |
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
267 } |
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
268 |
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
269 private static Register getReturnRegister(Kind kind, Type type) { |
10459 | 270 switch (kind) { |
271 case Boolean: | |
272 case Byte: | |
273 case Char: | |
274 case Short: | |
275 case Int: | |
276 case Long: | |
277 case Object: | |
10871
c3b09d69dfde
SPARC: fixes and more implementation; can now allocate objects
twisti
parents:
10854
diff
changeset
|
278 return type == Type.JavaCallee ? i0 : o0; |
10459 | 279 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
|
280 return f0; |
10459 | 281 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
|
282 return d0; |
10459 | 283 case Void: |
284 case Illegal: | |
285 return null; | |
286 default: | |
287 throw new UnsupportedOperationException("no return register for type " + kind); | |
288 } | |
289 } | |
290 | |
291 @Override | |
292 public Register getFrameRegister() { | |
293 return sp; | |
294 } | |
295 | |
296 public CalleeSaveLayout getCalleeSaveLayout() { | |
297 return csl; | |
298 } | |
299 | |
300 @Override | |
301 public String toString() { | |
302 return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave: " + Arrays.toString(getCallerSaveRegisters()) + "%n"); | |
303 } | |
304 } |