1 /* |
1 /* |
2 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
30 import static org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.LOG; |
30 import static org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.LOG; |
31 import static org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.LOG10; |
31 import static org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.LOG10; |
32 import static org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.SIN; |
32 import static org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.SIN; |
33 import static org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.TAN; |
33 import static org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.TAN; |
34 |
34 |
35 import org.graalvm.compiler.bytecode.BytecodeProvider; |
|
36 import org.graalvm.compiler.nodes.ValueNode; |
35 import org.graalvm.compiler.nodes.ValueNode; |
37 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; |
36 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; |
38 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext; |
37 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext; |
39 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin; |
38 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin; |
40 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins; |
39 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins; |
41 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration; |
40 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration; |
|
41 import org.graalvm.compiler.nodes.spi.Replacements; |
42 import org.graalvm.compiler.replacements.IntegerSubstitutions; |
42 import org.graalvm.compiler.replacements.IntegerSubstitutions; |
43 import org.graalvm.compiler.replacements.LongSubstitutions; |
43 import org.graalvm.compiler.replacements.LongSubstitutions; |
44 import org.graalvm.compiler.replacements.nodes.BinaryMathIntrinsicNode; |
44 import org.graalvm.compiler.replacements.nodes.BinaryMathIntrinsicNode; |
45 import org.graalvm.compiler.replacements.nodes.BitCountNode; |
45 import org.graalvm.compiler.replacements.nodes.BitCountNode; |
46 import org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode; |
46 import org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode; |
49 import jdk.vm.ci.meta.JavaKind; |
49 import jdk.vm.ci.meta.JavaKind; |
50 import jdk.vm.ci.meta.ResolvedJavaMethod; |
50 import jdk.vm.ci.meta.ResolvedJavaMethod; |
51 |
51 |
52 public class SPARCGraphBuilderPlugins { |
52 public class SPARCGraphBuilderPlugins { |
53 |
53 |
54 public static void register(Plugins plugins, BytecodeProvider bytecodeProvider, boolean explicitUnsafeNullChecks) { |
54 public static void register(Plugins plugins, Replacements replacements, boolean explicitUnsafeNullChecks) { |
55 InvocationPlugins invocationPlugins = plugins.getInvocationPlugins(); |
55 InvocationPlugins invocationPlugins = plugins.getInvocationPlugins(); |
56 invocationPlugins.defer(new Runnable() { |
56 invocationPlugins.defer(new Runnable() { |
57 @Override |
57 @Override |
58 public void run() { |
58 public void run() { |
59 registerIntegerLongPlugins(invocationPlugins, IntegerSubstitutions.class, JavaKind.Int, bytecodeProvider); |
59 registerIntegerLongPlugins(invocationPlugins, IntegerSubstitutions.class, JavaKind.Int, replacements); |
60 registerIntegerLongPlugins(invocationPlugins, LongSubstitutions.class, JavaKind.Long, bytecodeProvider); |
60 registerIntegerLongPlugins(invocationPlugins, LongSubstitutions.class, JavaKind.Long, replacements); |
61 registerMathPlugins(invocationPlugins); |
61 registerMathPlugins(invocationPlugins); |
62 // This is temporarily disabled until we implement correct emitting of the CAS |
62 // This is temporarily disabled until we implement correct emitting of the CAS |
63 // instructions of the proper width. |
63 // instructions of the proper width. |
64 registerPlatformSpecificUnsafePlugins(invocationPlugins, bytecodeProvider, explicitUnsafeNullChecks, |
64 registerPlatformSpecificUnsafePlugins(invocationPlugins, replacements, explicitUnsafeNullChecks, |
65 new JavaKind[]{JavaKind.Int, JavaKind.Long, JavaKind.Object}); |
65 new JavaKind[]{JavaKind.Int, JavaKind.Long, JavaKind.Object}); |
66 } |
66 } |
67 }); |
67 }); |
68 } |
68 } |
69 |
69 |
70 private static void registerIntegerLongPlugins(InvocationPlugins plugins, Class<?> substituteDeclaringClass, JavaKind kind, BytecodeProvider bytecodeProvider) { |
70 private static void registerIntegerLongPlugins(InvocationPlugins plugins, Class<?> substituteDeclaringClass, JavaKind kind, Replacements replacements) { |
71 Class<?> declaringClass = kind.toBoxedJavaClass(); |
71 Class<?> declaringClass = kind.toBoxedJavaClass(); |
72 Class<?> type = kind.toJavaClass(); |
72 Class<?> type = kind.toJavaClass(); |
73 Registration r = new Registration(plugins, declaringClass, bytecodeProvider); |
73 Registration r = new Registration(plugins, declaringClass, replacements); |
74 r.registerMethodSubstitution(substituteDeclaringClass, "numberOfLeadingZeros", type); |
74 r.registerMethodSubstitution(substituteDeclaringClass, "numberOfLeadingZeros", type); |
75 r.registerMethodSubstitution(substituteDeclaringClass, "numberOfTrailingZeros", type); |
75 r.registerMethodSubstitution(substituteDeclaringClass, "numberOfTrailingZeros", type); |
76 |
76 |
77 r.register1("bitCount", type, new InvocationPlugin() { |
77 r.register1("bitCount", type, new InvocationPlugin() { |
78 @Override |
78 @Override |