Mercurial > hg > graal-jvmci-8
comparison graal/GraalCompiler/src/com/sun/c1x/ir/ArithmeticOp.java @ 2538:e1ba5a93e997
Clean up on Value class and LIRGenerator/LIRItem-related things.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 27 Apr 2011 20:13:54 +0200 |
parents | 16b9a8b5ad39 |
children | 0f9eeb15e636 |
comparison
equal
deleted
inserted
replaced
2537:4a016ff4d2df | 2538:e1ba5a93e997 |
---|---|
34 * @author Ben L. Titzer | 34 * @author Ben L. Titzer |
35 */ | 35 */ |
36 public final class ArithmeticOp extends Op2 { | 36 public final class ArithmeticOp extends Op2 { |
37 | 37 |
38 private FrameState stateBefore; | 38 private FrameState stateBefore; |
39 private boolean isStrictFP; | |
39 | 40 |
40 /** | 41 /** |
41 * Creates a new arithmetic operation. | 42 * Creates a new arithmetic operation. |
42 * @param opcode the bytecode opcode | 43 * @param opcode the bytecode opcode |
43 * @param kind the result kind of the operation | 44 * @param kind the result kind of the operation |
46 * @param isStrictFP indicates this operation has strict rounding semantics | 47 * @param isStrictFP indicates this operation has strict rounding semantics |
47 * @param stateBefore the state for instructions that may trap | 48 * @param stateBefore the state for instructions that may trap |
48 */ | 49 */ |
49 public ArithmeticOp(int opcode, CiKind kind, Value x, Value y, boolean isStrictFP, FrameState stateBefore) { | 50 public ArithmeticOp(int opcode, CiKind kind, Value x, Value y, boolean isStrictFP, FrameState stateBefore) { |
50 super(kind, opcode, x, y); | 51 super(kind, opcode, x, y); |
51 initFlag(Flag.IsStrictFP, isStrictFP); | 52 this.isStrictFP = isStrictFP; |
52 if (stateBefore != null) { | 53 if (stateBefore != null) { |
53 // state before is only used in the case of a division or remainder, | 54 // state before is only used in the case of a division or remainder, |
54 // and isn't needed if the zero check is redundant | 55 // and isn't needed if the zero check is redundant |
55 if (y.isConstant()) { | 56 if (y.isConstant()) { |
56 long divisor = y.asConstant().asLong(); | 57 long divisor = y.asConstant().asLong(); |
57 if (divisor != 0) { | 58 if (divisor != 0) { |
58 C1XMetrics.ZeroChecksRedundant++; | 59 C1XMetrics.ZeroChecksRedundant++; |
59 setFlag(Flag.NoZeroCheck); | 60 setFlag(Flag.NoZeroCheck); |
60 } else { | 61 } else { |
61 this.stateBefore = stateBefore; | 62 this.stateBefore = stateBefore; |
62 } | |
63 if (divisor != -1) { | |
64 C1XMetrics.DivideSpecialChecksRedundant++; | |
65 setFlag(Flag.NoDivSpecialCase); | |
66 } | 63 } |
67 } else { | 64 } else { |
68 this.stateBefore = stateBefore; | 65 this.stateBefore = stateBefore; |
69 } | 66 } |
70 } | 67 } |
78 /** | 75 /** |
79 * Checks whether this instruction has strict fp semantics. | 76 * Checks whether this instruction has strict fp semantics. |
80 * @return {@code true} if this instruction has strict fp semantics | 77 * @return {@code true} if this instruction has strict fp semantics |
81 */ | 78 */ |
82 public boolean isStrictFP() { | 79 public boolean isStrictFP() { |
83 return checkFlag(Flag.IsStrictFP); | 80 return isStrictFP; |
84 } | 81 } |
85 | 82 |
86 /** | 83 /** |
87 * Checks whether this instruction can cause a trap. For arithmetic operations, | 84 * Checks whether this instruction can cause a trap. For arithmetic operations, |
88 * only division and remainder operations can cause traps. | 85 * only division and remainder operations can cause traps. |
110 clearRuntimeCheck(Flag.NoZeroCheck); | 107 clearRuntimeCheck(Flag.NoZeroCheck); |
111 } | 108 } |
112 | 109 |
113 @Override | 110 @Override |
114 public void print(LogStream out) { | 111 public void print(LogStream out) { |
115 out.print(x()). | 112 out.print(x()).print(' ').print(Bytecodes.operator(opcode)).print(' ').print(y()); |
116 print(' '). | |
117 print(Bytecodes.operator(opcode)). | |
118 print(' '). | |
119 print(y()); | |
120 } | 113 } |
121 } | 114 } |