Skip to content

Commit 735c789

Browse files
author
Yudi Zheng
committed
8334717: Add JVMCI support for APX EGPRs
Reviewed-by: dnsimon
1 parent a0cdf36 commit 735c789

21 files changed

+227
-517
lines changed

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/aarch64/AArch64.java

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424

2525
import java.nio.ByteOrder;
2626
import java.util.EnumSet;
27+
import java.util.List;
2728

2829
import jdk.vm.ci.code.Architecture;
2930
import jdk.vm.ci.code.CPUFeatureName;
3031
import jdk.vm.ci.code.Register;
3132
import jdk.vm.ci.code.Register.RegisterCategory;
32-
import jdk.vm.ci.code.RegisterArray;
3333
import jdk.vm.ci.meta.JavaKind;
3434
import jdk.vm.ci.meta.PlatformKind;
3535

@@ -92,7 +92,7 @@ public class AArch64 extends Architecture {
9292
public static final Register rscratch2 = r9;
9393

9494
// @formatter:off
95-
public static final RegisterArray cpuRegisters = new RegisterArray(
95+
public static final List<Register> cpuRegisters = List.of(
9696
r0, r1, r2, r3, r4, r5, r6, r7,
9797
r8, r9, r10, r11, r12, r13, r14, r15,
9898
r16, r17, r18, r19, r20, r21, r22, r23,
@@ -138,7 +138,7 @@ public class AArch64 extends Architecture {
138138
public static final Register v31 = new Register(65, 31, "v31", SIMD);
139139

140140
// @formatter:off
141-
public static final RegisterArray simdRegisters = new RegisterArray(
141+
public static final List<Register> simdRegisters = List.of(
142142
v0, v1, v2, v3, v4, v5, v6, v7,
143143
v8, v9, v10, v11, v12, v13, v14, v15,
144144
v16, v17, v18, v19, v20, v21, v22, v23,
@@ -147,7 +147,7 @@ public class AArch64 extends Architecture {
147147
// @formatter:on
148148

149149
// @formatter:off
150-
public static final RegisterArray allRegisters = new RegisterArray(
150+
public static final List<Register> allRegisters = List.of(
151151
r0, r1, r2, r3, r4, r5, r6, r7,
152152
r8, r9, r10, r11, r12, r13, r14, r15,
153153
r16, r17, r18, r19, r20, r21, r22, r23,
@@ -189,34 +189,16 @@ public enum CPUFeature implements CPUFeatureName {
189189

190190
private final EnumSet<CPUFeature> features;
191191

192-
/**
193-
* Set of flags to control code emission.
194-
*/
195-
public enum Flag {
196-
UseCRC32,
197-
UseSIMDForMemoryOps,
198-
AvoidUnalignedAccesses,
199-
UseLSE,
200-
UseBlockZeroing
201-
}
202-
203-
private final EnumSet<Flag> flags;
204-
205-
public AArch64(EnumSet<CPUFeature> features, EnumSet<Flag> flags) {
192+
public AArch64(EnumSet<CPUFeature> features) {
206193
super("aarch64", AArch64Kind.QWORD, ByteOrder.LITTLE_ENDIAN, true, allRegisters, 0, 0, 0);
207194
this.features = features;
208-
this.flags = flags;
209195
}
210196

211197
@Override
212198
public EnumSet<CPUFeature> getFeatures() {
213199
return features;
214200
}
215201

216-
public EnumSet<Flag> getFlags() {
217-
return flags;
218-
}
219-
220202
@Override
221203
public PlatformKind getPlatformKind(JavaKind javaKind) {
222204
switch (javaKind) {

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64.java

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929

3030
import java.nio.ByteOrder;
3131
import java.util.EnumSet;
32+
import java.util.List;
3233

3334
import jdk.vm.ci.code.Architecture;
3435
import jdk.vm.ci.code.CPUFeatureName;
3536
import jdk.vm.ci.code.Register;
3637
import jdk.vm.ci.code.Register.RegisterCategory;
37-
import jdk.vm.ci.code.RegisterArray;
3838
import jdk.vm.ci.meta.JavaKind;
3939
import jdk.vm.ci.meta.PlatformKind;
4040

@@ -86,10 +86,17 @@ public class AMD64 extends Architecture {
8686
public static final Register r31 = new Register(31, 31, "r31", CPU);
8787

8888
// The set of common CPU registers available on all x64 platforms.
89-
public static final Register[] cpuRegisters = {
89+
public static final List<Register> cpuRegisters = List.of(
9090
rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi,
9191
r8, r9, r10, r11, r12, r13, r14, r15
92-
};
92+
);
93+
94+
public static final List<Register> cpuRegistersAPX = List.of(
95+
rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi,
96+
r8, r9, r10, r11, r12, r13, r14, r15,
97+
r16, r17, r18, r19, r20, r21, r22, r23,
98+
r24, r25, r26, r27, r28, r29, r30, r31
99+
);
93100

94101
public static final RegisterCategory XMM = new RegisterCategory("XMM");
95102

@@ -130,17 +137,17 @@ public class AMD64 extends Architecture {
130137
public static final Register xmm30 = new Register(62, 30, "xmm30", XMM);
131138
public static final Register xmm31 = new Register(63, 31, "xmm31", XMM);
132139

133-
public static final Register[] xmmRegistersSSE = {
140+
public static final List<Register> xmmRegistersSSE = List.of(
134141
xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7,
135142
xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15
136-
};
143+
);
137144

138-
public static final Register[] xmmRegistersAVX512 = {
145+
public static final List<Register> xmmRegistersAVX512 = List.of(
139146
xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7,
140147
xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15,
141148
xmm16, xmm17, xmm18, xmm19, xmm20, xmm21, xmm22, xmm23,
142149
xmm24, xmm25, xmm26, xmm27, xmm28, xmm29, xmm30, xmm31
143-
};
150+
);
144151

145152
public static final RegisterCategory MASK = new RegisterCategory("MASK", false);
146153

@@ -153,14 +160,14 @@ public class AMD64 extends Architecture {
153160
public static final Register k6 = new Register(70, 6, "k6", MASK);
154161
public static final Register k7 = new Register(71, 7, "k7", MASK);
155162

156-
public static final RegisterArray valueRegistersSSE = new RegisterArray(
163+
public static final List<Register> valueRegistersSSE = List.of(
157164
rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi,
158165
r8, r9, r10, r11, r12, r13, r14, r15,
159166
xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7,
160167
xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15
161168
);
162169

163-
public static final RegisterArray valueRegistersAVX512 = new RegisterArray(
170+
public static final List<Register> valueRegistersAVX512 = List.of(
164171
rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi,
165172
r8, r9, r10, r11, r12, r13, r14, r15,
166173
xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7,
@@ -170,12 +177,33 @@ public class AMD64 extends Architecture {
170177
k0, k1, k2, k3, k4, k5, k6, k7
171178
);
172179

180+
public static final List<Register> valueRegistersSSEAndAPX = List.of(
181+
rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi,
182+
r8, r9, r10, r11, r12, r13, r14, r15,
183+
r16, r17, r18, r19, r20, r21, r22, r23,
184+
r24, r25, r26, r27, r28, r29, r30, r31,
185+
xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7,
186+
xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15
187+
);
188+
189+
public static final List<Register> valueRegistersAVX512AndAPX = List.of(
190+
rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi,
191+
r8, r9, r10, r11, r12, r13, r14, r15,
192+
r16, r17, r18, r19, r20, r21, r22, r23,
193+
r24, r25, r26, r27, r28, r29, r30, r31,
194+
xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7,
195+
xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15,
196+
xmm16, xmm17, xmm18, xmm19, xmm20, xmm21, xmm22, xmm23,
197+
xmm24, xmm25, xmm26, xmm27, xmm28, xmm29, xmm30, xmm31,
198+
k0, k1, k2, k3, k4, k5, k6, k7
199+
);
200+
173201
/**
174202
* Register used to construct an instruction-relative address.
175203
*/
176204
public static final Register rip = new Register(72, -1, "rip", SPECIAL);
177205

178-
public static final RegisterArray allRegisters = new RegisterArray(
206+
public static final List<Register> allRegisters = List.of(
179207
rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi,
180208
r8, r9, r10, r11, r12, r13, r14, r15,
181209
r16, r17, r18, r19, r20, r21, r22, r23,
@@ -264,24 +292,13 @@ public enum CPUFeature implements CPUFeatureName {
264292

265293
private final EnumSet<CPUFeature> features;
266294

267-
/**
268-
* Set of flags to control code emission.
269-
*/
270-
public enum Flag {
271-
UseCountLeadingZerosInstruction,
272-
UseCountTrailingZerosInstruction
273-
}
274-
275-
private final EnumSet<Flag> flags;
276-
277295
private final AMD64Kind largestKind;
278296

279297
private final AMD64Kind largestMaskKind;
280298

281-
public AMD64(EnumSet<CPUFeature> features, EnumSet<Flag> flags) {
299+
public AMD64(EnumSet<CPUFeature> features) {
282300
super("AMD64", AMD64Kind.QWORD, ByteOrder.LITTLE_ENDIAN, true, allRegisters, LOAD_LOAD | LOAD_STORE | STORE_STORE, 1, 8);
283301
this.features = features;
284-
this.flags = flags;
285302
assert features.contains(CPUFeature.SSE2) : "minimum config for x64";
286303

287304
if (features.contains(CPUFeature.AVX512F)) {
@@ -305,13 +322,15 @@ public EnumSet<CPUFeature> getFeatures() {
305322
return features;
306323
}
307324

308-
public EnumSet<Flag> getFlags() {
309-
return flags;
310-
}
311-
312325
@Override
313-
public RegisterArray getAvailableValueRegisters() {
314-
if (features.contains(CPUFeature.AVX512F)) {
326+
public List<Register> getAvailableValueRegisters() {
327+
if (features.contains(CPUFeature.APX_F)) {
328+
if (features.contains(CPUFeature.AVX512F)) {
329+
return valueRegistersAVX512AndAPX;
330+
} else {
331+
return valueRegistersSSEAndAPX;
332+
}
333+
} else if (features.contains(CPUFeature.AVX512F)) {
315334
return valueRegistersAVX512;
316335
} else {
317336
return valueRegistersSSE;

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/Architecture.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
2323
package jdk.vm.ci.code;
2424

2525
import java.nio.ByteOrder;
26+
import java.util.List;
2627
import java.util.Set;
2728

2829
import jdk.vm.ci.code.Register.RegisterCategory;
@@ -50,7 +51,7 @@ public abstract class Architecture {
5051
* List of all available registers on this architecture. The index of each register in this list
5152
* is equal to its {@linkplain Register#number number}.
5253
*/
53-
private final RegisterArray registers;
54+
private final List<Register> registers;
5455

5556
/**
5657
* The byte ordering can be either little or big endian.
@@ -79,7 +80,7 @@ public abstract class Architecture {
7980
*/
8081
private final int returnAddressSize;
8182

82-
protected Architecture(String name, PlatformKind wordKind, ByteOrder byteOrder, boolean unalignedMemoryAccess, RegisterArray registers, int implicitMemoryBarriers,
83+
protected Architecture(String name, PlatformKind wordKind, ByteOrder byteOrder, boolean unalignedMemoryAccess, List<Register> registers, int implicitMemoryBarriers,
8384
int nativeCallDisplacementOffset,
8485
int returnAddressSize) {
8586
// registers is expected to mention all registers in order of their encoding.
@@ -144,15 +145,15 @@ public String getName() {
144145
* this particular architecture instance. The index of each register in this list is equal to
145146
* its {@linkplain Register#number number}.
146147
*/
147-
public RegisterArray getRegisters() {
148+
public List<Register> getRegisters() {
148149
return registers;
149150
}
150151

151152
/**
152153
* Gets a list of all registers available for storing values on this architecture. This may be a
153154
* subset of {@link #getRegisters()}, depending on the capabilities of this particular CPU.
154155
*/
155-
public RegisterArray getAvailableValueRegisters() {
156+
public List<Register> getAvailableValueRegisters() {
156157
return getRegisters();
157158
}
158159

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CallingConvention.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
2727
import jdk.vm.ci.meta.AllocatableValue;
2828
import jdk.vm.ci.meta.Value;
2929

30+
import java.util.List;
31+
3032
/**
3133
* A calling convention describes the locations in which the arguments for a call are placed and the
3234
* location in which the return value is placed if the call is not void.
@@ -49,7 +51,7 @@ public interface Type {
4951
/**
5052
* The ordered locations in which the arguments are placed.
5153
*/
52-
private final AllocatableValue[] argumentLocations;
54+
private final List<AllocatableValue> argumentLocations;
5355

5456
/**
5557
* Creates a description of the registers and stack locations used by a call.
@@ -63,7 +65,7 @@ public interface Type {
6365
public CallingConvention(int stackSize, AllocatableValue returnLocation, AllocatableValue... argumentLocations) {
6466
assert argumentLocations != null;
6567
assert returnLocation != null;
66-
this.argumentLocations = argumentLocations;
68+
this.argumentLocations = List.of(argumentLocations);
6769
this.stackSize = stackSize;
6870
this.returnLocation = returnLocation;
6971
assert verify();
@@ -80,7 +82,7 @@ public AllocatableValue getReturn() {
8082
* Gets the location for the {@code index}'th argument.
8183
*/
8284
public AllocatableValue getArgument(int index) {
83-
return argumentLocations[index];
85+
return argumentLocations.get(index);
8486
}
8587

8688
/**
@@ -94,18 +96,14 @@ public int getStackSize() {
9496
* Gets the number of locations required for the arguments.
9597
*/
9698
public int getArgumentCount() {
97-
return argumentLocations.length;
99+
return argumentLocations.size();
98100
}
99101

100102
/**
101103
* Gets the locations required for the arguments.
102104
*/
103-
@SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "FB false positive")
104-
public AllocatableValue[] getArguments() {
105-
if (argumentLocations.length == 0) {
106-
return argumentLocations;
107-
}
108-
return argumentLocations.clone();
105+
public List<AllocatableValue> getArguments() {
106+
return argumentLocations;
109107
}
110108

111109
@Override
@@ -125,8 +123,8 @@ public String toString() {
125123
}
126124

127125
private boolean verify() {
128-
for (int i = 0; i < argumentLocations.length; i++) {
129-
Value location = argumentLocations[i];
126+
for (int i = 0; i < argumentLocations.size(); i++) {
127+
Value location = argumentLocations.get(i);
130128
assert isStackSlot(location) || isAllocatableValue(location);
131129
}
132130
return true;

0 commit comments

Comments
 (0)