comparison graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/FloatStamp.java @ 14997:5e4ae8709830

Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
author Roland Schatz <roland.schatz@oracle.com>
date Fri, 04 Apr 2014 15:57:41 +0200
parents 0c38906450a0
children 96bb07a5d667
comparison
equal deleted inserted replaced
14996:88d77743dff3 14997:5e4ae8709830
36 this(bits, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, false); 36 this(bits, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, false);
37 } 37 }
38 38
39 protected FloatStamp(int bits, double lowerBound, double upperBound, boolean nonNaN) { 39 protected FloatStamp(int bits, double lowerBound, double upperBound, boolean nonNaN) {
40 super(bits); 40 super(bits);
41 assert (!nonNaN && Double.isNaN(lowerBound) && Double.isNaN(upperBound)) || lowerBound <= upperBound;
42 this.lowerBound = lowerBound; 41 this.lowerBound = lowerBound;
43 this.upperBound = upperBound; 42 this.upperBound = upperBound;
44 this.nonNaN = nonNaN; 43 this.nonNaN = nonNaN;
45 } 44 }
46 45
47 @Override 46 @Override
48 public Stamp unrestricted() { 47 public Stamp unrestricted() {
49 return new FloatStamp(getBits()); 48 return new FloatStamp(getBits());
49 }
50
51 @Override
52 public Stamp illegal() {
53 return new FloatStamp(getBits(), Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, true);
54 }
55
56 @Override
57 public boolean isLegal() {
58 return lowerBound <= upperBound || !nonNaN;
50 } 59 }
51 60
52 @Override 61 @Override
53 public Kind getStackKind() { 62 public Kind getStackKind() {
54 if (getBits() > 32) { 63 if (getBits() > 32) {
122 @Override 131 @Override
123 public Stamp meet(Stamp otherStamp) { 132 public Stamp meet(Stamp otherStamp) {
124 if (otherStamp == this) { 133 if (otherStamp == this) {
125 return this; 134 return this;
126 } 135 }
127 if (otherStamp instanceof IllegalStamp) {
128 return otherStamp.meet(this);
129 }
130 if (!(otherStamp instanceof FloatStamp)) { 136 if (!(otherStamp instanceof FloatStamp)) {
131 return StampFactory.illegal(Kind.Illegal); 137 return StampFactory.illegal(Kind.Illegal);
132 } 138 }
133 FloatStamp other = (FloatStamp) otherStamp; 139 FloatStamp other = (FloatStamp) otherStamp;
134 assert getBits() == other.getBits(); 140 assert getBits() == other.getBits();
147 @Override 153 @Override
148 public Stamp join(Stamp otherStamp) { 154 public Stamp join(Stamp otherStamp) {
149 if (otherStamp == this) { 155 if (otherStamp == this) {
150 return this; 156 return this;
151 } 157 }
152 if (otherStamp instanceof IllegalStamp) {
153 return otherStamp.join(this);
154 }
155 if (!(otherStamp instanceof FloatStamp)) { 158 if (!(otherStamp instanceof FloatStamp)) {
156 return StampFactory.illegal(Kind.Illegal); 159 return StampFactory.illegal(Kind.Illegal);
157 } 160 }
158 FloatStamp other = (FloatStamp) otherStamp; 161 FloatStamp other = (FloatStamp) otherStamp;
159 assert getBits() == other.getBits(); 162 assert getBits() == other.getBits();
162 boolean joinNonNaN = nonNaN || other.nonNaN; 165 boolean joinNonNaN = nonNaN || other.nonNaN;
163 if (joinLowerBound == lowerBound && joinUpperBound == upperBound && joinNonNaN == nonNaN) { 166 if (joinLowerBound == lowerBound && joinUpperBound == upperBound && joinNonNaN == nonNaN) {
164 return this; 167 return this;
165 } else if (joinLowerBound == other.lowerBound && joinUpperBound == other.upperBound && joinNonNaN == other.nonNaN) { 168 } else if (joinLowerBound == other.lowerBound && joinUpperBound == other.upperBound && joinNonNaN == other.nonNaN) {
166 return other; 169 return other;
167 } else if (joinLowerBound > joinUpperBound) {
168 return illegal();
169 } else { 170 } else {
170 return new FloatStamp(getBits(), joinLowerBound, joinUpperBound, joinNonNaN); 171 return new FloatStamp(getBits(), joinLowerBound, joinUpperBound, joinNonNaN);
171 } 172 }
172 } 173 }
173 174