Mercurial > hg > truffle
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampTool.java @ 15260:61363577a184
Move static helpers from ObjectStamp to StampTool.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Tue, 22 Apr 2014 14:15:24 +0200 |
parents | 2c0cfbf454b5 |
children | 10c6705dbe9a |
rev | line source |
---|---|
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
1 /* |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
4 * |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
8 * |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
14 * |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
18 * |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
21 * questions. |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
22 */ |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
23 package com.oracle.graal.nodes.type; |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
24 |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
25 import java.util.*; |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
26 |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
27 import com.oracle.graal.api.meta.*; |
15198
2c0cfbf454b5
Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15132
diff
changeset
|
28 import com.oracle.graal.compiler.common.type.*; |
15260
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
29 import com.oracle.graal.nodes.*; |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
30 import com.oracle.graal.nodes.calc.*; |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
31 |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
32 /** |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
33 * Helper class that is used to keep all stamp-related operations in one place. |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
34 */ |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
35 public class StampTool { |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
36 |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
37 public static Stamp negate(Stamp stamp) { |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
38 if (stamp instanceof IntegerStamp) { |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
39 IntegerStamp integerStamp = (IntegerStamp) stamp; |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
40 int bits = integerStamp.getBits(); |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
41 if (integerStamp.lowerBound() != IntegerStamp.defaultMinValue(bits)) { |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
42 // TODO(ls) check if the mask calculation is correct... |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
43 return StampFactory.forInteger(bits, -integerStamp.upperBound(), -integerStamp.lowerBound()); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
44 } |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
45 } else if (stamp instanceof FloatStamp) { |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
46 FloatStamp floatStamp = (FloatStamp) stamp; |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
47 return new FloatStamp(floatStamp.getBits(), -floatStamp.upperBound(), -floatStamp.lowerBound(), floatStamp.isNonNaN()); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
48 } |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
49 |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
50 return stamp.unrestricted(); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
51 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
52 |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
53 public static Stamp not(Stamp stamp) { |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
54 if (stamp instanceof IntegerStamp) { |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
55 IntegerStamp integerStamp = (IntegerStamp) stamp; |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
56 int bits = integerStamp.getBits(); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
57 long defaultMask = IntegerStamp.defaultMask(bits); |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
58 return new IntegerStamp(bits, ~integerStamp.upperBound(), ~integerStamp.lowerBound(), (~integerStamp.upMask()) & defaultMask, (~integerStamp.downMask()) & defaultMask); |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
59 } |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
60 return stamp.unrestricted(); |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
61 } |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
62 |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
63 public static Stamp meet(Collection<? extends StampProvider> values) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7489
diff
changeset
|
64 Iterator<? extends StampProvider> iterator = values.iterator(); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
65 if (iterator.hasNext()) { |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
66 Stamp stamp = iterator.next().stamp(); |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
67 while (iterator.hasNext()) { |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
68 stamp = stamp.meet(iterator.next().stamp()); |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
69 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
70 return stamp; |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
71 } else { |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
72 return StampFactory.forVoid(); |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
73 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
74 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
75 |
11265 | 76 public static Stamp add(Stamp stamp1, Stamp stamp2) { |
77 if (stamp1 instanceof IntegerStamp && stamp2 instanceof IntegerStamp) { | |
78 return add((IntegerStamp) stamp1, (IntegerStamp) stamp2); | |
79 } | |
14997
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
80 return StampFactory.illegal(); |
11265 | 81 } |
82 | |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
83 private static long carryBits(long x, long y) { |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
84 return (x + y) ^ x ^ y; |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
85 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
86 |
11265 | 87 public static Stamp sub(Stamp stamp1, Stamp stamp2) { |
88 return add(stamp1, StampTool.negate(stamp2)); | |
89 } | |
90 | |
91 public static Stamp div(Stamp stamp1, Stamp stamp2) { | |
92 if (stamp1 instanceof IntegerStamp && stamp2 instanceof IntegerStamp) { | |
93 return div((IntegerStamp) stamp1, (IntegerStamp) stamp2); | |
94 } | |
14997
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
95 return StampFactory.illegal(); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
96 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
97 |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
98 public static Stamp div(IntegerStamp stamp1, IntegerStamp stamp2) { |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
99 assert stamp1.getBits() == stamp2.getBits(); |
6299
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5657
diff
changeset
|
100 if (stamp2.isStrictlyPositive()) { |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
101 long lowerBound = stamp1.lowerBound() / stamp2.lowerBound(); |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
102 long upperBound = stamp1.upperBound() / stamp2.lowerBound(); |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
103 return StampFactory.forInteger(stamp1.getBits(), lowerBound, upperBound); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
104 } |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
105 return stamp1.unrestricted(); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
106 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
107 |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
108 private static boolean addOverflowsPositively(long x, long y, int bits) { |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
109 long result = x + y; |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
110 if (bits == 64) { |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
111 return (~x & ~y & result) < 0; |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
112 } else { |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
113 return result > IntegerStamp.defaultMaxValue(bits); |
12562
035474349265
Serveral fixes to StampTool.add and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12538
diff
changeset
|
114 } |
035474349265
Serveral fixes to StampTool.add and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12538
diff
changeset
|
115 } |
035474349265
Serveral fixes to StampTool.add and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12538
diff
changeset
|
116 |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
117 private static boolean addOverflowsNegatively(long x, long y, int bits) { |
12562
035474349265
Serveral fixes to StampTool.add and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12538
diff
changeset
|
118 long result = x + y; |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
119 if (bits == 64) { |
12562
035474349265
Serveral fixes to StampTool.add and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12538
diff
changeset
|
120 return (x & y & ~result) < 0; |
035474349265
Serveral fixes to StampTool.add and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12538
diff
changeset
|
121 } else { |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
122 return result < IntegerStamp.defaultMinValue(bits); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
123 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
124 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
125 |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
126 public static IntegerStamp add(IntegerStamp stamp1, IntegerStamp stamp2) { |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
127 int bits = stamp1.getBits(); |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
128 assert bits == stamp2.getBits(); |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
129 |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
130 if (stamp1.isUnrestricted()) { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
131 return stamp1; |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
132 } else if (stamp2.isUnrestricted()) { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
133 return stamp2; |
12677
e53aa17b8fdf
Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12656
diff
changeset
|
134 } |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
135 long defaultMask = IntegerStamp.defaultMask(bits); |
12677
e53aa17b8fdf
Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12656
diff
changeset
|
136 long variableBits = (stamp1.downMask() ^ stamp1.upMask()) | (stamp2.downMask() ^ stamp2.upMask()); |
e53aa17b8fdf
Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12656
diff
changeset
|
137 long variableBitsWithCarry = variableBits | (carryBits(stamp1.downMask(), stamp2.downMask()) ^ carryBits(stamp1.upMask(), stamp2.upMask())); |
e53aa17b8fdf
Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12656
diff
changeset
|
138 long newDownMask = (stamp1.downMask() + stamp2.downMask()) & ~variableBitsWithCarry; |
e53aa17b8fdf
Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12656
diff
changeset
|
139 long newUpMask = (stamp1.downMask() + stamp2.downMask()) | variableBitsWithCarry; |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
140 |
12677
e53aa17b8fdf
Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12656
diff
changeset
|
141 newDownMask &= defaultMask; |
e53aa17b8fdf
Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12656
diff
changeset
|
142 newUpMask &= defaultMask; |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
143 |
12677
e53aa17b8fdf
Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12656
diff
changeset
|
144 long lowerBound; |
e53aa17b8fdf
Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12656
diff
changeset
|
145 long upperBound; |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
146 boolean lowerOverflowsPositively = addOverflowsPositively(stamp1.lowerBound(), stamp2.lowerBound(), bits); |
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
147 boolean upperOverflowsPositively = addOverflowsPositively(stamp1.upperBound(), stamp2.upperBound(), bits); |
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
148 boolean lowerOverflowsNegatively = addOverflowsNegatively(stamp1.lowerBound(), stamp2.lowerBound(), bits); |
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
149 boolean upperOverflowsNegatively = addOverflowsNegatively(stamp1.upperBound(), stamp2.upperBound(), bits); |
12677
e53aa17b8fdf
Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12656
diff
changeset
|
150 if ((lowerOverflowsNegatively && !upperOverflowsNegatively) || (!lowerOverflowsPositively && upperOverflowsPositively)) { |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
151 lowerBound = IntegerStamp.defaultMinValue(bits); |
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
152 upperBound = IntegerStamp.defaultMaxValue(bits); |
12677
e53aa17b8fdf
Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12656
diff
changeset
|
153 } else { |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
154 lowerBound = SignExtendNode.signExtend((stamp1.lowerBound() + stamp2.lowerBound()) & defaultMask, bits); |
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
155 upperBound = SignExtendNode.signExtend((stamp1.upperBound() + stamp2.upperBound()) & defaultMask, bits); |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
156 } |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
157 IntegerStamp limit = StampFactory.forInteger(bits, lowerBound, upperBound); |
12677
e53aa17b8fdf
Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12656
diff
changeset
|
158 newUpMask &= limit.upMask(); |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
159 upperBound = SignExtendNode.signExtend(upperBound & newUpMask, bits); |
12677
e53aa17b8fdf
Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12656
diff
changeset
|
160 newDownMask |= limit.downMask(); |
e53aa17b8fdf
Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12656
diff
changeset
|
161 lowerBound |= newDownMask; |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
162 return new IntegerStamp(bits, lowerBound, upperBound, newDownMask, newUpMask); |
10045
a4e7a7dc74f3
better stamps for OrNodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
163 } |
a4e7a7dc74f3
better stamps for OrNodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
164 |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
165 public static Stamp sub(IntegerStamp stamp1, IntegerStamp stamp2) { |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
166 if (stamp1.isUnrestricted() || stamp2.isUnrestricted()) { |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
167 return stamp1.unrestricted(); |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
168 } |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
169 return add(stamp1, (IntegerStamp) StampTool.negate(stamp2)); |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
170 } |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
171 |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
172 private static Stamp stampForMask(int bits, long downMask, long upMask) { |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
173 long lowerBound; |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
174 long upperBound; |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
175 if (((upMask >>> (bits - 1)) & 1) == 0) { |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
176 lowerBound = downMask; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
177 upperBound = upMask; |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
178 } else if (((downMask >>> (bits - 1)) & 1) == 1) { |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
179 lowerBound = downMask; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
180 upperBound = upMask; |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
181 } else { |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
182 lowerBound = downMask | (-1L << (bits - 1)); |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
183 upperBound = IntegerStamp.defaultMaxValue(bits) & upMask; |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
184 } |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
185 lowerBound = IntegerConvertNode.convert(lowerBound, bits, false); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
186 upperBound = IntegerConvertNode.convert(upperBound, bits, false); |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
187 return new IntegerStamp(bits, lowerBound, upperBound, downMask, upMask); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
188 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
189 |
11265 | 190 public static Stamp and(Stamp stamp1, Stamp stamp2) { |
191 if (stamp1 instanceof IntegerStamp && stamp2 instanceof IntegerStamp) { | |
192 return and((IntegerStamp) stamp1, (IntegerStamp) stamp2); | |
193 } | |
14997
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
194 return StampFactory.illegal(); |
11265 | 195 } |
196 | |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
197 public static Stamp and(IntegerStamp stamp1, IntegerStamp stamp2) { |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
198 assert stamp1.getBits() == stamp2.getBits(); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
199 return stampForMask(stamp1.getBits(), stamp1.downMask() & stamp2.downMask(), stamp1.upMask() & stamp2.upMask()); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
200 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
201 |
11265 | 202 public static Stamp or(Stamp stamp1, Stamp stamp2) { |
203 if (stamp1 instanceof IntegerStamp && stamp2 instanceof IntegerStamp) { | |
204 return or((IntegerStamp) stamp1, (IntegerStamp) stamp2); | |
205 } | |
14997
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
206 return StampFactory.illegal(); |
11265 | 207 } |
208 | |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
209 public static Stamp or(IntegerStamp stamp1, IntegerStamp stamp2) { |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
210 assert stamp1.getBits() == stamp2.getBits(); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
211 return stampForMask(stamp1.getBits(), stamp1.downMask() | stamp2.downMask(), stamp1.upMask() | stamp2.upMask()); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
212 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
213 |
11265 | 214 public static Stamp xor(Stamp stamp1, Stamp stamp2) { |
215 if (stamp1 instanceof IntegerStamp && stamp2 instanceof IntegerStamp) { | |
216 return xor((IntegerStamp) stamp1, (IntegerStamp) stamp2); | |
217 } | |
14997
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
218 return StampFactory.illegal(); |
11265 | 219 } |
220 | |
7489
8461d937ac18
Better for Load/Read stamps for non-stack kinds
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7302
diff
changeset
|
221 public static Stamp xor(IntegerStamp stamp1, IntegerStamp stamp2) { |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
222 assert stamp1.getBits() == stamp2.getBits(); |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
223 long variableBits = (stamp1.downMask() ^ stamp1.upMask()) | (stamp2.downMask() ^ stamp2.upMask()); |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
224 long newDownMask = (stamp1.downMask() ^ stamp2.downMask()) & ~variableBits; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
225 long newUpMask = (stamp1.downMask() ^ stamp2.downMask()) | variableBits; |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
226 return stampForMask(stamp1.getBits(), newDownMask, newUpMask); |
7489
8461d937ac18
Better for Load/Read stamps for non-stack kinds
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7302
diff
changeset
|
227 } |
8461d937ac18
Better for Load/Read stamps for non-stack kinds
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7302
diff
changeset
|
228 |
11265 | 229 public static Stamp unsignedRightShift(Stamp value, Stamp shift) { |
230 if (value instanceof IntegerStamp && shift instanceof IntegerStamp) { | |
231 return unsignedRightShift((IntegerStamp) value, (IntegerStamp) shift); | |
232 } | |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
233 return value.illegal(); |
11265 | 234 } |
235 | |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
236 public static Stamp unsignedRightShift(IntegerStamp value, IntegerStamp shift) { |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
237 int bits = value.getBits(); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
238 if (shift.lowerBound() == shift.upperBound()) { |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
239 long shiftMask = bits > 32 ? 0x3FL : 0x1FL; |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
240 long shiftCount = shift.lowerBound() & shiftMask; |
7302
f9f40467383e
Fixes for new Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
241 if (shiftCount != 0) { |
f9f40467383e
Fixes for new Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
242 long lowerBound; |
f9f40467383e
Fixes for new Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
243 long upperBound; |
12538
ae36dae46d50
Fix StampTool.unsignedRightShift
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11387
diff
changeset
|
244 long downMask = value.downMask() >>> shiftCount; |
12562
035474349265
Serveral fixes to StampTool.add and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12538
diff
changeset
|
245 long upMask = value.upMask() >>> shiftCount; |
7302
f9f40467383e
Fixes for new Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
246 if (value.lowerBound() < 0) { |
12538
ae36dae46d50
Fix StampTool.unsignedRightShift
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11387
diff
changeset
|
247 lowerBound = downMask; |
12562
035474349265
Serveral fixes to StampTool.add and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12538
diff
changeset
|
248 upperBound = upMask; |
7302
f9f40467383e
Fixes for new Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
249 } else { |
f9f40467383e
Fixes for new Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
250 lowerBound = value.lowerBound() >>> shiftCount; |
f9f40467383e
Fixes for new Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
251 upperBound = value.upperBound() >>> shiftCount; |
f9f40467383e
Fixes for new Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
252 } |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
253 return new IntegerStamp(bits, lowerBound, upperBound, downMask, upMask); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
254 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
255 } |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
256 long mask = IntegerStamp.upMaskFor(bits, value.lowerBound(), value.upperBound()); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
257 return stampForMask(bits, 0, mask); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
258 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
259 |
11265 | 260 public static Stamp leftShift(Stamp value, Stamp shift) { |
261 if (value instanceof IntegerStamp && shift instanceof IntegerStamp) { | |
262 return leftShift((IntegerStamp) value, (IntegerStamp) shift); | |
263 } | |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
264 return value.illegal(); |
11265 | 265 } |
266 | |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
267 public static Stamp leftShift(IntegerStamp value, IntegerStamp shift) { |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
268 int bits = value.getBits(); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
269 long defaultMask = IntegerStamp.defaultMask(bits); |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
270 if (value.upMask() == 0) { |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
271 return value; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
272 } |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
273 int shiftBits = bits > 32 ? 6 : 5; |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
274 long shiftMask = bits > 32 ? 0x3FL : 0x1FL; |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
275 if ((shift.lowerBound() >>> shiftBits) == (shift.upperBound() >>> shiftBits)) { |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
276 long downMask = defaultMask; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
277 long upMask = 0; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
278 for (long i = shift.lowerBound(); i <= shift.upperBound(); i++) { |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
279 if (shift.contains(i)) { |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
280 downMask &= value.downMask() << (i & shiftMask); |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
281 upMask |= value.upMask() << (i & shiftMask); |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
282 } |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
283 } |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
284 Stamp result = stampForMask(bits, downMask, upMask & defaultMask); |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
285 return result; |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
286 } |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
287 return value.unrestricted(); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
288 } |
6313
7ac010ae8c97
Add inferStamp for a number of ConvertNode's operations
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6299
diff
changeset
|
289 |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
290 public static Stamp signExtend(Stamp input, int resultBits) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
291 if (input instanceof IntegerStamp) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
292 IntegerStamp inputStamp = (IntegerStamp) input; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
293 int inputBits = inputStamp.getBits(); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
294 assert inputBits <= resultBits; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
295 |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
296 long defaultMask = IntegerStamp.defaultMask(resultBits); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
297 long downMask = SignExtendNode.signExtend(inputStamp.downMask(), inputBits) & defaultMask; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
298 long upMask = SignExtendNode.signExtend(inputStamp.upMask(), inputBits) & defaultMask; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
299 |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
300 return new IntegerStamp(resultBits, inputStamp.lowerBound(), inputStamp.upperBound(), downMask, upMask); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
301 } else { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
302 return input.illegal(); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
303 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
304 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
305 |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
306 public static Stamp zeroExtend(Stamp input, int resultBits) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
307 if (input instanceof IntegerStamp) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
308 IntegerStamp inputStamp = (IntegerStamp) input; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
309 int inputBits = inputStamp.getBits(); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
310 assert inputBits <= resultBits; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
311 |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
312 long downMask = ZeroExtendNode.zeroExtend(inputStamp.downMask(), inputBits); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
313 long upMask = ZeroExtendNode.zeroExtend(inputStamp.upMask(), inputBits); |
14015
0354f629431a
Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14010
diff
changeset
|
314 |
0354f629431a
Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14010
diff
changeset
|
315 if (inputStamp.lowerBound() < 0 && inputStamp.upperBound() >= 0) { |
0354f629431a
Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14010
diff
changeset
|
316 // signed range including 0 and -1 |
0354f629431a
Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14010
diff
changeset
|
317 // after sign extension, the whole range from 0 to MAX_INT is possible |
0354f629431a
Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14010
diff
changeset
|
318 return stampForMask(resultBits, downMask, upMask); |
14010
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14000
diff
changeset
|
319 } |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
320 |
14015
0354f629431a
Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14010
diff
changeset
|
321 long lowerBound = ZeroExtendNode.zeroExtend(inputStamp.lowerBound(), inputBits); |
0354f629431a
Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14010
diff
changeset
|
322 long upperBound = ZeroExtendNode.zeroExtend(inputStamp.upperBound(), inputBits); |
0354f629431a
Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14010
diff
changeset
|
323 |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
324 return new IntegerStamp(resultBits, lowerBound, upperBound, downMask, upMask); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
325 } else { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
326 return input.illegal(); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
327 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
328 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
329 |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
330 public static Stamp narrowingConversion(Stamp input, int resultBits) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
331 if (input instanceof IntegerStamp) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
332 IntegerStamp inputStamp = (IntegerStamp) input; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
333 int inputBits = inputStamp.getBits(); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
334 assert resultBits <= inputBits; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
335 if (resultBits == inputBits) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
336 return inputStamp; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
337 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
338 |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
339 final long upperBound; |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
340 if (inputStamp.lowerBound() < IntegerStamp.defaultMinValue(resultBits)) { |
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
341 upperBound = IntegerStamp.defaultMaxValue(resultBits); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
342 } else { |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
343 upperBound = saturate(inputStamp.upperBound(), resultBits); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
344 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
345 final long lowerBound; |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
346 if (inputStamp.upperBound() > IntegerStamp.defaultMaxValue(resultBits)) { |
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
347 lowerBound = IntegerStamp.defaultMinValue(resultBits); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
348 } else { |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
349 lowerBound = saturate(inputStamp.lowerBound(), resultBits); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
350 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
351 |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
352 long defaultMask = IntegerStamp.defaultMask(resultBits); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
353 long newDownMask = inputStamp.downMask() & defaultMask; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
354 long newUpMask = inputStamp.upMask() & defaultMask; |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
355 long newLowerBound = SignExtendNode.signExtend((lowerBound | newDownMask) & newUpMask, resultBits); |
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
356 long newUpperBound = SignExtendNode.signExtend((upperBound | newDownMask) & newUpMask, resultBits); |
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
357 return new IntegerStamp(resultBits, newLowerBound, newUpperBound, newDownMask, newUpMask); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
358 } else { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
359 return input.illegal(); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
360 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
361 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
362 |
12656
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12562
diff
changeset
|
363 public static IntegerStamp narrowingKindConversion(IntegerStamp fromStamp, Kind toKind) { |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
364 assert toKind == Kind.Byte || toKind == Kind.Char || toKind == Kind.Short || toKind == Kind.Int; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
365 final long upperBound; |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
366 if (fromStamp.lowerBound() < toKind.getMinValue()) { |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
367 upperBound = toKind.getMaxValue(); |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
368 } else { |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
369 upperBound = saturate(fromStamp.upperBound(), toKind); |
6313
7ac010ae8c97
Add inferStamp for a number of ConvertNode's operations
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6299
diff
changeset
|
370 } |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
371 final long lowerBound; |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
372 if (fromStamp.upperBound() > toKind.getMaxValue()) { |
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
373 lowerBound = toKind.getMinValue(); |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
374 } else { |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
375 lowerBound = saturate(fromStamp.lowerBound(), toKind); |
6313
7ac010ae8c97
Add inferStamp for a number of ConvertNode's operations
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6299
diff
changeset
|
376 } |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
377 |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
378 long defaultMask = IntegerStamp.defaultMask(toKind.getBitCount()); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
379 long intMask = IntegerStamp.defaultMask(32); |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
380 long newUpMask = signExtend(fromStamp.upMask() & defaultMask, toKind) & intMask; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
381 long newDownMask = signExtend(fromStamp.downMask() & defaultMask, toKind) & intMask; |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
382 return new IntegerStamp(toKind.getStackKind().getBitCount(), (int) ((lowerBound | newDownMask) & newUpMask), (int) ((upperBound | newDownMask) & newUpMask), newDownMask, newUpMask); |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
383 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
12677
diff
changeset
|
384 |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
385 private static long signExtend(long value, Kind valueKind) { |
12562
035474349265
Serveral fixes to StampTool.add and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12538
diff
changeset
|
386 if (valueKind != Kind.Char && valueKind != Kind.Long && (value >>> (valueKind.getBitCount() - 1) & 1) == 1) { |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
387 return value | (-1L << valueKind.getBitCount()); |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
388 } else { |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
389 return value; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
390 } |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
391 } |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
392 |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
393 private static long saturate(long v, int bits) { |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
394 if (bits < 64) { |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
395 long max = IntegerStamp.defaultMaxValue(bits); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
396 if (v > max) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
397 return max; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
398 } |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
399 long min = IntegerStamp.defaultMinValue(bits); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
400 if (v < min) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
401 return min; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
402 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
403 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
404 return v; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
405 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
406 |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
407 private static long saturate(long v, Kind kind) { |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
408 long max = kind.getMaxValue(); |
6313
7ac010ae8c97
Add inferStamp for a number of ConvertNode's operations
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6299
diff
changeset
|
409 if (v > max) { |
7ac010ae8c97
Add inferStamp for a number of ConvertNode's operations
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6299
diff
changeset
|
410 return max; |
7ac010ae8c97
Add inferStamp for a number of ConvertNode's operations
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6299
diff
changeset
|
411 } |
6328
6e66d97a16ae
Clean up Kind class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6313
diff
changeset
|
412 long min = kind.getMinValue(); |
6313
7ac010ae8c97
Add inferStamp for a number of ConvertNode's operations
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6299
diff
changeset
|
413 if (v < min) { |
7ac010ae8c97
Add inferStamp for a number of ConvertNode's operations
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6299
diff
changeset
|
414 return min; |
7ac010ae8c97
Add inferStamp for a number of ConvertNode's operations
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6299
diff
changeset
|
415 } |
7ac010ae8c97
Add inferStamp for a number of ConvertNode's operations
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6299
diff
changeset
|
416 return v; |
7ac010ae8c97
Add inferStamp for a number of ConvertNode's operations
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6299
diff
changeset
|
417 } |
14863
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
418 |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
419 /** |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
420 * Compute the stamp resulting from the unsigned comparison being true. |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
421 * |
14863
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
422 * @return null if it's can't be true or it nothing useful can be encoded. |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
423 */ |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
424 public static Stamp unsignedCompare(Stamp stamp, Stamp stamp2) { |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
425 IntegerStamp x = (IntegerStamp) stamp; |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
426 IntegerStamp y = (IntegerStamp) stamp2; |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
427 if (x == x.unrestricted() && y == y.unrestricted()) { |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
428 // Don't know anything. |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
429 return null; |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
430 } |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
431 // c <| n, where c is a constant and n is known to be positive. |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
432 if (x.lowerBound() == x.upperBound()) { |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
433 if (y.isPositive()) { |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
434 if (x.lowerBound() == (1 << x.getBits()) - 1) { |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
435 // Constant is MAX_VALUE which must fail. |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
436 return null; |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
437 } |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
438 if (x.lowerBound() <= y.lowerBound()) { |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
439 // Test will fail. Return illegalStamp instead? |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
440 return null; |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
441 } |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
442 // If the test succeeds then this proves that n is at greater than c so the bounds |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
443 // are [c+1..-n.upperBound)]. |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
444 return StampFactory.forInteger(x.getBits(), x.lowerBound() + 1, y.upperBound()); |
14863
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
445 } |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
446 return null; |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
447 } |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
448 // n <| c, where c is a strictly positive constant |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
449 if (y.lowerBound() == y.upperBound() && y.isStrictlyPositive()) { |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
450 // The test proves that n is positive and less than c, [0..c-1] |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14863
diff
changeset
|
451 return StampFactory.forInteger(y.getBits(), 0, y.lowerBound() - 1); |
14863
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
452 } |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
453 return null; |
ea712c41c5a2
merge unsigned compare guards with constant indexes or limits
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14021
diff
changeset
|
454 } |
15260
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
455 |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
456 /** |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
457 * Checks whether this {@link ValueNode} represents a {@linkplain Stamp#isLegal() legal} Object |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
458 * value which is known to be always null. |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
459 * |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
460 * @param node the node to check |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
461 * @return true if this node represents a legal object value which is known to be always null |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
462 */ |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
463 public static boolean isObjectAlwaysNull(ValueNode node) { |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
464 return isObjectAlwaysNull(node.stamp()); |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
465 } |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
466 |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
467 /** |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
468 * Checks whether this {@link Stamp} represents a {@linkplain Stamp#isLegal() legal} Object |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
469 * stamp whose values are known to be always null. |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
470 * |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
471 * @param stamp the stamp to check |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
472 * @return true if this stamp represents a legal object stamp whose values are known to be |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
473 * always null |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
474 */ |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
475 public static boolean isObjectAlwaysNull(Stamp stamp) { |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
476 if (stamp instanceof ObjectStamp && stamp.isLegal()) { |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
477 return ((ObjectStamp) stamp).alwaysNull(); |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
478 } |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
479 return false; |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
480 } |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
481 |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
482 /** |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
483 * Checks whether this {@link ValueNode} represents a {@linkplain Stamp#isLegal() legal} Object |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
484 * value which is known to never be null. |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
485 * |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
486 * @param node the node to check |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
487 * @return true if this node represents a legal object value which is known to never be null |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
488 */ |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
489 public static boolean isObjectNonNull(ValueNode node) { |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
490 return isObjectNonNull(node.stamp()); |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
491 } |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
492 |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
493 /** |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
494 * Checks whether this {@link Stamp} represents a {@linkplain Stamp#isLegal() legal} Object |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
495 * stamp whose values known to be always null. |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
496 * |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
497 * @param stamp the stamp to check |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
498 * @return true if this stamp represents a legal object stamp whose values are known to be |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
499 * always null |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
500 */ |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
501 public static boolean isObjectNonNull(Stamp stamp) { |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
502 if (stamp instanceof ObjectStamp && stamp.isLegal()) { |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
503 return ((ObjectStamp) stamp).nonNull(); |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
504 } |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
505 return false; |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
506 } |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
507 |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
508 /** |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
509 * Returns the {@linkplain ResolvedJavaType java type} this {@linkplain ValueNode} has if it is |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
510 * a {@linkplain Stamp#isLegal() legal} Object value. |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
511 * |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
512 * @param node the node to check |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
513 * @return the javat type this value has if it is a legal Object type, null otherwise |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
514 */ |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
515 public static ResolvedJavaType typeOrNull(ValueNode node) { |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
516 return typeOrNull(node.stamp()); |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
517 } |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
518 |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
519 /** |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
520 * Returns the {@linkplain ResolvedJavaType java type} this {@linkplain Stamp} has if it is a |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
521 * {@linkplain Stamp#isLegal() legal} Object stamp. |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
522 * |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
523 * @param stamp the stamp to check |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
524 * @return the java type this stamp has if it is a legal Object stamp, null otherwise |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
525 */ |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
526 public static ResolvedJavaType typeOrNull(Stamp stamp) { |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
527 if (stamp instanceof ObjectStamp && stamp.isLegal()) { |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
528 return ((ObjectStamp) stamp).type(); |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
529 } |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
530 return null; |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
531 } |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
532 |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
533 /** |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
534 * Checks whether this {@link ValueNode} represents a {@linkplain Stamp#isLegal() legal} Object |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
535 * value whose java type is known exactly. If this method returns true then the |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
536 * {@linkplain ResolvedJavaType java type} returned by {@link #typeOrNull(ValueNode)} is the |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
537 * concrete dynamic/runtime java type of this value. |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
538 * |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
539 * @param node the node to check |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
540 * @return true if this node represents a legal object value whose java type is known exactly |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
541 */ |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
542 public static boolean isExactType(ValueNode node) { |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
543 return isExactType(node.stamp()); |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
544 } |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
545 |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
546 /** |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
547 * Checks whether this {@link Stamp} represents a {@linkplain Stamp#isLegal() legal} Object |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
548 * stamp whose {@linkplain ResolvedJavaType java type} is known exactly. If this method returns |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
549 * true then the java type returned by {@link #typeOrNull(Stamp)} is the only concrete |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
550 * dynamic/runtime java type possible for values of this stamp. |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
551 * |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
552 * @param stamp the stamp to check |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
553 * @return true if this node represents a legal object stamp whose java type is known exactly |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
554 */ |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
555 public static boolean isExactType(Stamp stamp) { |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
556 if (stamp instanceof ObjectStamp && stamp.isLegal()) { |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
557 return ((ObjectStamp) stamp).isExactType(); |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
558 } |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
559 return false; |
61363577a184
Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
560 } |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
561 } |