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