comparison graal/GraalCompiler/src/com/sun/c1x/ir/ArithmeticOp.java @ 2541:0f9eeb15e636

More Value.Flag clean up.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 27 Apr 2011 20:58:01 +0200
parents e1ba5a93e997
children 421da5f53b5e
comparison
equal deleted inserted replaced
2540:3fc322165071 2541:0f9eeb15e636
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 */ 22 */
23 package com.sun.c1x.ir; 23 package com.sun.c1x.ir;
24 24
25 import com.sun.c1x.*;
26 import com.sun.c1x.debug.*; 25 import com.sun.c1x.debug.*;
27 import com.sun.c1x.value.*; 26 import com.sun.c1x.value.*;
28 import com.sun.cri.bytecode.*; 27 import com.sun.cri.bytecode.*;
29 import com.sun.cri.ci.*; 28 import com.sun.cri.ci.*;
30 29
31 /** 30 /**
32 * The {@code ArithmeticOp} class represents arithmetic operations such as addition, subtraction, etc. 31 * The {@code ArithmeticOp} class represents arithmetic operations such as addition, subtraction, etc.
33 *
34 * @author Ben L. Titzer
35 */ 32 */
36 public final class ArithmeticOp extends Op2 { 33 public final class ArithmeticOp extends Op2 {
37 34
38 private FrameState stateBefore; 35 private final FrameState stateBefore;
39 private boolean isStrictFP; 36 private final boolean isStrictFP;
40 37
41 /** 38 /**
42 * Creates a new arithmetic operation. 39 * Creates a new arithmetic operation.
43 * @param opcode the bytecode opcode 40 * @param opcode the bytecode opcode
44 * @param kind the result kind of the operation 41 * @param kind the result kind of the operation
48 * @param stateBefore the state for instructions that may trap 45 * @param stateBefore the state for instructions that may trap
49 */ 46 */
50 public ArithmeticOp(int opcode, CiKind kind, Value x, Value y, boolean isStrictFP, FrameState stateBefore) { 47 public ArithmeticOp(int opcode, CiKind kind, Value x, Value y, boolean isStrictFP, FrameState stateBefore) {
51 super(kind, opcode, x, y); 48 super(kind, opcode, x, y);
52 this.isStrictFP = isStrictFP; 49 this.isStrictFP = isStrictFP;
53 if (stateBefore != null) { 50 this.stateBefore = stateBefore;
54 // state before is only used in the case of a division or remainder,
55 // and isn't needed if the zero check is redundant
56 if (y.isConstant()) {
57 long divisor = y.asConstant().asLong();
58 if (divisor != 0) {
59 C1XMetrics.ZeroChecksRedundant++;
60 setFlag(Flag.NoZeroCheck);
61 } else {
62 this.stateBefore = stateBefore;
63 }
64 } else {
65 this.stateBefore = stateBefore;
66 }
67 }
68 } 51 }
69 52
70 @Override 53 @Override
71 public FrameState stateBefore() { 54 public FrameState stateBefore() {
72 return stateBefore; 55 return stateBefore;
97 80
98 public boolean isCommutative() { 81 public boolean isCommutative() {
99 return Bytecodes.isCommutative(opcode); 82 return Bytecodes.isCommutative(opcode);
100 } 83 }
101 84
102 public boolean needsZeroCheck() {
103 return !checkFlag(Flag.NoZeroCheck);
104 }
105
106 public void eliminateZeroCheck() {
107 clearRuntimeCheck(Flag.NoZeroCheck);
108 }
109
110 @Override 85 @Override
111 public void print(LogStream out) { 86 public void print(LogStream out) {
112 out.print(x()).print(' ').print(Bytecodes.operator(opcode)).print(' ').print(y()); 87 out.print(x()).print(' ').print(Bytecodes.operator(opcode)).print(' ').print(y());
113 } 88 }
114 } 89 }