Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IntegerStamp.java @ 16320:fcac781d3592
Merge
author | Stefan Anzinger <stefan.anzinger@gmail.com> |
---|---|
date | Tue, 03 Jun 2014 14:31:36 +0200 |
parents | graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IntegerStamp.java@151fe6b1e511 |
children |
rev | line source |
---|---|
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
1 /* |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
4 * |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
8 * |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
14 * |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
18 * |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
21 * questions. |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
22 */ |
15261
882f4cb7cfcf
Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15198
diff
changeset
|
23 package com.oracle.graal.compiler.common.type; |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
24 |
11763
8f6917d1205f
IntegerStamp.toString: print full mask
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11387
diff
changeset
|
25 import java.util.*; |
8f6917d1205f
IntegerStamp.toString: print full mask
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11387
diff
changeset
|
26 |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5504
diff
changeset
|
27 import com.oracle.graal.api.meta.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15132
diff
changeset
|
28 import com.oracle.graal.compiler.common.*; |
15198
2c0cfbf454b5
Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
29 import com.oracle.graal.compiler.common.spi.*; |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
30 |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
31 /** |
15393
1d3c23e675ed
fixed some minor javadoc formatting issues
Doug Simon <doug.simon@oracle.com>
parents:
15308
diff
changeset
|
32 * Describes the possible values of a node that produces an int or long result. |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
33 * |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
34 * The description consists of (inclusive) lower and upper bounds and up (may be set) and down |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
35 * (always set) bit-masks. |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
36 */ |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
37 public class IntegerStamp extends PrimitiveStamp { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
38 |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
39 private final long lowerBound; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
40 private final long upperBound; |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
41 private final long downMask; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
42 private final long upMask; |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
43 |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
44 public IntegerStamp(int bits, long lowerBound, long upperBound, long downMask, long upMask) { |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
45 super(bits); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
46 this.lowerBound = lowerBound; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
47 this.upperBound = upperBound; |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
48 this.downMask = downMask; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
49 this.upMask = upMask; |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
50 assert lowerBound >= defaultMinValue(bits) : this; |
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
51 assert upperBound <= defaultMaxValue(bits) : this; |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
52 assert (downMask & defaultMask(bits)) == downMask : this; |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
53 assert (upMask & defaultMask(bits)) == upMask : this; |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
54 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
55 |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
56 @Override |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
57 public Stamp unrestricted() { |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
58 return new IntegerStamp(getBits(), defaultMinValue(getBits()), defaultMaxValue(getBits()), 0, defaultMask(getBits())); |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
59 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
60 |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
61 @Override |
14997
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
62 public Stamp illegal() { |
15132 | 63 return new IntegerStamp(getBits(), defaultMaxValue(getBits()), defaultMinValue(getBits()), defaultMask(getBits()), 0); |
14997
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
64 } |
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
65 |
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
66 @Override |
15911
03e09ed7039d
Use correct stamp when creating ConstantNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
15571
diff
changeset
|
67 public Stamp constant(Constant c, MetaAccessProvider meta) { |
03e09ed7039d
Use correct stamp when creating ConstantNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
15571
diff
changeset
|
68 long value = c.asLong(); |
03e09ed7039d
Use correct stamp when creating ConstantNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
15571
diff
changeset
|
69 return StampFactory.forInteger(getBits(), value, value); |
03e09ed7039d
Use correct stamp when creating ConstantNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
15571
diff
changeset
|
70 } |
03e09ed7039d
Use correct stamp when creating ConstantNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
15571
diff
changeset
|
71 |
03e09ed7039d
Use correct stamp when creating ConstantNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
15571
diff
changeset
|
72 @Override |
14997
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
73 public boolean isLegal() { |
15132 | 74 return lowerBound <= upperBound; |
14997
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
75 } |
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
76 |
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
77 @Override |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
78 public Kind getStackKind() { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
79 if (getBits() > 32) { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
80 return Kind.Long; |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
81 } else { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
82 return Kind.Int; |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
83 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
84 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
85 |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
86 @Override |
15308
04234c228e4c
Rename LIRTypeTool to PlatformKindTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15261
diff
changeset
|
87 public PlatformKind getPlatformKind(PlatformKindTool tool) { |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
88 return tool.getIntegerKind(getBits()); |
14003
0c38906450a0
Make conversion from Stamp to PlatformKind extensible by backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
89 } |
0c38906450a0
Make conversion from Stamp to PlatformKind extensible by backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
90 |
0c38906450a0
Make conversion from Stamp to PlatformKind extensible by backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
91 @Override |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
92 public ResolvedJavaType javaType(MetaAccessProvider metaAccess) { |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
93 switch (getBits()) { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
94 case 1: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
95 return metaAccess.lookupJavaType(Boolean.TYPE); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
96 case 8: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
97 return metaAccess.lookupJavaType(Byte.TYPE); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
98 case 16: |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
99 return metaAccess.lookupJavaType(Short.TYPE); |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
100 case 32: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
101 return metaAccess.lookupJavaType(Integer.TYPE); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
102 case 64: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
103 return metaAccess.lookupJavaType(Long.TYPE); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
104 default: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
105 throw GraalInternalError.shouldNotReachHere(); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
106 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
107 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
108 |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
109 /** |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
110 * The signed inclusive lower bound on the value described by this stamp. |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
111 */ |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
112 public long lowerBound() { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
113 return lowerBound; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
114 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
115 |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
116 /** |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
117 * The signed inclusive upper bound on the value described by this stamp. |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
118 */ |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
119 public long upperBound() { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
120 return upperBound; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
121 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
122 |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
123 /** |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
124 * This bit-mask describes the bits that are always set in the value described by this stamp. |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
125 */ |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
126 public long downMask() { |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
127 return downMask; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
128 } |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
129 |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
130 /** |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
131 * This bit-mask describes the bits that can be set in the value described by this stamp. |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
132 */ |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
133 public long upMask() { |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
134 return upMask; |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
135 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
136 |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
137 public boolean isUnrestricted() { |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
138 return lowerBound == defaultMinValue(getBits()) && upperBound == defaultMaxValue(getBits()) && downMask == 0 && upMask == defaultMask(getBits()); |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
139 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
140 |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
141 public boolean contains(long value) { |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
142 return value >= lowerBound && value <= upperBound && (value & downMask) == downMask && (value & upMask) == (value & defaultMask(getBits())); |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
143 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
144 |
6299
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
145 public boolean isPositive() { |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
146 return lowerBound() >= 0; |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
147 } |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
148 |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
149 public boolean isNegative() { |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
150 return upperBound() <= 0; |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
151 } |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
152 |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
153 public boolean isStrictlyPositive() { |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
154 return lowerBound() > 0; |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
155 } |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
156 |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
157 public boolean isStrictlyNegative() { |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
158 return upperBound() < 0; |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
159 } |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
160 |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
161 public boolean canBePositive() { |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
162 return upperBound() > 0; |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
163 } |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
164 |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
165 public boolean canBeNegative() { |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
166 return lowerBound() < 0; |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
167 } |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
168 |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
169 @Override |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
170 public String toString() { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
171 StringBuilder str = new StringBuilder(); |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
172 str.append('i'); |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
173 str.append(getBits()); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
174 if (lowerBound == upperBound) { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
175 str.append(" [").append(lowerBound).append(']'); |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
176 } else if (lowerBound != defaultMinValue(getBits()) || upperBound != defaultMaxValue(getBits())) { |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
177 str.append(" [").append(lowerBound).append(" - ").append(upperBound).append(']'); |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
178 } |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
179 if (downMask != 0) { |
11763
8f6917d1205f
IntegerStamp.toString: print full mask
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11387
diff
changeset
|
180 str.append(" \u21ca"); |
8f6917d1205f
IntegerStamp.toString: print full mask
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11387
diff
changeset
|
181 new Formatter(str).format("%016x", downMask); |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
182 } |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
183 if (upMask != defaultMask(getBits())) { |
11763
8f6917d1205f
IntegerStamp.toString: print full mask
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11387
diff
changeset
|
184 str.append(" \u21c8"); |
8f6917d1205f
IntegerStamp.toString: print full mask
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11387
diff
changeset
|
185 new Formatter(str).format("%016x", upMask); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
186 } |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
187 return str.toString(); |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
188 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
189 |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
190 private Stamp createStamp(IntegerStamp other, long newUpperBound, long newLowerBound, long newDownMask, long newUpMask) { |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
191 assert getBits() == other.getBits(); |
15571
9a5b5a5b2246
more accurately determine if a IntegerStamp is illegal
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15393
diff
changeset
|
192 if (newLowerBound > newUpperBound || (newDownMask & (~newUpMask)) != 0 || (newUpMask == 0 && (newLowerBound > 0 || newUpperBound < 0))) { |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
193 return illegal(); |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
194 } else if (newLowerBound == lowerBound && newUpperBound == upperBound && newDownMask == downMask && newUpMask == upMask) { |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
195 return this; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
196 } else if (newLowerBound == other.lowerBound && newUpperBound == other.upperBound && newDownMask == other.downMask && newUpMask == other.upMask) { |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
197 return other; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
198 } else { |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
199 return new IntegerStamp(getBits(), newLowerBound, newUpperBound, newDownMask, newUpMask); |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
200 } |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
201 } |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
202 |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
203 @Override |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
204 public Stamp meet(Stamp otherStamp) { |
11265 | 205 if (otherStamp == this) { |
206 return this; | |
207 } | |
208 if (!(otherStamp instanceof IntegerStamp)) { | |
11387
9088d13767f3
Keep a kind in the illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11352
diff
changeset
|
209 return StampFactory.illegal(Kind.Illegal); |
11265 | 210 } |
15960
da6941811da8
fast path for IntegerStamp.meet
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15911
diff
changeset
|
211 if (equals(otherStamp)) { |
da6941811da8
fast path for IntegerStamp.meet
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15911
diff
changeset
|
212 return this; |
da6941811da8
fast path for IntegerStamp.meet
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15911
diff
changeset
|
213 } |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
214 IntegerStamp other = (IntegerStamp) otherStamp; |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
215 return createStamp(other, Math.max(upperBound, other.upperBound), Math.min(lowerBound, other.lowerBound), downMask & other.downMask, upMask | other.upMask); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
216 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
217 |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
218 @Override |
5890
c241963cda6d
added Stamp.join, used by PiNodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
5830
diff
changeset
|
219 public Stamp join(Stamp otherStamp) { |
11265 | 220 if (otherStamp == this) { |
221 return this; | |
222 } | |
223 if (!(otherStamp instanceof IntegerStamp)) { | |
11387
9088d13767f3
Keep a kind in the illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11352
diff
changeset
|
224 return StampFactory.illegal(Kind.Illegal); |
11265 | 225 } |
5890
c241963cda6d
added Stamp.join, used by PiNodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
5830
diff
changeset
|
226 IntegerStamp other = (IntegerStamp) otherStamp; |
12542
7cf8b577b6e1
Fix integer stamp join for downMask/lowerBound
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11887
diff
changeset
|
227 long newDownMask = downMask | other.downMask; |
7cf8b577b6e1
Fix integer stamp join for downMask/lowerBound
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11887
diff
changeset
|
228 long newLowerBound = Math.max(lowerBound, other.lowerBound) | newDownMask; |
7cf8b577b6e1
Fix integer stamp join for downMask/lowerBound
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11887
diff
changeset
|
229 return createStamp(other, Math.min(upperBound, other.upperBound), newLowerBound, newDownMask, upMask & other.upMask); |
5890
c241963cda6d
added Stamp.join, used by PiNodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
5830
diff
changeset
|
230 } |
c241963cda6d
added Stamp.join, used by PiNodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
5830
diff
changeset
|
231 |
c241963cda6d
added Stamp.join, used by PiNodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
5830
diff
changeset
|
232 @Override |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
233 public boolean isCompatible(Stamp stamp) { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
234 if (this == stamp) { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
235 return true; |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
236 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
237 if (stamp instanceof IntegerStamp) { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
238 IntegerStamp other = (IntegerStamp) stamp; |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
239 return getBits() == other.getBits(); |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
240 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
241 return false; |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
242 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
243 |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
244 @Override |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
245 public int hashCode() { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
246 final int prime = 31; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
247 int result = 1; |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
248 result = prime * result + super.hashCode(); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
249 result = prime * result + (int) (lowerBound ^ (lowerBound >>> 32)); |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
250 result = prime * result + (int) (upperBound ^ (upperBound >>> 32)); |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
251 result = prime * result + (int) (downMask ^ (downMask >>> 32)); |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
252 result = prime * result + (int) (upMask ^ (upMask >>> 32)); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
253 return result; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
254 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
255 |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
256 @Override |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
257 public boolean equals(Object obj) { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
258 if (this == obj) { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
259 return true; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
260 } |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
261 if (obj == null || getClass() != obj.getClass() || !super.equals(obj)) { |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
262 return false; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
263 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
264 IntegerStamp other = (IntegerStamp) obj; |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
265 if (lowerBound != other.lowerBound || upperBound != other.upperBound || downMask != other.downMask || upMask != other.upMask) { |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
266 return false; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
267 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
268 return true; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
269 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
270 |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
271 public static long defaultMask(int bits) { |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
272 assert 0 <= bits && bits <= 64; |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
273 if (bits == 64) { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
274 return 0xffffffffffffffffL; |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
275 } else { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
276 return (1L << bits) - 1; |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
277 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
278 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
279 |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
280 public static long defaultMinValue(int bits) { |
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
281 return -1L << (bits - 1); |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
282 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
283 |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
284 public static long defaultMaxValue(int bits) { |
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
285 return defaultMask(bits - 1); |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
286 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
287 |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
288 public static long upMaskFor(int bits, long lowerBound, long upperBound) { |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
289 long mask = lowerBound | upperBound; |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
290 if (mask == 0) { |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
291 return 0; |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
292 } else { |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
293 return ((-1L) >>> Long.numberOfLeadingZeros(mask)) & defaultMask(bits); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
294 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
295 } |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
296 |
6301
4535a87e8bf8
Fix for sameSign check and javadoc
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6299
diff
changeset
|
297 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7489
diff
changeset
|
298 * Checks if the 2 stamps represent values of the same sign. Returns true if the two stamps are |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7489
diff
changeset
|
299 * both positive of null or if they are both strictly negative |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
300 * |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7489
diff
changeset
|
301 * @return true if the two stamps are both positive of null or if they are both strictly |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7489
diff
changeset
|
302 * negative |
6301
4535a87e8bf8
Fix for sameSign check and javadoc
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6299
diff
changeset
|
303 */ |
6299
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
304 public static boolean sameSign(IntegerStamp s1, IntegerStamp s2) { |
6301
4535a87e8bf8
Fix for sameSign check and javadoc
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6299
diff
changeset
|
305 return s1.isPositive() && s2.isPositive() || s1.isStrictlyNegative() && s2.isStrictlyNegative(); |
6299
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
306 } |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
307 |
11265 | 308 @Override |
309 public Constant asConstant() { | |
310 if (lowerBound == upperBound) { | |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
311 switch (getBits()) { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
312 case 1: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
313 return Constant.forBoolean(lowerBound != 0); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
314 case 8: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
315 return Constant.forByte((byte) lowerBound); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
316 case 16: |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
317 return Constant.forShort((short) lowerBound); |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
318 case 32: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
319 return Constant.forInt((int) lowerBound); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
320 case 64: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
321 return Constant.forLong(lowerBound); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
322 } |
11265 | 323 } |
324 return null; | |
325 } | |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
326 } |