1 /* 2 * Copyright (c) 2014, 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 24 package org.graalvm.compiler.hotspot.aarch64; 25 26 import org.graalvm.compiler.core.common.spi.ForeignCallsProvider; 27 import org.graalvm.compiler.debug.DebugHandlersFactory; 28 import org.graalvm.compiler.graph.Node; 29 import org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider; 30 import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig; 31 import org.graalvm.compiler.hotspot.meta.DefaultHotSpotLoweringProvider; 32 import org.graalvm.compiler.hotspot.meta.HotSpotProviders; 33 import org.graalvm.compiler.hotspot.meta.HotSpotRegistersProvider; 34 import org.graalvm.compiler.nodes.calc.FixedBinaryNode; 35 import org.graalvm.compiler.nodes.calc.FloatConvertNode; 36 import org.graalvm.compiler.nodes.calc.RemNode; 37 import org.graalvm.compiler.nodes.spi.LoweringTool; 38 import org.graalvm.compiler.options.OptionValues; 39 import org.graalvm.compiler.replacements.aarch64.AArch64FloatArithmeticSnippets; 40 import org.graalvm.compiler.replacements.aarch64.AArch64IntegerArithmeticSnippets; 41 42 import jdk.vm.ci.code.TargetDescription; 43 import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; 44 import jdk.vm.ci.meta.MetaAccessProvider; 45 46 public class AArch64HotSpotLoweringProvider extends DefaultHotSpotLoweringProvider { 47 48 private AArch64IntegerArithmeticSnippets integerArithmeticSnippets; 49 private AArch64FloatArithmeticSnippets floatArithmeticSnippets; 50 51 public AArch64HotSpotLoweringProvider(HotSpotGraalRuntimeProvider runtime, MetaAccessProvider metaAccess, ForeignCallsProvider foreignCalls, HotSpotRegistersProvider registers, 52 HotSpotConstantReflectionProvider constantReflection, TargetDescription target) { 53 super(runtime, metaAccess, foreignCalls, registers, constantReflection, target); 54 } 55 56 @Override 57 public void initialize(OptionValues options, Iterable<DebugHandlersFactory> factories, HotSpotProviders providers, GraalHotSpotVMConfig config) { 58 integerArithmeticSnippets = new AArch64IntegerArithmeticSnippets(options, factories, providers, providers.getSnippetReflection(), providers.getCodeCache().getTarget()); 59 floatArithmeticSnippets = new AArch64FloatArithmeticSnippets(options, factories, providers, providers.getSnippetReflection(), providers.getCodeCache().getTarget()); 60 super.initialize(options, factories, providers, config); 61 } 62 63 @Override 64 public void lower(Node n, LoweringTool tool) { 65 if (n instanceof FixedBinaryNode) { 66 integerArithmeticSnippets.lower((FixedBinaryNode) n, tool); 67 } else if (n instanceof RemNode) { 68 floatArithmeticSnippets.lower((RemNode) n, tool); 69 } else if (n instanceof FloatConvertNode) { 70 // AMD64 has custom lowerings for ConvertNodes, HotSpotLoweringProvider does not expect 71 // to see a ConvertNode and throws an error, just do nothing here. 72 } else { 73 super.lower(n, tool); 74 } 75 } 76 }