Mercurial > hg > graal-jvmci-8
changeset 22604:479228019e48
[SPARC] Remove JavaKind dependency
author | Stefan Anzinger <stefan.anzinger@oracle.com> |
---|---|
date | Wed, 23 Sep 2015 15:43:53 +0200 |
parents | 2448e3c0cd98 |
children | f0ec628cb987 |
files | jvmci/jdk.internal.jvmci.hotspot.sparc/src/jdk/internal/jvmci/hotspot/sparc/SPARCHotSpotRegisterConfig.java jvmci/jdk.internal.jvmci.sparc/src/jdk/internal/jvmci/sparc/SPARC.java jvmci/jdk.internal.jvmci.sparc/src/jdk/internal/jvmci/sparc/SPARCKind.java |
diffstat | 3 files changed, 158 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/jvmci/jdk.internal.jvmci.hotspot.sparc/src/jdk/internal/jvmci/hotspot/sparc/SPARCHotSpotRegisterConfig.java Tue Sep 22 23:14:18 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot.sparc/src/jdk/internal/jvmci/hotspot/sparc/SPARCHotSpotRegisterConfig.java Wed Sep 23 15:43:53 2015 +0200 @@ -22,7 +22,6 @@ */ package jdk.internal.jvmci.hotspot.sparc; -import static jdk.internal.jvmci.sparc.SPARC.CPU; import static jdk.internal.jvmci.sparc.SPARC.FPUd; import static jdk.internal.jvmci.sparc.SPARC.FPUs; import static jdk.internal.jvmci.sparc.SPARC.d0; @@ -129,6 +128,7 @@ import jdk.internal.jvmci.meta.PlatformKind; import jdk.internal.jvmci.meta.Value; import jdk.internal.jvmci.sparc.SPARC; +import jdk.internal.jvmci.sparc.SPARCKind; public class SPARCHotSpotRegisterConfig implements RegisterConfig { @@ -149,11 +149,11 @@ if (architecture.canStoreValue(reg.getRegisterCategory(), kind)) { // Special treatment for double precision // TODO: This is wasteful it uses only half of the registers as float. - if (kind == JavaKind.Double) { + if (kind == SPARCKind.DOUBLE) { if (reg.getRegisterCategory().equals(FPUd)) { list.add(reg); } - } else if (kind == JavaKind.Float) { + } else if (kind == SPARCKind.SINGLE) { if (reg.getRegisterCategory().equals(FPUs)) { list.add(reg); } @@ -279,11 +279,21 @@ } public Register[] getCallingConventionRegisters(Type type, JavaKind kind) { - if (architecture.canStoreValue(FPUs, kind) || architecture.canStoreValue(FPUd, kind)) { - return fpuParameterRegisters; + switch (kind) { + case Boolean: + case Byte: + case Short: + case Char: + case Int: + case Long: + case Object: + return type == Type.JavaCallee ? cpuCalleeParameterRegisters : cpuCallerParameterRegisters; + case Double: + case Float: + return fpuParameterRegisters; + default: + throw JVMCIError.shouldNotReachHere("Unknown JavaKind " + kind); } - assert architecture.canStoreValue(CPU, kind) : kind; - return type == Type.JavaCallee ? cpuCalleeParameterRegisters : cpuCallerParameterRegisters; } private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, Type type, TargetDescription target, boolean stackOnly) {
--- a/jvmci/jdk.internal.jvmci.sparc/src/jdk/internal/jvmci/sparc/SPARC.java Tue Sep 22 23:14:18 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.sparc/src/jdk/internal/jvmci/sparc/SPARC.java Wed Sep 23 15:43:53 2015 +0200 @@ -256,31 +256,17 @@ public final Set<CPUFeature> features; public SPARC(Set<CPUFeature> features) { - super("SPARC", JavaKind.Long, BIG_ENDIAN, false, allRegisters, LOAD_LOAD | LOAD_STORE | STORE_STORE, 1, r31.encoding + FLOAT_REGISTER_COUNT + 1, 8); + super("SPARC", SPARCKind.DWORD, BIG_ENDIAN, false, allRegisters, LOAD_LOAD | LOAD_STORE | STORE_STORE, 1, r31.encoding + FLOAT_REGISTER_COUNT + 1, 8); this.features = features; } @Override - public boolean canStoreValue(RegisterCategory category, PlatformKind lirKind) { - if (!(lirKind instanceof JavaKind)) { - return false; - } - - JavaKind kind = (JavaKind) lirKind; + public boolean canStoreValue(RegisterCategory category, PlatformKind kind) { if (category.equals(CPU)) { - switch (kind) { - case Object: - case Boolean: - case Byte: - case Char: - case Short: - case Int: - case Long: - return true; - } - } else if (category.equals(FPUs) && kind.equals(JavaKind.Float)) { + return ((SPARCKind) kind).isInteger(); + } else if (category.equals(FPUs) && kind == SPARCKind.SINGLE) { return true; - } else if (category.equals(FPUd) && kind.equals(JavaKind.Double)) { + } else if (category.equals(FPUd) && kind == SPARCKind.DOUBLE) { return true; } return false; @@ -289,22 +275,36 @@ @Override public PlatformKind getLargestStorableKind(RegisterCategory category) { if (category.equals(CPU)) { - return JavaKind.Long; + return SPARCKind.DWORD; } else if (category.equals(FPUd)) { - return JavaKind.Double; + return SPARCKind.DOUBLE; } else if (category.equals(FPUs)) { - return JavaKind.Float; + return SPARCKind.SINGLE; } else { - return JavaKind.Illegal; + throw new IllegalArgumentException("Unknown register category: " + category); } } @Override public PlatformKind getPlatformKind(JavaKind javaKind) { - if (javaKind.isObject()) { - return JavaKind.Long; - } else { - return javaKind; + switch (javaKind) { + case Boolean: + case Byte: + return SPARCKind.BYTE; + case Short: + case Char: + return SPARCKind.HWORD; + case Int: + return SPARCKind.WORD; + case Long: + case Object: + return SPARCKind.DWORD; + case Float: + return SPARCKind.SINGLE; + case Double: + return SPARCKind.DOUBLE; + default: + throw new IllegalArgumentException("Unknown JavaKind: " + javaKind); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jvmci/jdk.internal.jvmci.sparc/src/jdk/internal/jvmci/sparc/SPARCKind.java Wed Sep 23 15:43:53 2015 +0200 @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2015, 2015, 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. + * + * 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 jdk.internal.jvmci.sparc; + +import jdk.internal.jvmci.meta.PlatformKind; + +public enum SPARCKind implements PlatformKind { + BYTE(1), + HWORD(2), + WORD(4), + DWORD(8), + SINGLE(4), + DOUBLE(8), + + V64_BYTE(8, BYTE), + V64_HWORD(8, HWORD), + V64_WORD(8, WORD); + + private final int size; + private final int vectorLength; + + private final SPARCKind scalar; + private final EnumKey<SPARCKind> key = new EnumKey<>(this); + + private SPARCKind(int size) { + this.size = size; + this.scalar = this; + this.vectorLength = 1; + } + + private SPARCKind(int size, SPARCKind scalar) { + this.size = size; + this.scalar = scalar; + + assert size % scalar.size == 0; + this.vectorLength = size / scalar.size; + } + + public SPARCKind getScalar() { + return scalar; + } + + public int getSizeInBytes() { + return size; + } + + public int getSizeInBits() { + return getSizeInBytes() * 8; + } + + public int getVectorLength() { + return vectorLength; + } + + public Key getKey() { + return key; + } + + public boolean isInteger() { + switch (this) { + case BYTE: + case HWORD: + case WORD: + case DWORD: + return true; + default: + return false; + } + } + + public boolean isFloat() { + return !isInteger(); + } + + public char getTypeChar() { + switch (this) { + case BYTE: + return 'b'; + case WORD: + return 'w'; + case DWORD: + return 'd'; + case SINGLE: + return 'S'; + case DOUBLE: + case V64_BYTE: + case V64_HWORD: + case V64_WORD: + return 'D'; + default: + return '-'; + } + } +}