Mercurial > hg > graal-compiler
changeset 9189:0331f7512be2
CPU capability detection.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Thu, 18 Apr 2013 16:25:08 +0200 |
parents | fb676e23ba51 |
children | 50d87c79f831 700f6a63763a |
files | graal/com.oracle.graal.amd64/src/com/oracle/graal/amd64/AMD64.java graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Architecture.java graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java src/share/vm/graal/graalCompilerToVM.cpp |
diffstat | 5 files changed, 81 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.amd64/src/com/oracle/graal/amd64/AMD64.java Thu Apr 18 13:16:39 2013 +0200 +++ b/graal/com.oracle.graal.amd64/src/com/oracle/graal/amd64/AMD64.java Thu Apr 18 16:25:08 2013 +0200 @@ -29,6 +29,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.Register.RegisterFlag; +import com.oracle.graal.api.meta.*; /** * Represents the AMD64 architecture. @@ -105,7 +106,10 @@ rip }; - public AMD64() { + private final int useSSE; + private final int useAVX; + + public AMD64(int useSSE, int useAVX) { super("AMD64", 8, ByteOrder.LITTLE_ENDIAN, @@ -114,6 +118,65 @@ 1, r15.encoding + 1, 8); + assert useSSE >= 2; + this.useSSE = useSSE; + this.useAVX = useAVX; } // @formatter:on + + @Override + public int getMaxVectorLength(Kind kind) { + if (useAVX > 0) { + switch (kind) { + case Boolean: + return 32; + case Byte: + return 32; + case Short: + return 16; + case Char: + return 16; + case Int: + return 8; + case Float: + return 8; + case Long: + return 4; + case Double: + return 4; + case Object: + return 4; + } + } else { + switch (kind) { + case Boolean: + return 16; + case Byte: + return 16; + case Short: + return 8; + case Char: + return 8; + case Int: + return 4; + case Float: + return 4; + case Long: + return 2; + case Double: + return 2; + case Object: + return 2; + } + } + return 1; + } + + public int getSSE() { + return useSSE; + } + + public int getAVX() { + return useAVX; + } }
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Architecture.java Thu Apr 18 13:16:39 2013 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Architecture.java Thu Apr 18 16:25:08 2013 +0200 @@ -24,6 +24,8 @@ import java.nio.*; +import com.oracle.graal.api.meta.*; + /** * Represents a CPU architecture, including information such as its endianness, CPU registers, word * width, etc. @@ -154,4 +156,12 @@ public final int requiredBarriers(int barriers) { return barriers & ~implicitMemoryBarriers; } + + /** + * Determine the maximum vector length supported for vector operations on values of a given + * {@link Kind}. + */ + public int getMaxVectorLength(@SuppressWarnings("unused") Kind kind) { + return 1; + } }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntime.java Thu Apr 18 13:16:39 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntime.java Thu Apr 18 16:25:08 2013 +0200 @@ -49,7 +49,7 @@ protected TargetDescription createTarget() { final int stackFrameAlignment = 16; final int implicitNullCheckLimit = 4096; - return new TargetDescription(new AMD64(), true, stackFrameAlignment, implicitNullCheckLimit, true); + return new TargetDescription(new AMD64(config.useSSE, config.useAVX), true, stackFrameAlignment, implicitNullCheckLimit, true); } @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Thu Apr 18 13:16:39 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Thu Apr 18 16:25:08 2013 +0200 @@ -49,6 +49,10 @@ public boolean useAESIntrinsics; public boolean useG1GC; + // CPU capabilities + public int useSSE; + public int useAVX; + // offsets, ... public int stackShadowPages;
--- a/src/share/vm/graal/graalCompilerToVM.cpp Thu Apr 18 13:16:39 2013 +0200 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Thu Apr 18 16:25:08 2013 +0200 @@ -643,6 +643,8 @@ set_boolean("useAESIntrinsics", UseAESIntrinsics); set_boolean("useTLAB", UseTLAB); set_boolean("useG1GC", UseG1GC); + set_int("useSSE", UseSSE); + set_int("useAVX", UseAVX); set_int("codeEntryAlignment", CodeEntryAlignment); set_int("stackShadowPages", StackShadowPages); set_int("hubOffset", oopDesc::klass_offset_in_bytes());