Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/Architecture.java @ 22688:ef7d87db544a
Remove unused reference map index.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Fri, 16 Oct 2015 11:12:34 +0200 |
parents | 1bbd4a7c274b |
children | 9e1235406b59 |
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; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22536
diff
changeset
|
26 import java.util.Arrays; |
22054 | 27 |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22640
diff
changeset
|
28 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
|
29 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
|
30 import jdk.vm.ci.meta.PlatformKind; |
22054 | 31 |
32 /** | |
33 * Represents a CPU architecture, including information such as its endianness, CPU registers, word | |
34 * width, etc. | |
35 */ | |
36 public abstract class Architecture { | |
37 | |
38 /** | |
22533
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
39 * The architecture specific type of a native word. |
22054 | 40 */ |
22533
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
41 private final PlatformKind wordKind; |
22054 | 42 |
43 /** | |
44 * The name of this architecture (e.g. "AMD64", "SPARCv9"). | |
45 */ | |
46 private final String name; | |
47 | |
48 /** | |
49 * Array of all available registers on this architecture. The index of each register in this | |
50 * array is equal to its {@linkplain Register#number number}. | |
51 */ | |
52 private final Register[] registers; | |
53 | |
54 /** | |
55 * The byte ordering can be either little or big endian. | |
56 */ | |
57 private final ByteOrder byteOrder; | |
58 | |
59 /** | |
60 * Whether the architecture supports unaligned memory accesses. | |
61 */ | |
62 private final boolean unalignedMemoryAccess; | |
63 | |
64 /** | |
65 * Mask of the barrier constants denoting the barriers that are not required to be explicitly | |
66 * inserted under this architecture. | |
67 */ | |
68 private final int implicitMemoryBarriers; | |
69 | |
70 /** | |
71 * Offset in bytes from the beginning of a call instruction to the displacement. | |
72 */ | |
73 private final int machineCodeCallDisplacementOffset; | |
74 | |
75 /** | |
76 * The size of the return address pushed to the stack by a call instruction. A value of 0 | |
77 * denotes that call linkage uses registers instead (e.g. SPARC). | |
78 */ | |
79 private final int returnAddressSize; | |
80 | |
22533
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
81 protected Architecture(String name, PlatformKind wordKind, ByteOrder byteOrder, boolean unalignedMemoryAccess, Register[] registers, int implicitMemoryBarriers, 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 /** | |
22640
3abba3d4aef1
Register and PlatformKind declarations for AVX512.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
123 * Gets an array of all registers that exist on this architecture. This contains all registers |
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 |
3abba3d4aef1
Register and PlatformKind declarations for AVX512.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
125 * this particular architecture instance. The index of each register in this array is equal to |
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 */ |
128 public Register[] getRegisters() { | |
129 return registers.clone(); | |
130 } | |
131 | |
22640
3abba3d4aef1
Register and PlatformKind declarations for AVX512.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
132 /** |
3abba3d4aef1
Register and PlatformKind declarations for AVX512.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
133 * Gets an array of all registers available for storing values on this architecture. This may be |
3abba3d4aef1
Register and PlatformKind declarations for AVX512.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
134 * a subset of {@link #getRegisters()}, depending on the capabilities of this particular CPU. |
3abba3d4aef1
Register and PlatformKind declarations for AVX512.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
135 */ |
3abba3d4aef1
Register and PlatformKind declarations for AVX512.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
136 public Register[] getAvailableValueRegisters() { |
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; | |
209 assert Arrays.equals(this.registers, that.registers); | |
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 } |