1 /* 2 * Copyright (c) 2012, 2015, 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.inittimer.InitTimer.*; 26 27 import java.util.*; 28 29 import jdk.vm.ci.code.*; 30 import jdk.vm.ci.compiler.*; 31 import jdk.vm.ci.hotspot.*; 32 import jdk.vm.ci.inittimer.*; 33 import jdk.vm.ci.runtime.*; 34 import jdk.vm.ci.service.*; 35 import jdk.vm.ci.sparc.*; 36 import jdk.vm.ci.sparc.SPARC.CPUFeature; 37 38 @ServiceProvider(HotSpotJVMCIBackendFactory.class) 39 public class SPARCHotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { 40 41 protected TargetDescription createTarget(HotSpotVMConfig config, CompilerFactory compilerFactory) { 42 final int stackFrameAlignment = 16; 43 final int implicitNullCheckLimit = 4096; 44 final boolean inlineObjects = false; 45 Architecture arch = new SPARC(computeFeatures(config)); 46 return new TargetDescription(compilerFactory.initializeArchitecture(arch), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); 47 } 48 49 protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { 50 return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); 51 } 52 53 protected EnumSet<CPUFeature> computeFeatures(HotSpotVMConfig config) { 54 EnumSet<CPUFeature> features = EnumSet.noneOf(CPUFeature.class); 55 if ((config.sparcFeatures & config.vis1Instructions) != 0) { 56 features.add(CPUFeature.VIS1); 57 } 58 if ((config.sparcFeatures & config.vis2Instructions) != 0) { 59 features.add(CPUFeature.VIS2); 60 } 61 if ((config.sparcFeatures & config.vis3Instructions) != 0) { 62 features.add(CPUFeature.VIS3); 63 } 64 if ((config.sparcFeatures & config.cbcondInstructions) != 0) { 65 features.add(CPUFeature.CBCOND); 66 } 67 if (config.useBlockZeroing) { 68 features.add(CPUFeature.BLOCK_ZEROING); 69 } 70 return features; 71 } 72 73 @Override 74 public String getArchitecture() { 75 return "SPARC"; 76 } 77 78 @Override 79 public String toString() { 80 return "JVMCIBackend:" + getArchitecture(); 81 } 82 83 @SuppressWarnings("try") 84 public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, CompilerFactory compilerFactory, JVMCIBackend host) { 85 assert host == null; 86 TargetDescription target = createTarget(runtime.getConfig(), compilerFactory); 87 88 HotSpotMetaAccessProvider metaAccess = new HotSpotMetaAccessProvider(runtime); 89 RegisterConfig regConfig = new SPARCHotSpotRegisterConfig(target, runtime.getConfig()); 90 HotSpotCodeCacheProvider codeCache = createCodeCache(runtime, target, regConfig); 91 HotSpotConstantReflectionProvider constantReflection = new HotSpotConstantReflectionProvider(runtime); 92 try (InitTimer rt = timer("instantiate backend")) { 93 return createBackend(metaAccess, codeCache, constantReflection); 94 } 95 } 96 97 protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, HotSpotConstantReflectionProvider constantReflection) { 98 return new JVMCIBackend(metaAccess, codeCache, constantReflection); 99 } 100 }