Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/Architecture.java @ 23703:9ac04c6047c8
sync with jdk9 changes for JDK-8159613
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 21 Jun 2016 09:48:02 +0200 |
parents | 9e1235406b59 |
children |
rev | line source |
---|---|
22054 | 1 /* |
22533
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
2 * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. |
22054 | 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 */ | |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22640
diff
changeset
|
23 package jdk.vm.ci.code; |
22054 | 24 |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22536
diff
changeset
|
25 import java.nio.ByteOrder; |
22054 | 26 |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22640
diff
changeset
|
27 import jdk.vm.ci.code.Register.RegisterCategory; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22640
diff
changeset
|
28 import jdk.vm.ci.meta.JavaKind; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22640
diff
changeset
|
29 import jdk.vm.ci.meta.PlatformKind; |
22054 | 30 |
31 /** | |
32 * Represents a CPU architecture, including information such as its endianness, CPU registers, word | |
33 * width, etc. | |
34 */ | |
35 public abstract class Architecture { | |
36 | |
37 /** | |
22533
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
38 * The architecture specific type of a native word. |
22054 | 39 */ |
22533
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
40 private final PlatformKind wordKind; |
22054 | 41 |
42 /** | |
43 * The name of this architecture (e.g. "AMD64", "SPARCv9"). | |
44 */ | |
45 private final String name; | |
46 | |
47 /** | |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
22688
diff
changeset
|
48 * List of all available registers on this architecture. The index of each register in this list |
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
22688
diff
changeset
|
49 * is equal to its {@linkplain Register#number number}. |
22054 | 50 */ |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
22688
diff
changeset
|
51 private final RegisterArray registers; |
22054 | 52 |
53 /** | |
54 * The byte ordering can be either little or big endian. | |
55 */ | |
56 private final ByteOrder byteOrder; | |
57 | |
58 /** | |
59 * Whether the architecture supports unaligned memory accesses. | |
60 */ | |
61 private final boolean unalignedMemoryAccess; | |
62 | |
63 /** | |
64 * Mask of the barrier constants denoting the barriers that are not required to be explicitly | |
65 * inserted under this architecture. | |
66 */ | |
67 private final int implicitMemoryBarriers; | |
68 | |
69 /** | |
70 * Offset in bytes from the beginning of a call instruction to the displacement. | |
71 */ | |
72 private final int machineCodeCallDisplacementOffset; | |
73 | |
74 /** | |
75 * The size of the return address pushed to the stack by a call instruction. A value of 0 | |
76 * denotes that call linkage uses registers instead (e.g. SPARC). | |
77 */ | |
78 private final int returnAddressSize; | |
79 | |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
22688
diff
changeset
|
80 protected Architecture(String name, PlatformKind wordKind, ByteOrder byteOrder, boolean unalignedMemoryAccess, RegisterArray registers, int implicitMemoryBarriers, |
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
22688
diff
changeset
|
81 int nativeCallDisplacementOffset, |
22688
ef7d87db544a
Remove unused reference map index.
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
82 int returnAddressSize) { |
22054 | 83 this.name = name; |
84 this.registers = registers; | |
22533
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
85 this.wordKind = wordKind; |
22054 | 86 this.byteOrder = byteOrder; |
87 this.unalignedMemoryAccess = unalignedMemoryAccess; | |
88 this.implicitMemoryBarriers = implicitMemoryBarriers; | |
89 this.machineCodeCallDisplacementOffset = nativeCallDisplacementOffset; | |
90 this.returnAddressSize = returnAddressSize; | |
91 } | |
92 | |
93 /** | |
94 * Converts this architecture to a string. | |
95 * | |
96 * @return the string representation of this architecture | |
97 */ | |
98 @Override | |
99 public final String toString() { | |
100 return getName().toLowerCase(); | |
101 } | |
102 | |
103 /** | |
104 * Gets the natural size of words (typically registers and pointers) of this architecture, in | |
105 * bytes. | |
106 */ | |
107 public int getWordSize() { | |
22535
ca418f35d728
Use wordKind instead of Kind.Object in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
22533
diff
changeset
|
108 return wordKind.getSizeInBytes(); |
22533
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
109 } |
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
110 |
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
111 public PlatformKind getWordKind() { |
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
112 return wordKind; |
22054 | 113 } |
114 | |
115 /** | |
116 * Gets the name of this architecture. | |
117 */ | |
118 public String getName() { | |
119 return name; | |
120 } | |
121 | |
122 /** | |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
22688
diff
changeset
|
123 * Gets the list of all registers that exist on this architecture. This contains all registers |
22640
3abba3d4aef1
Register and PlatformKind declarations for AVX512.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
124 * that exist in the specification of this architecture. Not all of them may be available on |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
22688
diff
changeset
|
125 * this particular architecture instance. The index of each register in this list is equal to |
22640
3abba3d4aef1
Register and PlatformKind declarations for AVX512.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
126 * its {@linkplain Register#number number}. |
22054 | 127 */ |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
22688
diff
changeset
|
128 public RegisterArray getRegisters() { |
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
22688
diff
changeset
|
129 return registers; |
22054 | 130 } |
131 | |
22640
3abba3d4aef1
Register and PlatformKind declarations for AVX512.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
132 /** |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
22688
diff
changeset
|
133 * Gets a list of all registers available for storing values on this architecture. This may be a |
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
22688
diff
changeset
|
134 * subset of {@link #getRegisters()}, depending on the capabilities of this particular CPU. |
22640
3abba3d4aef1
Register and PlatformKind declarations for AVX512.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
135 */ |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
22688
diff
changeset
|
136 public RegisterArray getAvailableValueRegisters() { |
22640
3abba3d4aef1
Register and PlatformKind declarations for AVX512.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
137 return getRegisters(); |
3abba3d4aef1
Register and PlatformKind declarations for AVX512.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
138 } |
3abba3d4aef1
Register and PlatformKind declarations for AVX512.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
139 |
22054 | 140 public ByteOrder getByteOrder() { |
141 return byteOrder; | |
142 } | |
143 | |
144 /** | |
145 * @return true if the architecture supports unaligned memory accesses. | |
146 */ | |
147 public boolean supportsUnalignedMemoryAccess() { | |
148 return unalignedMemoryAccess; | |
149 } | |
150 | |
151 /** | |
152 * Gets the size of the return address pushed to the stack by a call instruction. A value of 0 | |
153 * denotes that call linkage uses registers instead. | |
154 */ | |
155 public int getReturnAddressSize() { | |
156 return returnAddressSize; | |
157 } | |
158 | |
159 /** | |
160 * Gets the offset in bytes from the beginning of a call instruction to the displacement. | |
161 */ | |
162 public int getMachineCodeCallDisplacementOffset() { | |
163 return machineCodeCallDisplacementOffset; | |
164 } | |
165 | |
166 /** | |
167 * Determines the barriers in a given barrier mask that are explicitly required on this | |
168 * architecture. | |
169 * | |
170 * @param barriers a mask of the barrier constants | |
171 * @return the value of {@code barriers} minus the barriers unnecessary on this architecture | |
172 */ | |
173 public final int requiredBarriers(int barriers) { | |
174 return barriers & ~implicitMemoryBarriers; | |
175 } | |
176 | |
177 /** | |
178 * Determine whether a kind can be stored in a register of a given category. | |
179 * | |
180 * @param category the category of the register | |
181 * @param kind the kind that should be stored in the register | |
182 */ | |
183 public abstract boolean canStoreValue(RegisterCategory category, PlatformKind kind); | |
184 | |
185 /** | |
186 * Return the largest kind that can be stored in a register of a given category. | |
187 * | |
188 * @param category the category of the register | |
189 * @return the largest kind that can be stored in a register {@code category} | |
190 */ | |
191 public abstract PlatformKind getLargestStorableKind(RegisterCategory category); | |
192 | |
22533
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
193 /** |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22535
diff
changeset
|
194 * Return the {@link PlatformKind} that is used to store values of a given {@link JavaKind}. |
22533
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
195 */ |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22535
diff
changeset
|
196 public abstract PlatformKind getPlatformKind(JavaKind javaKind); |
22533
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
197 |
22054 | 198 @Override |
199 public final boolean equals(Object obj) { | |
200 if (obj == this) { | |
201 return true; | |
202 } | |
203 if (obj instanceof Architecture) { | |
204 Architecture that = (Architecture) obj; | |
205 if (this.name.equals(that.name)) { | |
206 assert this.byteOrder.equals(that.byteOrder); | |
207 assert this.implicitMemoryBarriers == that.implicitMemoryBarriers; | |
208 assert this.machineCodeCallDisplacementOffset == that.machineCodeCallDisplacementOffset; | |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
22688
diff
changeset
|
209 assert this.registers.equals(that.registers); |
22054 | 210 assert this.returnAddressSize == that.returnAddressSize; |
211 assert this.unalignedMemoryAccess == that.unalignedMemoryAccess; | |
22533
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
212 assert this.wordKind == that.wordKind; |
22054 | 213 return true; |
214 } | |
215 } | |
216 return false; | |
217 } | |
218 | |
219 @Override | |
220 public final int hashCode() { | |
221 return name.hashCode(); | |
222 } | |
223 } |