Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@

import java.nio.ByteOrder;
import java.util.EnumSet;
import java.util.List;

import jdk.vm.ci.code.Architecture;
import jdk.vm.ci.code.CPUFeatureName;
import jdk.vm.ci.code.Register;
import jdk.vm.ci.code.Register.RegisterCategory;
import jdk.vm.ci.code.RegisterArray;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.PlatformKind;

Expand Down Expand Up @@ -92,7 +92,7 @@ public class AArch64 extends Architecture {
public static final Register rscratch2 = r9;

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

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

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

private final EnumSet<CPUFeature> features;

/**
* Set of flags to control code emission.
*/
public enum Flag {
UseCRC32,
UseSIMDForMemoryOps,
AvoidUnalignedAccesses,
UseLSE,
UseBlockZeroing
}

private final EnumSet<Flag> flags;

public AArch64(EnumSet<CPUFeature> features, EnumSet<Flag> flags) {
public AArch64(EnumSet<CPUFeature> features) {
super("aarch64", AArch64Kind.QWORD, ByteOrder.LITTLE_ENDIAN, true, allRegisters, 0, 0, 0);
this.features = features;
this.flags = flags;
}

@Override
public EnumSet<CPUFeature> getFeatures() {
return features;
}

public EnumSet<Flag> getFlags() {
return flags;
}

@Override
public PlatformKind getPlatformKind(JavaKind javaKind) {
switch (javaKind) {
Expand Down
75 changes: 47 additions & 28 deletions src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@

import java.nio.ByteOrder;
import java.util.EnumSet;
import java.util.List;

import jdk.vm.ci.code.Architecture;
import jdk.vm.ci.code.CPUFeatureName;
import jdk.vm.ci.code.Register;
import jdk.vm.ci.code.Register.RegisterCategory;
import jdk.vm.ci.code.RegisterArray;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.PlatformKind;

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

// The set of common CPU registers available on all x64 platforms.
public static final Register[] cpuRegisters = {
public static final List<Register> cpuRegisters = List.of(
rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi,
r8, r9, r10, r11, r12, r13, r14, r15
};
);

public static final List<Register> cpuRegistersAPX = List.of(
rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi,
r8, r9, r10, r11, r12, r13, r14, r15,
r16, r17, r18, r19, r20, r21, r22, r23,
r24, r25, r26, r27, r28, r29, r30, r31
);

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

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

public static final Register[] xmmRegistersSSE = {
public static final List<Register> xmmRegistersSSE = List.of(
xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7,
xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15
};
);

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

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

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

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

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

public static final List<Register> valueRegistersSSEAndAPX = List.of(
rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi,
r8, r9, r10, r11, r12, r13, r14, r15,
r16, r17, r18, r19, r20, r21, r22, r23,
r24, r25, r26, r27, r28, r29, r30, r31,
xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7,
xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15
);

public static final List<Register> valueRegistersAVX512AndAPX = List.of(
rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi,
r8, r9, r10, r11, r12, r13, r14, r15,
r16, r17, r18, r19, r20, r21, r22, r23,
r24, r25, r26, r27, r28, r29, r30, r31,
xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7,
xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15,
xmm16, xmm17, xmm18, xmm19, xmm20, xmm21, xmm22, xmm23,
xmm24, xmm25, xmm26, xmm27, xmm28, xmm29, xmm30, xmm31,
k0, k1, k2, k3, k4, k5, k6, k7
);

/**
* Register used to construct an instruction-relative address.
*/
public static final Register rip = new Register(72, -1, "rip", SPECIAL);

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

private final EnumSet<CPUFeature> features;

/**
* Set of flags to control code emission.
*/
public enum Flag {
UseCountLeadingZerosInstruction,
UseCountTrailingZerosInstruction
}

private final EnumSet<Flag> flags;

private final AMD64Kind largestKind;

private final AMD64Kind largestMaskKind;

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

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

public EnumSet<Flag> getFlags() {
return flags;
}

@Override
public RegisterArray getAvailableValueRegisters() {
if (features.contains(CPUFeature.AVX512F)) {
public List<Register> getAvailableValueRegisters() {
if (features.contains(CPUFeature.APX_F)) {
if (features.contains(CPUFeature.AVX512F)) {
return valueRegistersAVX512AndAPX;
} else {
return valueRegistersSSEAndAPX;
}
} else if (features.contains(CPUFeature.AVX512F)) {
return valueRegistersAVX512;
} else {
return valueRegistersSSE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,6 +23,7 @@
package jdk.vm.ci.code;

import java.nio.ByteOrder;
import java.util.List;
import java.util.Set;

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

/**
* The byte ordering can be either little or big endian.
Expand Down Expand Up @@ -79,7 +80,7 @@ public abstract class Architecture {
*/
private final int returnAddressSize;

protected Architecture(String name, PlatformKind wordKind, ByteOrder byteOrder, boolean unalignedMemoryAccess, RegisterArray registers, int implicitMemoryBarriers,
protected Architecture(String name, PlatformKind wordKind, ByteOrder byteOrder, boolean unalignedMemoryAccess, List<Register> registers, int implicitMemoryBarriers,
int nativeCallDisplacementOffset,
int returnAddressSize) {
// registers is expected to mention all registers in order of their encoding.
Expand Down Expand Up @@ -144,15 +145,15 @@ public String getName() {
* this particular architecture instance. The index of each register in this list is equal to
* its {@linkplain Register#number number}.
*/
public RegisterArray getRegisters() {
public List<Register> getRegisters() {
return registers;
}

/**
* Gets a list of all registers available for storing values on this architecture. This may be a
* subset of {@link #getRegisters()}, depending on the capabilities of this particular CPU.
*/
public RegisterArray getAvailableValueRegisters() {
public List<Register> getAvailableValueRegisters() {
return getRegisters();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -27,6 +27,8 @@
import jdk.vm.ci.meta.AllocatableValue;
import jdk.vm.ci.meta.Value;

import java.util.List;

/**
* A calling convention describes the locations in which the arguments for a call are placed and the
* location in which the return value is placed if the call is not void.
Expand All @@ -49,7 +51,7 @@ public interface Type {
/**
* The ordered locations in which the arguments are placed.
*/
private final AllocatableValue[] argumentLocations;
private final List<AllocatableValue> argumentLocations;

/**
* Creates a description of the registers and stack locations used by a call.
Expand All @@ -63,7 +65,7 @@ public interface Type {
public CallingConvention(int stackSize, AllocatableValue returnLocation, AllocatableValue... argumentLocations) {
assert argumentLocations != null;
assert returnLocation != null;
this.argumentLocations = argumentLocations;
this.argumentLocations = List.of(argumentLocations);
this.stackSize = stackSize;
this.returnLocation = returnLocation;
assert verify();
Expand All @@ -80,7 +82,7 @@ public AllocatableValue getReturn() {
* Gets the location for the {@code index}'th argument.
*/
public AllocatableValue getArgument(int index) {
return argumentLocations[index];
return argumentLocations.get(index);
}

/**
Expand All @@ -94,18 +96,14 @@ public int getStackSize() {
* Gets the number of locations required for the arguments.
*/
public int getArgumentCount() {
return argumentLocations.length;
return argumentLocations.size();
}

/**
* Gets the locations required for the arguments.
*/
@SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "FB false positive")
public AllocatableValue[] getArguments() {
if (argumentLocations.length == 0) {
return argumentLocations;
}
return argumentLocations.clone();
public List<AllocatableValue> getArguments() {
return argumentLocations;
}

@Override
Expand All @@ -125,8 +123,8 @@ public String toString() {
}

private boolean verify() {
for (int i = 0; i < argumentLocations.length; i++) {
Value location = argumentLocations[i];
for (int i = 0; i < argumentLocations.size(); i++) {
Value location = argumentLocations.get(i);
assert isStackSlot(location) || isAllocatableValue(location);
}
return true;
Expand Down
Loading