Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMathIntrinsicOp.java @ 18564:966081b8e830
guard against null element in HotSpotConstantReflectionProvider.readStableFieldValue
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 27 Nov 2014 11:45:13 +0100 |
parents | 2d401b9ca70d |
children | 8fc336a04d77 32a5dd091f5f |
rev | line source |
---|---|
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
1 /* |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
4 * |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
8 * |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
14 * |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
18 * |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
21 * questions. |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
22 */ |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.lir.sparc; |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
24 |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
25 import static com.oracle.graal.api.code.ValueUtil.*; |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
26 |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
27 import com.oracle.graal.api.meta.*; |
17117
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
28 import com.oracle.graal.asm.sparc.SPARCAssembler.*; |
10686
73122b5edf6a
SPARC: Can compile simple methods and do static calls.
twisti
parents:
10565
diff
changeset
|
29 import com.oracle.graal.asm.sparc.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
14908
diff
changeset
|
30 import com.oracle.graal.compiler.common.*; |
9856
fbeda9df497d
implemented workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=409824
Doug Simon <doug.simon@oracle.com>
parents:
9846
diff
changeset
|
31 import com.oracle.graal.lir.*; |
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.lir.asm.*; |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
33 |
17206
2d401b9ca70d
[SPARC] Improve the lookup for delayable candidates, renaming interfaces/methods
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
17177
diff
changeset
|
34 public class SPARCMathIntrinsicOp extends SPARCLIRInstruction implements SPARCTailDelayedLIRInstruction { |
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
35 |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
36 public enum IntrinsicOpcode { |
14908
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13227
diff
changeset
|
37 SQRT, |
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13227
diff
changeset
|
38 SIN, |
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13227
diff
changeset
|
39 COS, |
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13227
diff
changeset
|
40 TAN, |
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13227
diff
changeset
|
41 LOG, |
17117
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
42 LOG10, |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
43 ABS |
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
44 } |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
45 |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
46 @Opcode private final IntrinsicOpcode opcode; |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
47 @Def protected Value result; |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
48 @Use protected Value input; |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
49 |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
50 public SPARCMathIntrinsicOp(IntrinsicOpcode opcode, Value result, Value input) { |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
51 this.opcode = opcode; |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
52 this.result = result; |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
53 this.input = input; |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
54 } |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
55 |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
56 @Override |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
11233
diff
changeset
|
57 public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { |
17117
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
58 Kind inputKind = (Kind) input.getLIRKind().getPlatformKind(); |
17206
2d401b9ca70d
[SPARC] Improve the lookup for delayable candidates, renaming interfaces/methods
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
17177
diff
changeset
|
59 delayedControlTransfer.emitControlTransfer(crb, masm); |
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
60 switch (opcode) { |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
61 case SQRT: |
17117
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
62 switch (inputKind) { |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
63 case Float: |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
64 new Fsqrts(asFloatReg(input), asFloatReg(result)).emit(masm); |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
65 break; |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
66 case Double: |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
67 new Fsqrtd(asDoubleReg(input), asDoubleReg(result)).emit(masm); |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
68 break; |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
69 default: |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
70 GraalInternalError.shouldNotReachHere(); |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
71 } |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
72 break; |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
73 case ABS: |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
74 switch (inputKind) { |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
75 case Float: |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
76 new Fabss(asFloatReg(input), asFloatReg(result)).emit(masm); |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
77 break; |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
78 case Double: |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
79 new Fabsd(asDoubleReg(input), asDoubleReg(result)).emit(masm); |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
80 break; |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
81 default: |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
82 GraalInternalError.shouldNotReachHere(); |
d980377abc6f
[SPARC] MathIntrinsic for sqrt and abs
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
15193
diff
changeset
|
83 } |
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
84 break; |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
85 case LOG: |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
86 case LOG10: |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
87 case SIN: |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
88 case COS: |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
89 case TAN: |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
90 default: |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
91 throw GraalInternalError.shouldNotReachHere(); |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
92 } |
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
93 } |
17177
805a26002dc7
[SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
17117
diff
changeset
|
94 |
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
95 } |