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