Mercurial > hg > truffle
annotate graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IntegerStamp.java @ 17430:ad62445b46b0
Revert 9010170f942f: better stamps for I2F, I2D, L2F and L2D operations
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Tue, 14 Oct 2014 12:12:01 +0200 |
parents | 83c3dd41ca64 |
children | 689092d5cf44 |
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 */ |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
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 |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
25 import static com.oracle.graal.compiler.common.calc.FloatConvert.*; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
26 |
11763
8f6917d1205f
IntegerStamp.toString: print full mask
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11387
diff
changeset
|
27 import java.util.*; |
8f6917d1205f
IntegerStamp.toString: print full mask
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11387
diff
changeset
|
28 |
17196
189479d72dc8
Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents:
16330
diff
changeset
|
29 import com.oracle.graal.api.code.*; |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5504
diff
changeset
|
30 import com.oracle.graal.api.meta.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15132
diff
changeset
|
31 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
|
32 import com.oracle.graal.compiler.common.spi.*; |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
33 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.BinaryOp; |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
34 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.FloatConvertOp; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
35 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.IntegerConvertOp; |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
36 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.UnaryOp; |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
37 |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
38 /** |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15198
diff
changeset
|
39 * 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
|
40 * |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
41 * 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
|
42 * (always set) bit-masks. |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
43 */ |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
44 public class IntegerStamp extends PrimitiveStamp { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
45 |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
46 private final long lowerBound; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
47 private final long upperBound; |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
48 private final long downMask; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
49 private final long upMask; |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
50 |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
51 public IntegerStamp(int bits, long lowerBound, long upperBound, long downMask, long upMask) { |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
52 super(bits, OPS); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
53 this.lowerBound = lowerBound; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
54 this.upperBound = upperBound; |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
55 this.downMask = downMask; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
56 this.upMask = upMask; |
17196
189479d72dc8
Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents:
16330
diff
changeset
|
57 assert lowerBound >= CodeUtil.minValue(bits) : this; |
189479d72dc8
Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents:
16330
diff
changeset
|
58 assert upperBound <= CodeUtil.maxValue(bits) : this; |
189479d72dc8
Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents:
16330
diff
changeset
|
59 assert (downMask & CodeUtil.mask(bits)) == downMask : this; |
189479d72dc8
Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents:
16330
diff
changeset
|
60 assert (upMask & CodeUtil.mask(bits)) == upMask : this; |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
61 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
62 |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
63 public static IntegerStamp stampForMask(int bits, long downMask, long upMask) { |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
64 long lowerBound; |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
65 long upperBound; |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
66 if (((upMask >>> (bits - 1)) & 1) == 0) { |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
67 lowerBound = downMask; |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
68 upperBound = upMask; |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
69 } else if (((downMask >>> (bits - 1)) & 1) == 1) { |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
70 lowerBound = downMask; |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
71 upperBound = upMask; |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
72 } else { |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
73 lowerBound = downMask | (-1L << (bits - 1)); |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
74 upperBound = CodeUtil.maxValue(bits) & upMask; |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
75 } |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
76 lowerBound = CodeUtil.convert(lowerBound, bits, false); |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
77 upperBound = CodeUtil.convert(upperBound, bits, false); |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
78 return new IntegerStamp(bits, lowerBound, upperBound, downMask, upMask); |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
79 } |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
80 |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
81 @Override |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
82 public IntegerStamp unrestricted() { |
17196
189479d72dc8
Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents:
16330
diff
changeset
|
83 return new IntegerStamp(getBits(), CodeUtil.minValue(getBits()), CodeUtil.maxValue(getBits()), 0, CodeUtil.mask(getBits())); |
13999
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 |
14997
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
87 public Stamp illegal() { |
17196
189479d72dc8
Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents:
16330
diff
changeset
|
88 return new IntegerStamp(getBits(), CodeUtil.maxValue(getBits()), CodeUtil.minValue(getBits()), CodeUtil.mask(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
|
89 } |
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
90 |
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
91 @Override |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15198
diff
changeset
|
92 public Stamp constant(Constant c, MetaAccessProvider meta) { |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15198
diff
changeset
|
93 long value = c.asLong(); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15198
diff
changeset
|
94 return StampFactory.forInteger(getBits(), value, value); |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15198
diff
changeset
|
95 } |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15198
diff
changeset
|
96 |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15198
diff
changeset
|
97 @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
|
98 public boolean isLegal() { |
15132 | 99 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
|
100 } |
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
101 |
5e4ae8709830
Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
102 @Override |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
103 public Kind getStackKind() { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
104 if (getBits() > 32) { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
105 return Kind.Long; |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
106 } else { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
107 return Kind.Int; |
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 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
110 |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
111 @Override |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15198
diff
changeset
|
112 public LIRKind getLIRKind(LIRKindTool tool) { |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
113 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
|
114 } |
0c38906450a0
Make conversion from Stamp to PlatformKind extensible by backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
115 |
0c38906450a0
Make conversion from Stamp to PlatformKind extensible by backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
116 @Override |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
117 public ResolvedJavaType javaType(MetaAccessProvider metaAccess) { |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
118 switch (getBits()) { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
119 case 1: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
120 return metaAccess.lookupJavaType(Boolean.TYPE); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
121 case 8: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
122 return metaAccess.lookupJavaType(Byte.TYPE); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
123 case 16: |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
124 return metaAccess.lookupJavaType(Short.TYPE); |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
125 case 32: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
126 return metaAccess.lookupJavaType(Integer.TYPE); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
127 case 64: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
128 return metaAccess.lookupJavaType(Long.TYPE); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
129 default: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
130 throw GraalInternalError.shouldNotReachHere(); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
131 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
132 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
133 |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
134 /** |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
135 * 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
|
136 */ |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
137 public long lowerBound() { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
138 return lowerBound; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
139 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
140 |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
141 /** |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
142 * 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
|
143 */ |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
144 public long upperBound() { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
145 return upperBound; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
146 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
147 |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
148 /** |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
149 * 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
|
150 */ |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
151 public long downMask() { |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
152 return downMask; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
153 } |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
154 |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
155 /** |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
156 * 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
|
157 */ |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
158 public long upMask() { |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
159 return upMask; |
5657
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 |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
162 public boolean isUnrestricted() { |
17196
189479d72dc8
Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents:
16330
diff
changeset
|
163 return lowerBound == CodeUtil.minValue(getBits()) && upperBound == CodeUtil.maxValue(getBits()) && downMask == 0 && upMask == CodeUtil.mask(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
|
164 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
165 |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
166 public boolean contains(long value) { |
17196
189479d72dc8
Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents:
16330
diff
changeset
|
167 return value >= lowerBound && value <= upperBound && (value & downMask) == downMask && (value & upMask) == (value & CodeUtil.mask(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
|
168 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5657
diff
changeset
|
169 |
6299
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
170 public boolean isPositive() { |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
171 return lowerBound() >= 0; |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
172 } |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
173 |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
174 public boolean isNegative() { |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
175 return upperBound() <= 0; |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
176 } |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
177 |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
178 public boolean isStrictlyPositive() { |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
179 return lowerBound() > 0; |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
180 } |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
181 |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
182 public boolean isStrictlyNegative() { |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
183 return upperBound() < 0; |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
184 } |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
185 |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
186 public boolean canBePositive() { |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
187 return upperBound() > 0; |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
188 } |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
189 |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
190 public boolean canBeNegative() { |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
191 return lowerBound() < 0; |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
192 } |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
193 |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
194 @Override |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
195 public String toString() { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
196 StringBuilder str = new StringBuilder(); |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
197 str.append('i'); |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
198 str.append(getBits()); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
199 if (lowerBound == upperBound) { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
200 str.append(" [").append(lowerBound).append(']'); |
17196
189479d72dc8
Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents:
16330
diff
changeset
|
201 } else if (lowerBound != CodeUtil.minValue(getBits()) || upperBound != CodeUtil.maxValue(getBits())) { |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
202 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
|
203 } |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
204 if (downMask != 0) { |
11763
8f6917d1205f
IntegerStamp.toString: print full mask
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11387
diff
changeset
|
205 str.append(" \u21ca"); |
8f6917d1205f
IntegerStamp.toString: print full mask
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11387
diff
changeset
|
206 new Formatter(str).format("%016x", downMask); |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
207 } |
17196
189479d72dc8
Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents:
16330
diff
changeset
|
208 if (upMask != CodeUtil.mask(getBits())) { |
11763
8f6917d1205f
IntegerStamp.toString: print full mask
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11387
diff
changeset
|
209 str.append(" \u21c8"); |
8f6917d1205f
IntegerStamp.toString: print full mask
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11387
diff
changeset
|
210 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
|
211 } |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
212 return str.toString(); |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
213 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
214 |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
215 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
|
216 assert getBits() == other.getBits(); |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15198
diff
changeset
|
217 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
|
218 return illegal(); |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
219 } 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
|
220 return this; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
221 } 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
|
222 return other; |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
223 } else { |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
224 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
|
225 } |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
226 } |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
227 |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
228 @Override |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
229 public Stamp meet(Stamp otherStamp) { |
11265 | 230 if (otherStamp == this) { |
231 return this; | |
232 } | |
233 if (!(otherStamp instanceof IntegerStamp)) { | |
11387
9088d13767f3
Keep a kind in the illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11352
diff
changeset
|
234 return StampFactory.illegal(Kind.Illegal); |
11265 | 235 } |
16328
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15198
diff
changeset
|
236 if (equals(otherStamp)) { |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15198
diff
changeset
|
237 return this; |
34ac3ddfd5ac
[SPARC] fixing findbug warnings
Stefan Anzinger <stefan.anzinger@gmail.com>
parents:
15198
diff
changeset
|
238 } |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
239 IntegerStamp other = (IntegerStamp) otherStamp; |
11352
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
240 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
|
241 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
242 |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
243 @Override |
5890
c241963cda6d
added Stamp.join, used by PiNodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
5830
diff
changeset
|
244 public Stamp join(Stamp otherStamp) { |
11265 | 245 if (otherStamp == this) { |
246 return this; | |
247 } | |
248 if (!(otherStamp instanceof IntegerStamp)) { | |
11387
9088d13767f3
Keep a kind in the illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11352
diff
changeset
|
249 return StampFactory.illegal(Kind.Illegal); |
11265 | 250 } |
5890
c241963cda6d
added Stamp.join, used by PiNodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
5830
diff
changeset
|
251 IntegerStamp other = (IntegerStamp) otherStamp; |
12542
7cf8b577b6e1
Fix integer stamp join for downMask/lowerBound
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11887
diff
changeset
|
252 long newDownMask = downMask | other.downMask; |
7cf8b577b6e1
Fix integer stamp join for downMask/lowerBound
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11887
diff
changeset
|
253 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
|
254 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
|
255 } |
c241963cda6d
added Stamp.join, used by PiNodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
5830
diff
changeset
|
256 |
c241963cda6d
added Stamp.join, used by PiNodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
5830
diff
changeset
|
257 @Override |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
258 public boolean isCompatible(Stamp stamp) { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
259 if (this == stamp) { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
260 return true; |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
261 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
262 if (stamp instanceof IntegerStamp) { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
263 IntegerStamp other = (IntegerStamp) stamp; |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
264 return getBits() == other.getBits(); |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
265 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
266 return false; |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
267 } |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
268 |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
269 @Override |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
270 public int hashCode() { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
271 final int prime = 31; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
272 int result = 1; |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
273 result = prime * result + super.hashCode(); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
274 result = prime * result + (int) (lowerBound ^ (lowerBound >>> 32)); |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
275 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
|
276 result = prime * result + (int) (downMask ^ (downMask >>> 32)); |
8185c119d731
"always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents:
11265
diff
changeset
|
277 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
|
278 return result; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
279 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
280 |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
281 @Override |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
282 public boolean equals(Object obj) { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
283 if (this == obj) { |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
284 return true; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
285 } |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
286 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
|
287 return false; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
288 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
289 IntegerStamp other = (IntegerStamp) obj; |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
290 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
|
291 return false; |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
292 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
293 return super.equals(other); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
294 } |
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
295 |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
296 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
|
297 long mask = lowerBound | upperBound; |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
298 if (mask == 0) { |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
299 return 0; |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
300 } else { |
17196
189479d72dc8
Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents:
16330
diff
changeset
|
301 return ((-1L) >>> Long.numberOfLeadingZeros(mask)) & CodeUtil.mask(bits); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
302 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5540
diff
changeset
|
303 } |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
304 |
6301
4535a87e8bf8
Fix for sameSign check and javadoc
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6299
diff
changeset
|
305 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7489
diff
changeset
|
306 * 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
|
307 * 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
|
308 * |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7489
diff
changeset
|
309 * @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
|
310 * negative |
6301
4535a87e8bf8
Fix for sameSign check and javadoc
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6299
diff
changeset
|
311 */ |
6299
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
312 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
|
313 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
|
314 } |
1ed726759f65
Add helper methods to IntegerStamp for sign, use them
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5890
diff
changeset
|
315 |
11265 | 316 @Override |
317 public Constant asConstant() { | |
318 if (lowerBound == upperBound) { | |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
319 switch (getBits()) { |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
320 case 1: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
321 return Constant.forBoolean(lowerBound != 0); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
322 case 8: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
323 return Constant.forByte((byte) lowerBound); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
324 case 16: |
15131
9c1e53adc159
Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
325 return Constant.forShort((short) lowerBound); |
13999
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
326 case 32: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
327 return Constant.forInt((int) lowerBound); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
328 case 64: |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
329 return Constant.forLong(lowerBound); |
f2b300c6e621
Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
13675
diff
changeset
|
330 } |
11265 | 331 } |
332 return null; | |
333 } | |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
334 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
335 private static boolean addOverflowsPositively(long x, long y, int bits) { |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
336 long result = x + y; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
337 if (bits == 64) { |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
338 return (~x & ~y & result) < 0; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
339 } else { |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
340 return result > CodeUtil.maxValue(bits); |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
341 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
342 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
343 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
344 private static boolean addOverflowsNegatively(long x, long y, int bits) { |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
345 long result = x + y; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
346 if (bits == 64) { |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
347 return (x & y & ~result) < 0; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
348 } else { |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
349 return result < CodeUtil.minValue(bits); |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
350 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
351 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
352 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
353 private static long carryBits(long x, long y) { |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
354 return (x + y) ^ x ^ y; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
355 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
356 |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
357 private static long saturate(long v, int bits) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
358 if (bits < 64) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
359 long max = CodeUtil.maxValue(bits); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
360 if (v > max) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
361 return max; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
362 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
363 long min = CodeUtil.minValue(bits); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
364 if (v < min) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
365 return min; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
366 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
367 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
368 return v; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
369 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
370 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
371 public static final ArithmeticOpTable OPS = new ArithmeticOpTable( |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
372 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
373 new UnaryOp.Neg() { |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
374 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
375 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
376 public Constant foldConstant(Constant value) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
377 return Constant.forIntegerKind(value.getKind(), -value.asLong()); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
378 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
379 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
380 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
381 public Stamp foldStamp(Stamp s) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
382 IntegerStamp stamp = (IntegerStamp) s; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
383 int bits = stamp.getBits(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
384 if (stamp.lowerBound() != CodeUtil.minValue(bits)) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
385 // TODO(ls) check if the mask calculation is correct... |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
386 return StampFactory.forInteger(bits, -stamp.upperBound(), -stamp.lowerBound()); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
387 } else { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
388 return stamp.unrestricted(); |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
389 } |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
390 } |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
391 }, |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
392 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
393 new BinaryOp.Add(true, true) { |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
394 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
395 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
396 public Constant foldConstant(Constant a, Constant b) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
397 assert a.getKind() == b.getKind(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
398 return Constant.forIntegerKind(a.getKind(), a.asLong() + b.asLong()); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
399 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
400 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
401 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
402 public Stamp foldStamp(Stamp stamp1, Stamp stamp2) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
403 IntegerStamp a = (IntegerStamp) stamp1; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
404 IntegerStamp b = (IntegerStamp) stamp2; |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
405 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
406 int bits = a.getBits(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
407 assert bits == b.getBits(); |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
408 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
409 if (a.isUnrestricted()) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
410 return a; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
411 } else if (b.isUnrestricted()) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
412 return b; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
413 } |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
414 long defaultMask = CodeUtil.mask(bits); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
415 long variableBits = (a.downMask() ^ a.upMask()) | (b.downMask() ^ b.upMask()); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
416 long variableBitsWithCarry = variableBits | (carryBits(a.downMask(), b.downMask()) ^ carryBits(a.upMask(), b.upMask())); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
417 long newDownMask = (a.downMask() + b.downMask()) & ~variableBitsWithCarry; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
418 long newUpMask = (a.downMask() + b.downMask()) | variableBitsWithCarry; |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
419 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
420 newDownMask &= defaultMask; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
421 newUpMask &= defaultMask; |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
422 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
423 long newLowerBound; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
424 long newUpperBound; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
425 boolean lowerOverflowsPositively = addOverflowsPositively(a.lowerBound(), b.lowerBound(), bits); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
426 boolean upperOverflowsPositively = addOverflowsPositively(a.upperBound(), b.upperBound(), bits); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
427 boolean lowerOverflowsNegatively = addOverflowsNegatively(a.lowerBound(), b.lowerBound(), bits); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
428 boolean upperOverflowsNegatively = addOverflowsNegatively(a.upperBound(), b.upperBound(), bits); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
429 if ((lowerOverflowsNegatively && !upperOverflowsNegatively) || (!lowerOverflowsPositively && upperOverflowsPositively)) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
430 newLowerBound = CodeUtil.minValue(bits); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
431 newUpperBound = CodeUtil.maxValue(bits); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
432 } else { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
433 newLowerBound = CodeUtil.signExtend((a.lowerBound() + b.lowerBound()) & defaultMask, bits); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
434 newUpperBound = CodeUtil.signExtend((a.upperBound() + b.upperBound()) & defaultMask, bits); |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
435 } |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
436 IntegerStamp limit = StampFactory.forInteger(bits, newLowerBound, newUpperBound); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
437 newUpMask &= limit.upMask(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
438 newUpperBound = CodeUtil.signExtend(newUpperBound & newUpMask, bits); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
439 newDownMask |= limit.downMask(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
440 newLowerBound |= newDownMask; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
441 return new IntegerStamp(bits, newLowerBound, newUpperBound, newDownMask, newUpMask); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
442 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
443 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
444 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
445 public boolean isNeutral(Constant n) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
446 return n.asLong() == 0; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
447 } |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
448 }, |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
449 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
450 new BinaryOp.Sub(true, false) { |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
451 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
452 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
453 public Constant foldConstant(Constant a, Constant b) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
454 assert a.getKind() == b.getKind(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
455 return Constant.forIntegerKind(a.getKind(), a.asLong() - b.asLong()); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
456 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
457 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
458 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
459 public Stamp foldStamp(Stamp a, Stamp b) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
460 return OPS.getAdd().foldStamp(a, OPS.getNeg().foldStamp(b)); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
461 } |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
462 |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
463 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
464 public boolean isNeutral(Constant n) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
465 return n.asLong() == 0; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
466 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
467 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
468 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
469 public Constant getZero(Stamp s) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
470 IntegerStamp stamp = (IntegerStamp) s; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
471 return Constant.forPrimitiveInt(stamp.getBits(), 0); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
472 } |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
473 }, |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
474 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
475 new BinaryOp.Mul(true, true) { |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
476 |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
477 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
478 public Constant foldConstant(Constant a, Constant b) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
479 assert a.getKind() == b.getKind(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
480 return Constant.forIntegerKind(a.getKind(), a.asLong() * b.asLong()); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
481 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
482 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
483 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
484 public Stamp foldStamp(Stamp stamp1, Stamp stamp2) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
485 IntegerStamp a = (IntegerStamp) stamp1; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
486 IntegerStamp b = (IntegerStamp) stamp2; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
487 if (a.upMask() == 0) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
488 return a; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
489 } else if (b.upMask() == 0) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
490 return b; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
491 } else { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
492 // TODO |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
493 return a.unrestricted(); |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
494 } |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
495 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
496 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
497 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
498 public boolean isNeutral(Constant n) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
499 return n.asLong() == 1; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
500 } |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
501 }, |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
502 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
503 new BinaryOp.Div(true, false) { |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
504 |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
505 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
506 public Constant foldConstant(Constant a, Constant b) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
507 assert a.getKind() == b.getKind(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
508 return Constant.forIntegerKind(a.getKind(), a.asLong() / b.asLong()); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
509 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
510 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
511 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
512 public Stamp foldStamp(Stamp stamp1, Stamp stamp2) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
513 IntegerStamp a = (IntegerStamp) stamp1; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
514 IntegerStamp b = (IntegerStamp) stamp2; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
515 assert a.getBits() == b.getBits(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
516 if (b.isStrictlyPositive()) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
517 long newLowerBound = a.lowerBound() / b.lowerBound(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
518 long newUpperBound = a.upperBound() / b.lowerBound(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
519 return StampFactory.forInteger(a.getBits(), newLowerBound, newUpperBound); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
520 } else { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
521 return a.unrestricted(); |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
522 } |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
523 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
524 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
525 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
526 public boolean isNeutral(Constant n) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
527 return n.asLong() == 1; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
528 } |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
529 }, |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
530 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
531 new BinaryOp.Rem(false, false) { |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
532 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
533 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
534 public Constant foldConstant(Constant a, Constant b) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
535 assert a.getKind() == b.getKind(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
536 return Constant.forIntegerKind(a.getKind(), a.asLong() % b.asLong()); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
537 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
538 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
539 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
540 public Stamp foldStamp(Stamp stamp1, Stamp stamp2) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
541 IntegerStamp a = (IntegerStamp) stamp1; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
542 IntegerStamp b = (IntegerStamp) stamp2; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
543 assert a.getBits() == b.getBits(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
544 // zero is always possible |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
545 long newLowerBound = Math.min(a.lowerBound(), 0); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
546 long newUpperBound = Math.max(a.upperBound(), 0); |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
547 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
548 long magnitude; // the maximum absolute value of the result, derived from b |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
549 if (b.lowerBound() == CodeUtil.minValue(b.getBits())) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
550 // Math.abs(...) - 1 does not work in a case |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
551 magnitude = CodeUtil.maxValue(b.getBits()); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
552 } else { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
553 magnitude = Math.max(Math.abs(b.lowerBound()), Math.abs(b.upperBound())) - 1; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
554 } |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
555 newLowerBound = Math.max(newLowerBound, -magnitude); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
556 newUpperBound = Math.min(newUpperBound, magnitude); |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
17196
diff
changeset
|
557 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
558 return StampFactory.forInteger(a.getBits(), newLowerBound, newUpperBound); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
559 } |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
560 }, |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
561 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
562 new UnaryOp.Not() { |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
563 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
564 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
565 public Constant foldConstant(Constant value) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
566 return Constant.forIntegerKind(value.getKind(), ~value.asLong()); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
567 } |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
568 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
569 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
570 public Stamp foldStamp(Stamp stamp) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
571 IntegerStamp integerStamp = (IntegerStamp) stamp; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
572 int bits = integerStamp.getBits(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
573 long defaultMask = CodeUtil.mask(bits); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
574 return new IntegerStamp(bits, ~integerStamp.upperBound(), ~integerStamp.lowerBound(), (~integerStamp.upMask()) & defaultMask, (~integerStamp.downMask()) & defaultMask); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
575 } |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
576 }, |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
577 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
578 new BinaryOp.And(true, true) { |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
579 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
580 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
581 public Constant foldConstant(Constant a, Constant b) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
582 assert a.getKind() == b.getKind(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
583 return Constant.forIntegerKind(a.getKind(), a.asLong() & b.asLong()); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
584 } |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
585 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
586 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
587 public Stamp foldStamp(Stamp stamp1, Stamp stamp2) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
588 IntegerStamp a = (IntegerStamp) stamp1; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
589 IntegerStamp b = (IntegerStamp) stamp2; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
590 assert a.getBits() == b.getBits(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
591 return stampForMask(a.getBits(), a.downMask() & b.downMask(), a.upMask() & b.upMask()); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
592 } |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
593 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
594 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
595 public boolean isNeutral(Constant n) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
596 int bits = n.getKind().getBitCount(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
597 long mask = CodeUtil.mask(bits); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
598 return (n.asLong() & mask) == mask; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
599 } |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
600 }, |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
601 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
602 new BinaryOp.Or(true, true) { |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
603 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
604 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
605 public Constant foldConstant(Constant a, Constant b) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
606 assert a.getKind() == b.getKind(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
607 return Constant.forIntegerKind(a.getKind(), a.asLong() | b.asLong()); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
608 } |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
609 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
610 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
611 public Stamp foldStamp(Stamp stamp1, Stamp stamp2) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
612 IntegerStamp a = (IntegerStamp) stamp1; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
613 IntegerStamp b = (IntegerStamp) stamp2; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
614 assert a.getBits() == b.getBits(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
615 return stampForMask(a.getBits(), a.downMask() | b.downMask(), a.upMask() | b.upMask()); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
616 } |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
617 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
618 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
619 public boolean isNeutral(Constant n) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
620 return n.asLong() == 0; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
621 } |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
622 }, |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
623 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
624 new BinaryOp.Xor(true, true) { |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
625 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
626 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
627 public Constant foldConstant(Constant a, Constant b) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
628 assert a.getKind() == b.getKind(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
629 return Constant.forIntegerKind(a.getKind(), a.asLong() ^ b.asLong()); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
630 } |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
631 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
632 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
633 public Stamp foldStamp(Stamp stamp1, Stamp stamp2) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
634 IntegerStamp a = (IntegerStamp) stamp1; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
635 IntegerStamp b = (IntegerStamp) stamp2; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
636 assert a.getBits() == b.getBits(); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
637 |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
638 long variableBits = (a.downMask() ^ a.upMask()) | (b.downMask() ^ b.upMask()); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
639 long newDownMask = (a.downMask() ^ b.downMask()) & ~variableBits; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
640 long newUpMask = (a.downMask() ^ b.downMask()) | variableBits; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
641 return stampForMask(a.getBits(), newDownMask, newUpMask); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
642 } |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
643 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
644 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
645 public boolean isNeutral(Constant n) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
646 return n.asLong() == 0; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
647 } |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
648 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
649 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
650 public Constant getZero(Stamp s) { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
651 IntegerStamp stamp = (IntegerStamp) s; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
652 return Constant.forPrimitiveInt(stamp.getBits(), 0); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
653 } |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
654 }, |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
655 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
656 new IntegerConvertOp.ZeroExtend() { |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
657 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
658 @Override |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
659 public Constant foldConstant(int inputBits, int resultBits, Constant value) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
660 return Constant.forPrimitiveInt(resultBits, CodeUtil.zeroExtend(value.asLong(), inputBits)); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
661 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
662 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
663 @Override |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
664 public Stamp foldStamp(int resultBits, Stamp input) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
665 IntegerStamp stamp = (IntegerStamp) input; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
666 int inputBits = stamp.getBits(); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
667 assert inputBits <= resultBits; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
668 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
669 long downMask = CodeUtil.zeroExtend(stamp.downMask(), inputBits); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
670 long upMask = CodeUtil.zeroExtend(stamp.upMask(), inputBits); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
671 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
672 if (stamp.lowerBound() < 0 && stamp.upperBound() >= 0) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
673 // signed range including 0 and -1 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
674 // after sign extension, the whole range from 0 to MAX_INT is possible |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
675 return IntegerStamp.stampForMask(resultBits, downMask, upMask); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
676 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
677 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
678 long lowerBound = CodeUtil.zeroExtend(stamp.lowerBound(), inputBits); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
679 long upperBound = CodeUtil.zeroExtend(stamp.upperBound(), inputBits); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
680 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
681 return new IntegerStamp(resultBits, lowerBound, upperBound, downMask, upMask); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
682 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
683 }, |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
684 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
685 new IntegerConvertOp.SignExtend() { |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
686 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
687 @Override |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
688 public Constant foldConstant(int inputBits, int resultBits, Constant value) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
689 return Constant.forPrimitiveInt(resultBits, CodeUtil.signExtend(value.asLong(), inputBits)); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
690 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
691 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
692 @Override |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
693 public Stamp foldStamp(int resultBits, Stamp input) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
694 IntegerStamp stamp = (IntegerStamp) input; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
695 int inputBits = stamp.getBits(); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
696 assert inputBits <= resultBits; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
697 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
698 long defaultMask = CodeUtil.mask(resultBits); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
699 long downMask = CodeUtil.signExtend(stamp.downMask(), inputBits) & defaultMask; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
700 long upMask = CodeUtil.signExtend(stamp.upMask(), inputBits) & defaultMask; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
701 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
702 return new IntegerStamp(resultBits, stamp.lowerBound(), stamp.upperBound(), downMask, upMask); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
703 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
704 }, |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
705 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
706 new IntegerConvertOp.Narrow() { |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
707 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
708 @Override |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
709 public Constant foldConstant(int inputBits, int resultBits, Constant value) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
710 return Constant.forPrimitiveInt(resultBits, CodeUtil.narrow(value.asLong(), resultBits)); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
711 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
712 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
713 @Override |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
714 public Stamp foldStamp(int resultBits, Stamp input) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
715 IntegerStamp stamp = (IntegerStamp) input; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
716 int inputBits = stamp.getBits(); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
717 assert resultBits <= inputBits; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
718 if (resultBits == inputBits) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
719 return stamp; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
720 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
721 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
722 final long upperBound; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
723 if (stamp.lowerBound() < CodeUtil.minValue(resultBits)) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
724 upperBound = CodeUtil.maxValue(resultBits); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
725 } else { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
726 upperBound = saturate(stamp.upperBound(), resultBits); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
727 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
728 final long lowerBound; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
729 if (stamp.upperBound() > CodeUtil.maxValue(resultBits)) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
730 lowerBound = CodeUtil.minValue(resultBits); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
731 } else { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
732 lowerBound = saturate(stamp.lowerBound(), resultBits); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
733 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
734 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
735 long defaultMask = CodeUtil.mask(resultBits); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
736 long newDownMask = stamp.downMask() & defaultMask; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
737 long newUpMask = stamp.upMask() & defaultMask; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
738 long newLowerBound = CodeUtil.signExtend((lowerBound | newDownMask) & newUpMask, resultBits); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
739 long newUpperBound = CodeUtil.signExtend((upperBound | newDownMask) & newUpMask, resultBits); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
740 return new IntegerStamp(resultBits, newLowerBound, newUpperBound, newDownMask, newUpMask); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
741 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
742 }, |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
743 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
744 new FloatConvertOp(I2F) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
745 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
746 @Override |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
747 public Constant foldConstant(Constant value) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
748 return Constant.forFloat(value.asInt()); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
749 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
750 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
751 @Override |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
752 public Stamp foldStamp(Stamp input) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
753 IntegerStamp stamp = (IntegerStamp) input; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
754 assert stamp.getBits() == 32; |
17430
ad62445b46b0
Revert 9010170f942f: better stamps for I2F, I2D, L2F and L2D operations
Roland Schatz <roland.schatz@oracle.com>
parents:
17419
diff
changeset
|
755 return StampFactory.forKind(Kind.Float); |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
756 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
757 }, |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
758 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
759 new FloatConvertOp(L2F) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
760 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
761 @Override |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
762 public Constant foldConstant(Constant value) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
763 return Constant.forFloat(value.asLong()); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
764 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
765 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
766 @Override |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
767 public Stamp foldStamp(Stamp input) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
768 IntegerStamp stamp = (IntegerStamp) input; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
769 assert stamp.getBits() == 64; |
17430
ad62445b46b0
Revert 9010170f942f: better stamps for I2F, I2D, L2F and L2D operations
Roland Schatz <roland.schatz@oracle.com>
parents:
17419
diff
changeset
|
770 return StampFactory.forKind(Kind.Float); |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
771 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
772 }, |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
773 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
774 new FloatConvertOp(I2D) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
775 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
776 @Override |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
777 public Constant foldConstant(Constant value) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
778 return Constant.forDouble(value.asInt()); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
779 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
780 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
781 @Override |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
782 public Stamp foldStamp(Stamp input) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
783 IntegerStamp stamp = (IntegerStamp) input; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
784 assert stamp.getBits() == 32; |
17430
ad62445b46b0
Revert 9010170f942f: better stamps for I2F, I2D, L2F and L2D operations
Roland Schatz <roland.schatz@oracle.com>
parents:
17419
diff
changeset
|
785 return StampFactory.forKind(Kind.Double); |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
786 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
787 }, |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
788 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
789 new FloatConvertOp(L2D) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
790 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
791 @Override |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
792 public Constant foldConstant(Constant value) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
793 return Constant.forDouble(value.asLong()); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
794 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
795 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
796 @Override |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
797 public Stamp foldStamp(Stamp input) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
798 IntegerStamp stamp = (IntegerStamp) input; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
799 assert stamp.getBits() == 64; |
17430
ad62445b46b0
Revert 9010170f942f: better stamps for I2F, I2D, L2F and L2D operations
Roland Schatz <roland.schatz@oracle.com>
parents:
17419
diff
changeset
|
800 return StampFactory.forKind(Kind.Double); |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
801 } |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
802 }); |
5443
141817e206d4
changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
803 } |