Mercurial > hg > truffle
annotate graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64MathIntrinsicNode.java @ 21916:3df76a0300f3
jvmci.make remove generated source from search path; export compilers into a different directory when jvmci is disabled: jre/lib/<arch>/(server|client)-nojvmci/
author | Stefan Anzinger <stefan.anzinger@oracle.com> |
---|---|
date | Thu, 11 Jun 2015 11:07:28 +0200 |
parents | 48c1ebd24120 |
children |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
19396
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18845
diff
changeset
|
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
20854
3081a57f95fd
converted @MethodSubstitutions for java.lang.Math to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents:
19791
diff
changeset
|
23 package com.oracle.graal.replacements.amd64; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@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:
21543
diff
changeset
|
25 import com.oracle.jvmci.meta.Kind; |
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:
21543
diff
changeset
|
26 import com.oracle.jvmci.meta.Value; |
15261
882f4cb7cfcf
Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
27 import com.oracle.graal.compiler.common.type.*; |
19396
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18845
diff
changeset
|
28 import com.oracle.graal.graph.*; |
11881
da9db8331658
moved Canonicalizable and Simplifiable to the com.oracle.graal.graph project (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11880
diff
changeset
|
29 import com.oracle.graal.graph.spi.*; |
20854
3081a57f95fd
converted @MethodSubstitutions for java.lang.Math to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents:
19791
diff
changeset
|
30 import com.oracle.graal.lir.amd64.*; |
15299
60406b8d6ad1
Move ArithmeticLIRGenerator to graal.lir (errors).
Josef Eisl <josef.eisl@jku.at>
parents:
15261
diff
changeset
|
31 import com.oracle.graal.lir.gen.*; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16822
diff
changeset
|
32 import com.oracle.graal.nodeinfo.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
33 import com.oracle.graal.nodes.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
34 import com.oracle.graal.nodes.calc.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
35 import com.oracle.graal.nodes.spi.*; |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20854
diff
changeset
|
36 import com.oracle.jvmci.common.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 |
16822
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16249
diff
changeset
|
38 @NodeInfo |
20854
3081a57f95fd
converted @MethodSubstitutions for java.lang.Math to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents:
19791
diff
changeset
|
39 public final class AMD64MathIntrinsicNode extends UnaryNode implements ArithmeticLIRLowerable { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 |
20854
3081a57f95fd
converted @MethodSubstitutions for java.lang.Math to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents:
19791
diff
changeset
|
41 public static final NodeClass<AMD64MathIntrinsicNode> TYPE = NodeClass.create(AMD64MathIntrinsicNode.class); |
17328
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
42 protected final Operation operation; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 public enum Operation { |
14908
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14888
diff
changeset
|
45 LOG, |
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14888
diff
changeset
|
46 LOG10, |
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14888
diff
changeset
|
47 SIN, |
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14888
diff
changeset
|
48 COS, |
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14888
diff
changeset
|
49 TAN |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 public Operation operation() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 return operation; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 |
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
56 public static ValueNode create(ValueNode value, Operation op) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
57 ValueNode c = tryConstantFold(value, op); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
58 if (c != null) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
59 return c; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
60 } |
20854
3081a57f95fd
converted @MethodSubstitutions for java.lang.Math to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents:
19791
diff
changeset
|
61 return new AMD64MathIntrinsicNode(value, op); |
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
62 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
63 |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
64 protected static ValueNode tryConstantFold(ValueNode value, Operation op) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
65 if (value.isConstant()) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
66 double ret = doCompute(value.asJavaConstant().asDouble(), op); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
67 return ConstantNode.forDouble(ret); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
68 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
69 return null; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
70 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
71 |
20854
3081a57f95fd
converted @MethodSubstitutions for java.lang.Math to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents:
19791
diff
changeset
|
72 protected AMD64MathIntrinsicNode(ValueNode value, Operation op) { |
19396
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18845
diff
changeset
|
73 super(TYPE, StampFactory.forKind(Kind.Double), value); |
16249
9c4043105f48
make MathIntrinsicNode a UnaryNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15299
diff
changeset
|
74 assert value.stamp() instanceof FloatStamp && PrimitiveStamp.getBits(value.stamp()) == 64; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 this.operation = op; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
77 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 @Override |
20854
3081a57f95fd
converted @MethodSubstitutions for java.lang.Math to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents:
19791
diff
changeset
|
79 public void generate(NodeMappableLIRBuilder builder, ArithmeticLIRGenerator lirGen) { |
3081a57f95fd
converted @MethodSubstitutions for java.lang.Math to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents:
19791
diff
changeset
|
80 AMD64ArithmeticLIRGenerator gen = (AMD64ArithmeticLIRGenerator) lirGen; |
16249
9c4043105f48
make MathIntrinsicNode a UnaryNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15299
diff
changeset
|
81 Value input = builder.operand(getValue()); |
11290
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11272
diff
changeset
|
82 Value result; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 switch (operation()) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7224
diff
changeset
|
84 case LOG: |
15130
ec22234bde0d
Pass more restricted interfaces to ArithmeticLIRLowerable and LocationNode in LIR generation.
Roland Schatz <roland.schatz@oracle.com>
parents:
14950
diff
changeset
|
85 result = gen.emitMathLog(input, false); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7224
diff
changeset
|
86 break; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7224
diff
changeset
|
87 case LOG10: |
15130
ec22234bde0d
Pass more restricted interfaces to ArithmeticLIRLowerable and LocationNode in LIR generation.
Roland Schatz <roland.schatz@oracle.com>
parents:
14950
diff
changeset
|
88 result = gen.emitMathLog(input, true); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7224
diff
changeset
|
89 break; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7224
diff
changeset
|
90 case SIN: |
15130
ec22234bde0d
Pass more restricted interfaces to ArithmeticLIRLowerable and LocationNode in LIR generation.
Roland Schatz <roland.schatz@oracle.com>
parents:
14950
diff
changeset
|
91 result = gen.emitMathSin(input); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7224
diff
changeset
|
92 break; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7224
diff
changeset
|
93 case COS: |
15130
ec22234bde0d
Pass more restricted interfaces to ArithmeticLIRLowerable and LocationNode in LIR generation.
Roland Schatz <roland.schatz@oracle.com>
parents:
14950
diff
changeset
|
94 result = gen.emitMathCos(input); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7224
diff
changeset
|
95 break; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7224
diff
changeset
|
96 case TAN: |
15130
ec22234bde0d
Pass more restricted interfaces to ArithmeticLIRLowerable and LocationNode in LIR generation.
Roland Schatz <roland.schatz@oracle.com>
parents:
14950
diff
changeset
|
97 result = gen.emitMathTan(input); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7224
diff
changeset
|
98 break; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7224
diff
changeset
|
99 default: |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20854
diff
changeset
|
100 throw JVMCIError.shouldNotReachHere(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 } |
15130
ec22234bde0d
Pass more restricted interfaces to ArithmeticLIRLowerable and LocationNode in LIR generation.
Roland Schatz <roland.schatz@oracle.com>
parents:
14950
diff
changeset
|
102 builder.setResult(this, result); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 @Override |
16249
9c4043105f48
make MathIntrinsicNode a UnaryNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15299
diff
changeset
|
106 public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) { |
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
107 ValueNode c = tryConstantFold(forValue, operation()); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
108 if (c != null) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
109 return c; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
110 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
111 return this; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
112 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
113 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
114 @NodeIntrinsic |
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19526
diff
changeset
|
115 public static native double compute(double value, @ConstantNodeParameter Operation op); |
14741
8c0e5b7d5af9
Do not call @NodeIntrinsic method from within Graal
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14024
diff
changeset
|
116 |
16249
9c4043105f48
make MathIntrinsicNode a UnaryNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15299
diff
changeset
|
117 private static double doCompute(double value, Operation op) { |
8481
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8451
diff
changeset
|
118 switch (op) { |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8451
diff
changeset
|
119 case LOG: |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8451
diff
changeset
|
120 return Math.log(value); |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8451
diff
changeset
|
121 case LOG10: |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8451
diff
changeset
|
122 return Math.log10(value); |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8451
diff
changeset
|
123 case SIN: |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8451
diff
changeset
|
124 return Math.sin(value); |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8451
diff
changeset
|
125 case COS: |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8451
diff
changeset
|
126 return Math.cos(value); |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8451
diff
changeset
|
127 case TAN: |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8451
diff
changeset
|
128 return Math.tan(value); |
16249
9c4043105f48
make MathIntrinsicNode a UnaryNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15299
diff
changeset
|
129 default: |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20854
diff
changeset
|
130 throw new JVMCIError("unknown op %s", op); |
8481
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8451
diff
changeset
|
131 } |
92571f3eeeeb
made VM independent method substitutions be interpretable
Doug Simon <doug.simon@oracle.com>
parents:
8451
diff
changeset
|
132 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
133 } |