1 /* 2 * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package jdk.vm.ci.hotspot.sparc; 24 25 import static jdk.vm.ci.common.InitTimer.timer; 26 27 import java.util.EnumSet; 28 29 import jdk.vm.ci.code.Architecture; 30 import jdk.vm.ci.code.RegisterConfig; 31 import jdk.vm.ci.code.TargetDescription; 32 import jdk.vm.ci.code.stack.StackIntrospection; 33 import jdk.vm.ci.common.InitTimer; 34 import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; 35 import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; 36 import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; 37 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider; 38 import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; 39 import jdk.vm.ci.hotspot.HotSpotStackIntrospection; 40 import jdk.vm.ci.runtime.JVMCIBackend; 41 import jdk.vm.ci.sparc.SPARC; 42 import jdk.vm.ci.sparc.SPARC.CPUFeature; 43 44 public class SPARCHotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { 45 46 protected TargetDescription createTarget(SPARCHotSpotVMConfig config) { 47 final int stackFrameAlignment = 16; 48 final int implicitNullCheckLimit = 4096; 49 final boolean inlineObjects = false; 50 Architecture arch = new SPARC(computeFeatures(config)); 51 return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); 52 } 53 54 protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { 55 return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); 56 } 57 58 protected EnumSet<CPUFeature> computeFeatures(SPARCHotSpotVMConfig config) { 59 EnumSet<CPUFeature> features = EnumSet.noneOf(CPUFeature.class); 60 61 if ((config.vmVersionFeatures & 1L << config.sparc_ADI) != 0) { 62 features.add(CPUFeature.ADI); 63 } 64 if ((config.vmVersionFeatures & 1L << config.sparc_AES) != 0) { 65 features.add(CPUFeature.AES); 66 } 67 if ((config.vmVersionFeatures & 1L << config.sparc_BLK_INIT) != 0) { 68 features.add(CPUFeature.BLK_INIT); 69 } 70 if ((config.vmVersionFeatures & 1L << config.sparc_CAMELLIA) != 0) { 71 features.add(CPUFeature.CAMELLIA); 72 } 73 if ((config.vmVersionFeatures & 1L << config.sparc_CBCOND) != 0) { 74 features.add(CPUFeature.CBCOND); 75 } 76 if ((config.vmVersionFeatures & 1L << config.sparc_CRC32C) != 0) { 77 features.add(CPUFeature.CRC32C); 78 } 79 if ((config.vmVersionFeatures & 1L << config.sparc_DES) != 0) { 80 features.add(CPUFeature.DES); 81 } 82 if ((config.vmVersionFeatures & 1L << config.sparc_FMAF) != 0) { 83 features.add(CPUFeature.FMAF); 84 } 85 if ((config.vmVersionFeatures & 1L << config.sparc_HPC) != 0) { 86 features.add(CPUFeature.HPC); 87 } 88 if ((config.vmVersionFeatures & 1L << config.sparc_IMA) != 0) { 89 features.add(CPUFeature.IMA); 90 } 91 if ((config.vmVersionFeatures & 1L << config.sparc_KASUMI) != 0) { 92 features.add(CPUFeature.KASUMI); 93 } 94 if ((config.vmVersionFeatures & 1L << config.sparc_MD5) != 0) { 95 features.add(CPUFeature.MD5); 96 } 97 if ((config.vmVersionFeatures & 1L << config.sparc_MONT) != 0) { 98 features.add(CPUFeature.MONT); 99 } 100 if ((config.vmVersionFeatures & 1L << config.sparc_MPMUL) != 0) { 101 features.add(CPUFeature.MPMUL); 102 } 103 if ((config.vmVersionFeatures & 1L << config.sparc_MWAIT) != 0) { 104 features.add(CPUFeature.MWAIT); 105 } 106 if ((config.vmVersionFeatures & 1L << config.sparc_PAUSE) != 0) { 107 features.add(CPUFeature.PAUSE); 108 } 109 if ((config.vmVersionFeatures & 1L << config.sparc_PAUSE_NSEC) != 0) { 110 features.add(CPUFeature.PAUSE_NSEC); 111 } 112 if ((config.vmVersionFeatures & 1L << config.sparc_POPC) != 0) { 113 features.add(CPUFeature.POPC); 114 } 115 if ((config.vmVersionFeatures & 1L << config.sparc_SHA1) != 0) { 116 features.add(CPUFeature.SHA1); 117 } 118 if ((config.vmVersionFeatures & 1L << config.sparc_SHA256) != 0) { 119 features.add(CPUFeature.SHA256); 120 } 121 if ((config.vmVersionFeatures & 1L << config.sparc_SHA512) != 0) { 122 features.add(CPUFeature.SHA512); 123 } 124 if ((config.vmVersionFeatures & 1L << config.sparc_SPARC5) != 0) { 125 features.add(CPUFeature.SPARC5); 126 } 127 if ((config.vmVersionFeatures & 1L << config.sparc_V9) != 0) { 128 features.add(CPUFeature.V9); 129 } 130 if ((config.vmVersionFeatures & 1L << config.sparc_VAMASK) != 0) { 131 features.add(CPUFeature.VAMASK); 132 } 133 if ((config.vmVersionFeatures & 1L << config.sparc_VIS1) != 0) { 134 features.add(CPUFeature.VIS1); 135 } 136 if ((config.vmVersionFeatures & 1L << config.sparc_VIS2) != 0) { 137 features.add(CPUFeature.VIS2); 138 } 139 if ((config.vmVersionFeatures & 1L << config.sparc_VIS3) != 0) { 140 features.add(CPUFeature.VIS3); 141 } 142 if ((config.vmVersionFeatures & 1L << config.sparc_VIS3B) != 0) { 143 features.add(CPUFeature.VIS3B); 144 } 145 if ((config.vmVersionFeatures & 1L << config.sparc_XMONT) != 0) { 146 features.add(CPUFeature.XMONT); 147 } 148 if ((config.vmVersionFeatures & 1L << config.sparc_XMPMUL) != 0) { 149 features.add(CPUFeature.XMPMUL); 150 } 151 152 if ((config.vmVersionFeatures & 1L << config.sparc_BLK_ZEROING) != 0) { 153 features.add(CPUFeature.BLK_ZEROING); 154 } 155 if ((config.vmVersionFeatures & 1L << config.sparc_FAST_BIS) != 0) { 156 features.add(CPUFeature.FAST_BIS); 157 } 158 if ((config.vmVersionFeatures & 1L << config.sparc_FAST_CMOVE) != 0) { 159 features.add(CPUFeature.FAST_CMOVE); 160 } 161 if ((config.vmVersionFeatures & 1L << config.sparc_FAST_IDIV) != 0) { 162 features.add(CPUFeature.FAST_IDIV); 163 } 164 if ((config.vmVersionFeatures & 1L << config.sparc_FAST_IND_BR) != 0) { 165 features.add(CPUFeature.FAST_IND_BR); 166 } 167 if ((config.vmVersionFeatures & 1L << config.sparc_FAST_LD) != 0) { 168 features.add(CPUFeature.FAST_LD); 169 } 170 if ((config.vmVersionFeatures & 1L << config.sparc_FAST_RDPC) != 0) { 171 features.add(CPUFeature.FAST_RDPC); 172 } 173 174 return features; 175 } 176 177 @Override 178 public String getArchitecture() { 179 return "SPARC"; 180 } 181 182 @Override 183 public String toString() { 184 return "JVMCIBackend:" + getArchitecture(); 185 } 186 187 @SuppressWarnings("try") 188 public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) { 189 assert host == null; 190 SPARCHotSpotVMConfig config = new SPARCHotSpotVMConfig(runtime.getConfigStore()); 191 TargetDescription target = createTarget(config); 192 193 HotSpotMetaAccessProvider metaAccess = new HotSpotMetaAccessProvider(runtime); 194 RegisterConfig regConfig = new SPARCHotSpotRegisterConfig(target, config.useCompressedOops); 195 HotSpotCodeCacheProvider codeCache = createCodeCache(runtime, target, regConfig); 196 HotSpotConstantReflectionProvider constantReflection = new HotSpotConstantReflectionProvider(runtime); 197 StackIntrospection stackIntrospection = new HotSpotStackIntrospection(runtime); 198 try (InitTimer rt = timer("instantiate backend")) { 199 return createBackend(metaAccess, codeCache, constantReflection, stackIntrospection); 200 } 201 } 202 203 protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, HotSpotConstantReflectionProvider constantReflection, 204 StackIntrospection stackIntrospection) { 205 return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection); 206 } 207 }