Skip to content
Merged
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
3 changes: 2 additions & 1 deletion compiler/mx.compiler/mx_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,8 @@ def compiler_gate_benchmark_runner(tasks, extraVMarguments=None, prefix=''):

_registers = {
'amd64': 'rbx,r11,r10,r14,xmm3,xmm2,xmm11,xmm14,k1?',
'aarch64': 'r0,r1,r2,r3,r4,v0,v1,v2,v3'
'aarch64': 'r0,r1,r2,r3,r4,v0,v1,v2,v3',
'riscv64': 'x10,x11,x12,x13,x14,v10,v11,v12,v13'
}
if mx.get_arch() not in _registers:
mx.warn('No registers for register pressure tests are defined for architecture ' + mx.get_arch())
Expand Down
43 changes: 43 additions & 0 deletions compiler/mx.compiler/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@
"digest" : "sha512:422e1078fe5d9e2f71c04ca2bbefef4e09cf9675d132c7531f1fb17330e2b1f9441470541b66c8db2f3d8e105d167e25a78dc11aada524ed623b1ae9a4cfdeeb",
"urls" : ["{urlbase}/hsdis-aarch64-linux-fcc9b70ac91c00db8a50b0d4345490a68e3743e1.tar.gz"],
},
"riscv64" : {
"optional" : True,
}
},
"darwin" : {
"amd64" : {
Expand Down Expand Up @@ -681,6 +684,27 @@
"workingSets" : "Graal,HotSpot,AMD64",
},

"org.graalvm.compiler.hotspot.riscv64" : {
"subDir" : "src",
"sourceDirs" : ["src"],
"dependencies" : [
"org.graalvm.compiler.core.riscv64",
"org.graalvm.compiler.hotspot",
],
"requiresConcealed" : {
"jdk.internal.vm.ci" : [
"jdk.vm.ci.meta",
"jdk.vm.ci.code",
],
},
"checkstyle" : "org.graalvm.compiler.graph",
"annotationProcessors" : [
"GRAAL_PROCESSOR"
],
"javaCompliance" : "11+",
"workingSets" : "Graal,HotSpot,RISCV64",
},

"org.graalvm.compiler.hotspot.test" : {
"subDir" : "src",
"sourceDirs" : ["src"],
Expand Down Expand Up @@ -1389,6 +1413,20 @@
"workingSets" : "Graal,AMD64,Test",
},

"org.graalvm.compiler.core.riscv64" : {
"subDir" : "src",
"sourceDirs" : ["src"],
"dependencies" : [
"org.graalvm.compiler.core",
],
"checkstyle" : "org.graalvm.compiler.graph",
"annotationProcessors" : [
"GRAAL_PROCESSOR",
],
"javaCompliance" : "11+",
"workingSets" : "Graal,RISCV64",
},

"org.graalvm.compiler.runtime" : {
"subDir" : "src",
"sourceDirs" : ["src"],
Expand Down Expand Up @@ -2110,8 +2148,10 @@
"org.graalvm.compiler.replacements.aarch64",
"org.graalvm.compiler.core.amd64",
"org.graalvm.compiler.replacements.amd64",
"org.graalvm.compiler.core.riscv64",
"org.graalvm.compiler.hotspot.aarch64",
"org.graalvm.compiler.hotspot.amd64",
"org.graalvm.compiler.hotspot.riscv64",
"org.graalvm.compiler.hotspot",
"org.graalvm.compiler.lir.aarch64",
"org.graalvm.compiler.truffle.runtime.serviceprovider",
Expand Down Expand Up @@ -2187,6 +2227,9 @@
"description" : "Disassembler support distribution for the GraalVM",
"os_arch" : {
"linux" : {
"riscv64" : {
"optional" : True,
},
"<others>" : {
"layout" : {
"hsdis-<arch>.so" : "file:<path:HSDIS>/*",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2022, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package org.graalvm.compiler.core.riscv64;

import org.graalvm.compiler.core.common.memory.MemoryExtendKind;
import org.graalvm.compiler.nodes.memory.ExtendableMemoryAccess;
import org.graalvm.compiler.nodes.spi.LoweringProvider;

public interface RISCV64LoweringProviderMixin extends LoweringProvider {

@Override
default boolean divisionOverflowIsJVMSCompliant() {
return true;
}

@Override
default Integer smallestCompareWidth() {
return 32;
}

@Override
default boolean supportsBulkZeroing() {
return false;
}

@Override
default boolean supportsRounding() {
return false;
}

@Override
default boolean writesStronglyOrdered() {
return false;
}

@Override
default boolean narrowsUseCastValue() {
return false;
}

@Override
default boolean supportsFoldingExtendIntoAccess(ExtendableMemoryAccess access, MemoryExtendKind extendKind) {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2022, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package org.graalvm.compiler.core.riscv64;

import org.graalvm.compiler.core.gen.NodeMatchRules;
import org.graalvm.compiler.lir.gen.LIRGeneratorTool;

public class RISCV64NodeMatchRules extends NodeMatchRules {
public RISCV64NodeMatchRules(LIRGeneratorTool gen) {
super(gen);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* Copyright (c) 2022, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package org.graalvm.compiler.core.riscv64;

import java.lang.reflect.Method;

/**
* This class contains utility methods for accessing RISC-V JVMCI classes and fields using
* reflection. This is needed as all JDK versions used by Graal currently do not implement JVMCI for
* RISC-V, which causes unwanted build errors.
*/
public class RISCV64ReflectionUtil {
public static final String archClass = "jdk.vm.ci.riscv64.RISCV64";
public static final String featureClass = archClass + "$CPUFeature";
public static final String flagClass = archClass + "$Flag";
public static final String hotSpotClass = "jdk.vm.ci.hotspot.riscv64.RISCV64HotSpotRegisterConfig";

public static Class<?> lookupClass(boolean optional, String className) {
try {
return Class.forName(className);
} catch (ClassNotFoundException ex) {
if (optional) {
return null;
}
throw new ReflectionUtilError(ex);
}
}

public static Class<?> getArch(boolean optional) {
return lookupClass(optional, archClass);
}

@SuppressWarnings("unchecked")
public static <T> T readStaticField(Class<?> declaringClass, String fieldName) {
try {
return (T) declaringClass.getField(fieldName).get(null);
} catch (ReflectiveOperationException ex) {
throw new ReflectionUtilError(ex);
}
}

@SuppressWarnings("serial")
public static final class ReflectionUtilError extends Error {
private ReflectionUtilError(Throwable cause) {
super(cause);
}
}

public static Method lookupMethod(Class<?> declaringClass, String methodName, Class<?>... parameterTypes) {
try {
return declaringClass.getDeclaredMethod(methodName, parameterTypes);
} catch (ReflectiveOperationException ex) {
throw new ReflectionUtilError(ex);
}
}

public static Object invokeMethod(Method method, Object obj, Object... args) {
try {
return method.invoke(obj, args);
} catch (ReflectiveOperationException ex) {
throw new ReflectionUtilError(ex);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
* Copyright (c) 2022, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package org.graalvm.compiler.core.riscv64;

import jdk.vm.ci.code.Architecture;
import jdk.vm.ci.code.Register;
import jdk.vm.ci.code.RegisterArray;

public class ShadowedRISCV64 {
public static final Class<?> riscv64OrNull = RISCV64ReflectionUtil.getArch(true);

public static final Register x0 = getRegister("x0");
public static final Register x1 = getRegister("x1");
public static final Register x2 = getRegister("x2");
public static final Register x3 = getRegister("x3");
public static final Register x4 = getRegister("x4");
public static final Register x5 = getRegister("x5");
public static final Register x6 = getRegister("x6");
public static final Register x7 = getRegister("x7");
public static final Register x8 = getRegister("x8");
public static final Register x9 = getRegister("x9");
public static final Register x10 = getRegister("x10");
public static final Register x11 = getRegister("x11");
public static final Register x12 = getRegister("x12");
public static final Register x13 = getRegister("x13");
public static final Register x14 = getRegister("x14");
public static final Register x15 = getRegister("x15");
public static final Register x16 = getRegister("x16");
public static final Register x17 = getRegister("x17");
public static final Register x18 = getRegister("x18");
public static final Register x19 = getRegister("x19");
public static final Register x20 = getRegister("x20");
public static final Register x21 = getRegister("x21");
public static final Register x22 = getRegister("x22");
public static final Register x23 = getRegister("x23");
public static final Register x24 = getRegister("x24");
public static final Register x25 = getRegister("x25");
public static final Register x26 = getRegister("x26");
public static final Register x27 = getRegister("x27");
public static final Register x28 = getRegister("x28");
public static final Register x29 = getRegister("x29");
public static final Register x30 = getRegister("x30");
public static final Register x31 = getRegister("x31");

public static final Register f0 = getRegister("f0");
public static final Register f1 = getRegister("f1");
public static final Register f2 = getRegister("f2");
public static final Register f3 = getRegister("f3");
public static final Register f4 = getRegister("f4");
public static final Register f5 = getRegister("f5");
public static final Register f6 = getRegister("f6");
public static final Register f7 = getRegister("f7");
public static final Register f8 = getRegister("f8");
public static final Register f9 = getRegister("f9");
public static final Register f10 = getRegister("f10");
public static final Register f11 = getRegister("f11");
public static final Register f12 = getRegister("f12");
public static final Register f13 = getRegister("f13");
public static final Register f14 = getRegister("f14");
public static final Register f15 = getRegister("f15");
public static final Register f16 = getRegister("f16");
public static final Register f17 = getRegister("f17");
public static final Register f18 = getRegister("f18");
public static final Register f19 = getRegister("f19");
public static final Register f20 = getRegister("f20");
public static final Register f21 = getRegister("f21");
public static final Register f22 = getRegister("f22");
public static final Register f23 = getRegister("f23");
public static final Register f24 = getRegister("f24");
public static final Register f25 = getRegister("f25");
public static final Register f26 = getRegister("f26");
public static final Register f27 = getRegister("f27");
public static final Register f28 = getRegister("f28");
public static final Register f29 = getRegister("f29");
public static final Register f30 = getRegister("f30");
public static final Register f31 = getRegister("f31");

public static final RegisterArray allRegisters = riscv64OrNull == null ? null : RISCV64ReflectionUtil.readStaticField(riscv64OrNull, "allRegisters");

public static boolean instanceOf(Architecture arch) {
return ShadowedRISCV64.riscv64OrNull != null && ShadowedRISCV64.riscv64OrNull.isInstance(arch);
}

private static Register getRegister(String register) {
return riscv64OrNull == null ? null : RISCV64ReflectionUtil.readStaticField(riscv64OrNull, register);
}
}
Loading