Mercurial > hg > truffle
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IntegerStamp.java @ 5830:f28115ee6108
Do without the Top stamp for now, too little benefits
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Fri, 13 Jul 2012 11:29:15 +0200 |
parents | 547587296886 |
children | c241963cda6d |
rev | line source |
---|---|
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
1 /* |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
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 */ |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
23 package com.oracle.graal.nodes.type; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
24 |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5504
diff
changeset
|
25 import com.oracle.graal.api.meta.*; |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
26 import com.oracle.graal.nodes.*; |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
27 |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
28 /** |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
29 * Describes the possible values of a {@link ValueNode} that produces an int or long result. |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
30 * |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
31 * The description consists of (inclusive) lower and upper bounds and a bit-mask. |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
32 */ |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
33 public class IntegerStamp extends Stamp { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
34 |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
35 private final long lowerBound; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
36 private final long upperBound; |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
37 private final long mask; |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
38 |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
39 public IntegerStamp(Kind kind) { |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
40 this(kind, kind.minValue(), kind.maxValue(), defaultMask(kind)); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
41 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
42 |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
43 public IntegerStamp(Kind kind, long lowerBound, long upperBound, long mask) { |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
44 super(kind); |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
45 assert lowerBound <= upperBound; |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
46 assert lowerBound >= kind.minValue(); |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
47 assert upperBound <= kind.maxValue(); |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
48 assert (mask & defaultMask(kind)) == mask; |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
49 this.lowerBound = lowerBound; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
50 this.upperBound = upperBound; |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
51 this.mask = mask; |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
52 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
53 |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
54 /** |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
55 * The (inclusive) lower bound on the value described by this stamp. |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
56 */ |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
57 public long lowerBound() { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
58 return lowerBound; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
59 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
60 |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
61 /** |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
62 * The (inclusive) upper bound on the value described by this stamp. |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
63 */ |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
64 public long upperBound() { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
65 return upperBound; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
66 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
67 |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
68 /** |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
69 * This bit-mask describes the bits that can be set in the value described by this stamp. It is primarily used to |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
70 * represent values that are multiples of a known power of two. |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
71 */ |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
72 public long mask() { |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
73 return mask; |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
74 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
75 |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
76 public boolean isUnrestricted() { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
77 return lowerBound == kind().minValue() && upperBound == kind().maxValue() && mask == defaultMask(kind()); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
78 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
79 |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
80 public boolean contains(long value) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
81 return value >= lowerBound && value <= upperBound && (value & mask) == (value & defaultMask(kind())); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
82 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
83 |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
84 @Override |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
85 public String toString() { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
86 StringBuilder str = new StringBuilder(); |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
87 str.append(kind().typeChar); |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
88 if (lowerBound == upperBound) { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
89 str.append(" [").append(lowerBound).append(']'); |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
90 } else if (lowerBound != kind().minValue() || upperBound != kind().maxValue()) { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
91 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
|
92 } |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
93 if (mask != defaultMask(kind())) { |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
94 str.append(" #").append(Long.toHexString(mask)); |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
95 } |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
96 return str.toString(); |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
97 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
98 |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
99 @Override |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
100 public boolean alwaysDistinct(Stamp otherStamp) { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
101 IntegerStamp other = (IntegerStamp) otherStamp; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
102 return lowerBound > other.upperBound || upperBound < other.lowerBound; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
103 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
104 |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
105 @Override |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
106 public Stamp meet(Stamp otherStamp) { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
107 IntegerStamp other = (IntegerStamp) otherStamp; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
108 assert kind() == other.kind(); |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
109 long meetUpperBound = Math.max(upperBound, other.upperBound); |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
110 long meetLowerBound = Math.min(lowerBound, other.lowerBound); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
111 long meetMask = mask | other.mask; |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
112 if (meetLowerBound == lowerBound && meetUpperBound == upperBound && meetMask == mask) { |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
113 return this; |
5785
e5f0cf5b5627
more sophisticated float stamp
Lukas Stadler <lukas.stadler@jku.at>
parents:
5698
diff
changeset
|
114 } else if (meetLowerBound == other.lowerBound && meetUpperBound == other.upperBound && meetMask == other.mask) { |
e5f0cf5b5627
more sophisticated float stamp
Lukas Stadler <lukas.stadler@jku.at>
parents:
5698
diff
changeset
|
115 return other; |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
116 } else { |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
117 return new IntegerStamp(kind(), meetLowerBound, meetUpperBound, meetMask); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
118 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
119 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
120 |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
121 @Override |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
122 public int hashCode() { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
123 final int prime = 31; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
124 int result = 1; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
125 result = prime * result + (int) (lowerBound ^ (lowerBound >>> 32)); |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
126 result = prime * result + (int) (upperBound ^ (upperBound >>> 32)); |
5785
e5f0cf5b5627
more sophisticated float stamp
Lukas Stadler <lukas.stadler@jku.at>
parents:
5698
diff
changeset
|
127 result = prime * result + (int) (mask ^ (mask >>> 32)); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
128 return result; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
129 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
130 |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
131 @Override |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
132 public boolean equals(Object obj) { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
133 if (this == obj) { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
134 return true; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
135 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
136 if (obj == null || getClass() != obj.getClass()) { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
137 return false; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
138 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
139 IntegerStamp other = (IntegerStamp) obj; |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
140 if (lowerBound != other.lowerBound || upperBound != other.upperBound || mask != other.mask) { |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
141 return false; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
142 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
143 return true; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
144 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
145 |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
146 public static long defaultMask(Kind kind) { |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
147 if (kind == Kind.Int) { |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
148 return 0xFFFFFFFFL; |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
149 } else { |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
150 return 0xFFFFFFFFFFFFFFFFL; |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
151 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
152 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
153 |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
154 public static long maskFor(Kind kind, long lowerBound, long upperBound) { |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
155 long mask = lowerBound | upperBound; |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
156 if (mask == 0) { |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
157 return 0; |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
158 } else { |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
159 return ((-1L) >>> Long.numberOfLeadingZeros(mask)) & defaultMask(kind); |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
160 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
161 } |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
162 |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
163 } |