Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.replacements.sparc/src/com/oracle/graal/replacements/sparc/SPARCGraphBuilderPlugins.java @ 21556:48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 27 May 2015 00:36:16 +0200 |
parents | b1530a6cce8c |
children | 0e095e2c24e2 |
rev | line source |
---|---|
20835
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.replacements.sparc; |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21554
diff
changeset
|
25 import com.oracle.jvmci.code.ForeignCallsProvider; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21554
diff
changeset
|
26 import com.oracle.jvmci.meta.Kind; |
20845
258f80bce598
[SPARC] added InvocationPlugins for using HotSpot runtime math methods
Doug Simon <doug.simon@oracle.com>
parents:
20835
diff
changeset
|
27 import static com.oracle.graal.compiler.target.Backend.*; |
258f80bce598
[SPARC] added InvocationPlugins for using HotSpot runtime math methods
Doug Simon <doug.simon@oracle.com>
parents:
20835
diff
changeset
|
28 |
21554
b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20848
diff
changeset
|
29 import com.oracle.graal.graphbuilderconf.*; |
20835
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.graphbuilderconf.InvocationPlugins.Registration; |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.replacements.*; |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 public class SPARCGraphBuilderPlugins { |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 |
20845
258f80bce598
[SPARC] added InvocationPlugins for using HotSpot runtime math methods
Doug Simon <doug.simon@oracle.com>
parents:
20835
diff
changeset
|
36 public static void register(Plugins plugins, ForeignCallsProvider foreignCalls) { |
20835
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 InvocationPlugins invocationPlugins = plugins.getInvocationPlugins(); |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 registerIntegerLongPlugins(invocationPlugins, IntegerSubstitutions.class, Kind.Int); |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 registerIntegerLongPlugins(invocationPlugins, LongSubstitutions.class, Kind.Long); |
20845
258f80bce598
[SPARC] added InvocationPlugins for using HotSpot runtime math methods
Doug Simon <doug.simon@oracle.com>
parents:
20835
diff
changeset
|
40 registerMathPlugins(invocationPlugins, foreignCalls); |
20835
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 } |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 private static void registerIntegerLongPlugins(InvocationPlugins plugins, Class<?> substituteDeclaringClass, Kind kind) { |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 Class<?> declaringClass = kind.toBoxedJavaClass(); |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 Class<?> type = kind.toJavaClass(); |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 Registration r = new Registration(plugins, declaringClass); |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 r.registerMethodSubstitution(substituteDeclaringClass, "numberOfLeadingZeros", type); |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 r.registerMethodSubstitution(substituteDeclaringClass, "numberOfTrailingZeros", type); |
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 } |
20845
258f80bce598
[SPARC] added InvocationPlugins for using HotSpot runtime math methods
Doug Simon <doug.simon@oracle.com>
parents:
20835
diff
changeset
|
50 |
258f80bce598
[SPARC] added InvocationPlugins for using HotSpot runtime math methods
Doug Simon <doug.simon@oracle.com>
parents:
20835
diff
changeset
|
51 private static void registerMathPlugins(InvocationPlugins plugins, ForeignCallsProvider foreignCalls) { |
258f80bce598
[SPARC] added InvocationPlugins for using HotSpot runtime math methods
Doug Simon <doug.simon@oracle.com>
parents:
20835
diff
changeset
|
52 Registration r = new Registration(plugins, Math.class); |
20847
74f8a2ec0844
generalized MathRuntimeCallPlugin to ForeignCallPlugin
Doug Simon <doug.simon@oracle.com>
parents:
20845
diff
changeset
|
53 r.register1("sin", Double.TYPE, new ForeignCallPlugin(foreignCalls, ARITHMETIC_SIN)); |
74f8a2ec0844
generalized MathRuntimeCallPlugin to ForeignCallPlugin
Doug Simon <doug.simon@oracle.com>
parents:
20845
diff
changeset
|
54 r.register1("cos", Double.TYPE, new ForeignCallPlugin(foreignCalls, ARITHMETIC_COS)); |
74f8a2ec0844
generalized MathRuntimeCallPlugin to ForeignCallPlugin
Doug Simon <doug.simon@oracle.com>
parents:
20845
diff
changeset
|
55 r.register1("tan", Double.TYPE, new ForeignCallPlugin(foreignCalls, ARITHMETIC_TAN)); |
20848
9e8f6d379720
added InvocationPlugins to use recently exposed HotSpot math runtime functions
Doug Simon <doug.simon@oracle.com>
parents:
20847
diff
changeset
|
56 r.register1("exp", Double.TYPE, new ForeignCallPlugin(foreignCalls, ARITHMETIC_EXP)); |
9e8f6d379720
added InvocationPlugins to use recently exposed HotSpot math runtime functions
Doug Simon <doug.simon@oracle.com>
parents:
20847
diff
changeset
|
57 r.register1("log", Double.TYPE, new ForeignCallPlugin(foreignCalls, ARITHMETIC_LOG)); |
9e8f6d379720
added InvocationPlugins to use recently exposed HotSpot math runtime functions
Doug Simon <doug.simon@oracle.com>
parents:
20847
diff
changeset
|
58 r.register1("log10", Double.TYPE, new ForeignCallPlugin(foreignCalls, ARITHMETIC_LOG10)); |
20847
74f8a2ec0844
generalized MathRuntimeCallPlugin to ForeignCallPlugin
Doug Simon <doug.simon@oracle.com>
parents:
20845
diff
changeset
|
59 r.register2("pow", Double.TYPE, Double.TYPE, new ForeignCallPlugin(foreignCalls, ARITHMETIC_POW)); |
20845
258f80bce598
[SPARC] added InvocationPlugins for using HotSpot runtime math methods
Doug Simon <doug.simon@oracle.com>
parents:
20835
diff
changeset
|
60 } |
20835
a2cd0e7072e2
added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 } |