annotate graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/IntegerStampTest.java @ 21597:c0f9aa6dc4cd

Introduce StackStoreOp.
author Josef Eisl <josef.eisl@jku.at>
date Thu, 28 May 2015 13:06:01 +0200
parents 48c1ebd24120
children 0e095e2c24e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
1 /*
18839
1b7dbb81df4f Use ArithmeticOpTable for shift operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
4 *
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
7 * published by the Free Software Foundation.
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
8 *
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
13 * accompanied this code).
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
14 *
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
18 *
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
21 * questions.
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
22 */
11385
e119ba892b45 Rename StampTest to ObjectStampJoinTest and move IntegerStampTest to com.oracle.graal.nodes.test
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11357
diff changeset
23 package com.oracle.graal.nodes.test;
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
24
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 20928
diff changeset
25 import com.oracle.jvmci.meta.Kind;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 20928
diff changeset
26 import com.oracle.jvmci.meta.JavaConstant;
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
27 import static org.junit.Assert.*;
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
28
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
29 import org.junit.*;
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
30
17344
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
31 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.IntegerConvertOp;
18839
1b7dbb81df4f Use ArithmeticOpTable for shift operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
32 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.ShiftOp;
15198
2c0cfbf454b5 Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15131
diff changeset
33 import com.oracle.graal.compiler.common.type.*;
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
34 import com.oracle.graal.nodes.*;
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19250
diff changeset
35 import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
36
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
37 /**
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
38 * This class tests that integer stamps are created correctly for constants.
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
39 */
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
40 public class IntegerStampTest {
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
41
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
42 private StructuredGraph graph;
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
43
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
44 private static Stamp addIntStamp(Stamp a, Stamp b) {
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
45 return IntegerStamp.OPS.getAdd().foldStamp(a, b);
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
46 }
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
47
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
48 @Before
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
49 public void before() {
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19250
diff changeset
50 graph = new StructuredGraph(AllowAssumptions.YES);
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
51 }
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
52
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
53 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
54 public void testBooleanConstant() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
55 assertEquals(new IntegerStamp(32, 1, 1, 0x1, 0x1), ConstantNode.forBoolean(true, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
56 assertEquals(new IntegerStamp(32, 0, 0, 0x0, 0x0), ConstantNode.forBoolean(false, graph).stamp());
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
57 }
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
58
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
59 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
60 public void testByteConstant() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
61 assertEquals(new IntegerStamp(32, 0, 0, 0x0, 0x0), ConstantNode.forByte((byte) 0, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
62 assertEquals(new IntegerStamp(32, 16, 16, 0x10, 0x10), ConstantNode.forByte((byte) 16, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
63 assertEquals(new IntegerStamp(32, -16, -16, 0xfffffff0L, 0xfffffff0L), ConstantNode.forByte((byte) -16, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
64 assertEquals(new IntegerStamp(32, 127, 127, 0x7f, 0x7f), ConstantNode.forByte((byte) 127, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
65 assertEquals(new IntegerStamp(32, -128, -128, 0xffffff80L, 0xffffff80L), ConstantNode.forByte((byte) -128, graph).stamp());
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
66 }
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
67
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
68 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
69 public void testShortConstant() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
70 assertEquals(new IntegerStamp(32, 0, 0, 0x0, 0x0), ConstantNode.forShort((short) 0, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
71 assertEquals(new IntegerStamp(32, 128, 128, 0x80, 0x80), ConstantNode.forShort((short) 128, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
72 assertEquals(new IntegerStamp(32, -128, -128, 0xffffff80L, 0xffffff80L), ConstantNode.forShort((short) -128, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
73 assertEquals(new IntegerStamp(32, 32767, 32767, 0x7fff, 0x7fff), ConstantNode.forShort((short) 32767, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
74 assertEquals(new IntegerStamp(32, -32768, -32768, 0xffff8000L, 0xffff8000L), ConstantNode.forShort((short) -32768, graph).stamp());
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
75 }
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
76
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
77 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
78 public void testCharConstant() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
79 assertEquals(new IntegerStamp(32, 0, 0, 0x0, 0x0), ConstantNode.forChar((char) 0, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
80 assertEquals(new IntegerStamp(32, 'A', 'A', 'A', 'A'), ConstantNode.forChar('A', graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
81 assertEquals(new IntegerStamp(32, 128, 128, 0x80, 0x80), ConstantNode.forChar((char) 128, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
82 assertEquals(new IntegerStamp(32, 65535, 65535, 0xffff, 0xffff), ConstantNode.forChar((char) 65535, graph).stamp());
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
83 }
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
84
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
85 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
86 public void testIntConstant() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
87 assertEquals(new IntegerStamp(32, 0, 0, 0x0, 0x0), ConstantNode.forInt(0, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
88 assertEquals(new IntegerStamp(32, 128, 128, 0x80, 0x80), ConstantNode.forInt(128, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
89 assertEquals(new IntegerStamp(32, -128, -128, 0xffffff80L, 0xffffff80L), ConstantNode.forInt(-128, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
90 assertEquals(new IntegerStamp(32, Integer.MAX_VALUE, Integer.MAX_VALUE, 0x7fffffff, 0x7fffffff), ConstantNode.forInt(Integer.MAX_VALUE, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
91 assertEquals(new IntegerStamp(32, Integer.MIN_VALUE, Integer.MIN_VALUE, 0x80000000L, 0x80000000L), ConstantNode.forInt(Integer.MIN_VALUE, graph).stamp());
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
92 }
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
93
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
94 @Test
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
95 public void testLongConstant() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
96 assertEquals(new IntegerStamp(64, 0, 0, 0x0, 0x0), ConstantNode.forLong(0, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
97 assertEquals(new IntegerStamp(64, 128, 128, 0x80, 0x80), ConstantNode.forLong(128, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
98 assertEquals(new IntegerStamp(64, -128, -128, 0xffffffffffffff80L, 0xffffffffffffff80L), ConstantNode.forLong(-128, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
99 assertEquals(new IntegerStamp(64, Long.MAX_VALUE, Long.MAX_VALUE, 0x7fffffffffffffffL, 0x7fffffffffffffffL), ConstantNode.forLong(Long.MAX_VALUE, graph).stamp());
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
100 assertEquals(new IntegerStamp(64, Long.MIN_VALUE, Long.MIN_VALUE, 0x8000000000000000L, 0x8000000000000000L), ConstantNode.forLong(Long.MIN_VALUE, graph).stamp());
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
101 }
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
102
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
103 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
104 public void testPositiveRanges() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
105 assertEquals(new IntegerStamp(32, 0, 0, 0, 0), StampFactory.forInteger(Kind.Int, 0, 0));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
106 assertEquals(new IntegerStamp(32, 0, 1, 0, 1), StampFactory.forInteger(Kind.Int, 0, 1));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
107 assertEquals(new IntegerStamp(32, 0, 0x123, 0, 0x1ff), StampFactory.forInteger(Kind.Int, 0, 0x123));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
108 assertEquals(new IntegerStamp(32, 0x120, 0x123, 0x120, 0x123), StampFactory.forInteger(Kind.Int, 0x120, 0x123));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
109 assertEquals(new IntegerStamp(32, 10000, 15000, 0x2000, 0x3fff), StampFactory.forInteger(Kind.Int, 10000, 15000));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
110 assertEquals(new IntegerStamp(64, 0, 1, 0, 1), StampFactory.forInteger(Kind.Long, 0, 1));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
111 assertEquals(new IntegerStamp(64, 10000, 15000, 0x2000, 0x3fff), StampFactory.forInteger(Kind.Long, 10000, 15000));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
112 assertEquals(new IntegerStamp(64, 140000000000L, 150000000000L, 0x2000000000L, 0x23ffffffffL), StampFactory.forInteger(Kind.Long, 140000000000L, 150000000000L));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
113 }
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
114
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
115 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
116 public void testNegativeRanges() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
117 assertEquals(new IntegerStamp(32, -2, -1, 0xfffffffeL, 0xffffffffL), StampFactory.forInteger(Kind.Int, -2, -1));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
118 assertEquals(new IntegerStamp(32, -20, -10, 0xffffffe0L, 0xffffffffL), StampFactory.forInteger(Kind.Int, -20, -10));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
119 assertEquals(new IntegerStamp(32, -10000, 0, 0, 0xffffffffL), StampFactory.forInteger(Kind.Int, -10000, 0));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
120 assertEquals(new IntegerStamp(32, -10000, -1, 0xffffc000L, 0xffffffffL), StampFactory.forInteger(Kind.Int, -10000, -1));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
121 assertEquals(new IntegerStamp(32, -10010, -10000, 0xffffd8e0L, 0xffffd8ffL), StampFactory.forInteger(Kind.Int, -10010, -10000));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
122 assertEquals(new IntegerStamp(64, -2, -1, 0xfffffffffffffffeL, 0xffffffffffffffffL), StampFactory.forInteger(Kind.Long, -2, -1));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
123 assertEquals(new IntegerStamp(64, -10010, -10000, 0xffffffffffffd8e0L, 0xffffffffffffd8ffL), StampFactory.forInteger(Kind.Long, -10010, -10000));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
124 assertEquals(new IntegerStamp(64, -150000000000L, -140000000000L, 0xffffffdc00000000L, 0xffffffdfffffffffL), StampFactory.forInteger(Kind.Long, -150000000000L, -140000000000L));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
125 }
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
126
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
127 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
128 public void testMixedRanges() {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
129 assertEquals(new IntegerStamp(32, -1, 0, 0, 0xffffffffL), StampFactory.forInteger(Kind.Int, -1, 0));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
130 assertEquals(new IntegerStamp(32, -10000, 1000, 0, 0xffffffffL), StampFactory.forInteger(Kind.Int, -10000, 1000));
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
131 assertEquals(new IntegerStamp(64, -10000, 1000, 0, 0xffffffffffffffffL), StampFactory.forInteger(Kind.Long, -10000, 1000));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
132 }
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
133
18124
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
134 private static Stamp narrowingKindConversion(IntegerStamp stamp, Kind kind) {
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
135 Stamp narrow = IntegerStamp.OPS.getNarrow().foldStamp(stamp.getBits(), kind.getBitCount(), stamp);
17419
83c3dd41ca64 Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents: 17344
diff changeset
136 IntegerConvertOp<?> implicitExtend = kind.isUnsigned() ? IntegerStamp.OPS.getZeroExtend() : IntegerStamp.OPS.getSignExtend();
18124
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
137 return implicitExtend.foldStamp(kind.getBitCount(), 32, narrow);
17344
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
138 }
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
139
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
140 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
141 public void testNarrowingConversions() {
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
142 // byte cases
17344
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
143 assertEquals(StampFactory.forInteger(Kind.Int, 0, 0), narrowingKindConversion(StampFactory.forInteger(Kind.Int, 0, 0), Kind.Byte));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
144 assertEquals(StampFactory.forInteger(Kind.Int, 0, 10), narrowingKindConversion(StampFactory.forInteger(Kind.Int, 0, 10), Kind.Byte));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
145 assertEquals(StampFactory.forInteger(Kind.Int, 10, 20), narrowingKindConversion(StampFactory.forInteger(Kind.Int, 10, 20), Kind.Byte));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
146 assertEquals(StampFactory.forInteger(Kind.Int, -10, 0), narrowingKindConversion(StampFactory.forInteger(Kind.Int, -10, 0), Kind.Byte));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
147 assertEquals(StampFactory.forInteger(Kind.Int, -20, -10), narrowingKindConversion(StampFactory.forInteger(Kind.Int, -20, -10), Kind.Byte));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
148 assertEquals(StampFactory.forInteger(Kind.Int, Byte.MIN_VALUE, Byte.MAX_VALUE), narrowingKindConversion(StampFactory.forInteger(Kind.Int, 100, 200), Kind.Byte));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
149 assertEquals(StampFactory.forInteger(Kind.Int, Byte.MIN_VALUE, Byte.MAX_VALUE), narrowingKindConversion(StampFactory.forInteger(Kind.Int, -100, 200), Kind.Byte));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
150 assertEquals(StampFactory.forInteger(Kind.Int, Byte.MIN_VALUE, Byte.MAX_VALUE), narrowingKindConversion(StampFactory.forInteger(Kind.Int, -200, -100), Kind.Byte));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
151 // char cases
17344
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
152 assertEquals(StampFactory.forInteger(Kind.Int, 0, 10), narrowingKindConversion(StampFactory.forInteger(Kind.Int, 0, 10), Kind.Char));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
153 assertEquals(StampFactory.forInteger(Kind.Int, 10, 20), narrowingKindConversion(StampFactory.forInteger(Kind.Int, 10, 20), Kind.Char));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
154 assertEquals(StampFactory.forInteger(Kind.Int, Character.MIN_VALUE, Character.MAX_VALUE), narrowingKindConversion(StampFactory.forInteger(Kind.Int, 20000, 80000), Kind.Char));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
155 assertEquals(StampFactory.forInteger(Kind.Int, Character.MIN_VALUE, Character.MAX_VALUE), narrowingKindConversion(StampFactory.forInteger(Kind.Int, -10000, 40000), Kind.Char));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
156 assertEquals(StampFactory.forInteger(Kind.Int, Character.MIN_VALUE, Character.MAX_VALUE), narrowingKindConversion(StampFactory.forInteger(Kind.Int, -40000, -10000), Kind.Char));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
157 // short cases
17344
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
158 assertEquals(StampFactory.forInteger(Kind.Int, 0, 10), narrowingKindConversion(StampFactory.forInteger(Kind.Int, 0, 10), Kind.Short));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
159 assertEquals(StampFactory.forInteger(Kind.Int, 10, 20), narrowingKindConversion(StampFactory.forInteger(Kind.Int, 10, 20), Kind.Short));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
160 assertEquals(StampFactory.forInteger(Kind.Int, Short.MIN_VALUE, Short.MAX_VALUE), narrowingKindConversion(StampFactory.forInteger(Kind.Int, 20000, 40000), Kind.Short));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
161 assertEquals(StampFactory.forInteger(Kind.Int, Short.MIN_VALUE, Short.MAX_VALUE), narrowingKindConversion(StampFactory.forInteger(Kind.Int, -10000, 40000), Kind.Short));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
162 assertEquals(StampFactory.forInteger(Kind.Int, Short.MIN_VALUE, Short.MAX_VALUE), narrowingKindConversion(StampFactory.forInteger(Kind.Int, -40000, -10000), Kind.Short));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
163 // int cases
17344
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
164 assertEquals(StampFactory.forInteger(Kind.Int, 0, 10), narrowingKindConversion(StampFactory.forInteger(Kind.Long, 0, 10), Kind.Int));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
165 assertEquals(StampFactory.forInteger(Kind.Int, 10, 20), narrowingKindConversion(StampFactory.forInteger(Kind.Long, 10, 20), Kind.Int));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
166 assertEquals(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, Integer.MAX_VALUE), narrowingKindConversion(StampFactory.forInteger(Kind.Long, 20000000000L, 40000000000L), Kind.Int));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
167 assertEquals(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, Integer.MAX_VALUE), narrowingKindConversion(StampFactory.forInteger(Kind.Long, -10000000000L, 40000000000L), Kind.Int));
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17199
diff changeset
168 assertEquals(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, Integer.MAX_VALUE), narrowingKindConversion(StampFactory.forInteger(Kind.Long, -40000000000L, -10000000000L), Kind.Int));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
169 }
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
170
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
171 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
172 public void testXor() {
17199
88012c1750a0 Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents: 17198
diff changeset
173 assertEquals(new IntegerStamp(32, 0, 0xff, 0, 0xff), IntegerStamp.OPS.getXor().foldStamp(new IntegerStamp(32, 0, 0, 0, 0), new IntegerStamp(32, 0, 0xff, 0, 0xff)));
88012c1750a0 Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents: 17198
diff changeset
174 assertEquals(new IntegerStamp(32, 0x10, 0x1f, 0x10, 0x1f), IntegerStamp.OPS.getXor().foldStamp(new IntegerStamp(32, 0, 0, 0, 0), new IntegerStamp(32, 0x10, 0x1f, 0x10, 0x1f)));
88012c1750a0 Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents: 17198
diff changeset
175 assertEquals(new IntegerStamp(32, 0x0, 0xf, 0x0, 0xf), IntegerStamp.OPS.getXor().foldStamp(new IntegerStamp(32, 0x10, 0x10, 0x10, 0x10), new IntegerStamp(32, 0x10, 0x1f, 0x10, 0x1f)));
88012c1750a0 Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents: 17198
diff changeset
176 assertEquals(new IntegerStamp(32, 0x10, 0x1f, 0x10, 0x1f), IntegerStamp.OPS.getXor().foldStamp(new IntegerStamp(32, 0x10, 0x10, 0x10, 0x10), new IntegerStamp(32, 0x0, 0xf, 0x0, 0xf)));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
177 }
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
178
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
179 @Test
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
180 public void testNot() {
17199
88012c1750a0 Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents: 17198
diff changeset
181 assertEquals(new IntegerStamp(32, -11, -1, 0xffff_fff0L, 0xffff_ffffL), IntegerStamp.OPS.getNot().foldStamp(new IntegerStamp(32, 0, 10, 0, 0xf)));
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
182 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
183
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
184 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
185 public void testAddIntSimple() {
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
186 assertEquals(StampFactory.forInteger(Kind.Int, 0, 30, 0, 31), addIntStamp(StampFactory.forInteger(Kind.Int, 0, 10), StampFactory.forInteger(Kind.Int, 0, 20)));
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
187 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
188
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
189 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
190 public void testAddNegativeOverFlowInt1() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
191 assertEquals(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, 0xffff_ffffL),
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
192 addIntStamp(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, 0), StampFactory.forInteger(Kind.Int, -1, 0)));
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
193 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
194
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
195 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
196 public void testAddNegativeOverFlowInt2() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
197 assertEquals(StampFactory.forInteger(Kind.Int, Integer.MAX_VALUE - 2, Integer.MAX_VALUE, 0x7fff_fffcL, 0x7fff_ffffL),
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
198 addIntStamp(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, Integer.MIN_VALUE + 1), StampFactory.forInteger(Kind.Int, -3, -2)));
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
199 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
200
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
201 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
202 public void testAddPositiveOverFlowInt1() {
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
203 assertEquals(StampFactory.forKind(Kind.Int), addIntStamp(StampFactory.forInteger(Kind.Int, 0, 1), StampFactory.forInteger(Kind.Int, 0, Integer.MAX_VALUE)));
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
204 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
205
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
206 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
207 public void testAddPositiveOverFlowInt2() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
208 assertEquals(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, Integer.MIN_VALUE + 2),
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
209 addIntStamp(StampFactory.forInteger(Kind.Int, Integer.MAX_VALUE - 1, Integer.MAX_VALUE), StampFactory.forInteger(Kind.Int, 2, 3)));
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
210 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
211
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
212 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
213 public void testAddOverFlowsInt() {
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
214 assertEquals(StampFactory.forKind(Kind.Int), addIntStamp(StampFactory.forInteger(Kind.Int, -1, 1), StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE, Integer.MAX_VALUE)));
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
215 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
216
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
217 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
218 public void testAddLongSimple() {
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
219 assertEquals(StampFactory.forInteger(Kind.Long, 0, 30, 0, 31), addIntStamp(StampFactory.forInteger(Kind.Long, 0, 10), StampFactory.forInteger(Kind.Long, 0, 20)));
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
220 }
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
221
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
222 @Test
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
223 public void testAddNegativOverFlowLong1() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
224 assertEquals(StampFactory.forInteger(Kind.Long, Long.MIN_VALUE, Long.MAX_VALUE, 0, 0xffff_ffff_ffff_ffffL),
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
225 addIntStamp(StampFactory.forInteger(Kind.Long, Long.MIN_VALUE, Long.MIN_VALUE + 1), StampFactory.forInteger(Kind.Long, Integer.MIN_VALUE, Integer.MAX_VALUE)));
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
226 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
227
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
228 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
229 public void testAddNegativeOverFlowLong2() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
230 assertEquals(StampFactory.forInteger(Kind.Long, Long.MAX_VALUE - 2, Long.MAX_VALUE),
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
231 addIntStamp(StampFactory.forInteger(Kind.Long, Long.MIN_VALUE, Long.MIN_VALUE + 1), StampFactory.forInteger(Kind.Long, -3, -2)));
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
232 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
233
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
234 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
235 public void testAddPositiveOverFlowLong1() {
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
236 assertEquals(StampFactory.forKind(Kind.Long), addIntStamp(StampFactory.forInteger(Kind.Long, 0, 1), StampFactory.forInteger(Kind.Long, 0, Long.MAX_VALUE)));
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
237 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
238
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
239 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
240 public void testAddPositiveOverFlowLong2() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
241 assertEquals(StampFactory.forInteger(Kind.Long, Long.MIN_VALUE, Long.MIN_VALUE + 2),
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
242 addIntStamp(StampFactory.forInteger(Kind.Long, Long.MAX_VALUE - 1, Long.MAX_VALUE), StampFactory.forInteger(Kind.Long, 2, 3)));
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
243 }
12562
035474349265 Serveral fixes to StampTool.add and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12449
diff changeset
244
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
245 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
246 public void testAddOverFlowsLong() {
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
247 assertEquals(StampFactory.forKind(Kind.Long), addIntStamp(StampFactory.forInteger(Kind.Long, -1, 1), StampFactory.forInteger(Kind.Long, Long.MIN_VALUE, Long.MAX_VALUE)));
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
248 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
249
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
250 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
251 public void testAdd1() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
252 assertEquals(StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE + 1, 31 + (Integer.MIN_VALUE + 1)),
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
253 addIntStamp(StampFactory.forInteger(Kind.Int, 0, 31), StampFactory.forInteger(Kind.Int, Integer.MIN_VALUE + 1, Integer.MIN_VALUE + 1)));
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
254 }
12562
035474349265 Serveral fixes to StampTool.add and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12449
diff changeset
255
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
256 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
257 public void testAdd2() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
258 assertEquals(StampFactory.forInteger(Kind.Int, 0x8000_007e, 0x8000_007f, 0x8000_007eL, 0x8000_007fL),
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
259 addIntStamp(StampFactory.forInteger(Kind.Int, 0x7fff_fffe, 0x7fff_ffff, 0x7fff_fffeL, 0x7ffff_fffL), StampFactory.forInteger(Kind.Int, 128, 128)));
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
260 }
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
261
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
262 @Test
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
263 public void testAdd3() {
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
264 assertEquals(StampFactory.forInteger(Kind.Long, Long.MIN_VALUE, Long.MAX_VALUE - 1, 0, 0xffff_ffff_ffff_fffeL),
17198
75177b3cc5a8 Remove unused methods from StampTool.
Roland Schatz <roland.schatz@oracle.com>
parents: 16452
diff changeset
265 addIntStamp(StampFactory.forInteger(Kind.Long, Long.MIN_VALUE, Long.MAX_VALUE - 1, 0, 0xffff_ffff_ffff_fffeL),
12677
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
266 StampFactory.forInteger(Kind.Long, Long.MIN_VALUE, Long.MAX_VALUE - 1, 0, 0xffff_ffff_ffff_fffeL)));
e53aa17b8fdf Fix some more problems in StampTool.add and simplify the overflow condition
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12656
diff changeset
267
11357
307eec0f460f fix incorrect lower bound in StampTool
Lukas Stadler <lukas.stadler@jku.at>
parents: 11352
diff changeset
268 }
11352
8185c119d731 "always set" bit mask on IntegerStamps
Lukas Stadler <lukas.stadler@jku.at>
parents: 11265
diff changeset
269
11357
307eec0f460f fix incorrect lower bound in StampTool
Lukas Stadler <lukas.stadler@jku.at>
parents: 11352
diff changeset
270 @Test
307eec0f460f fix incorrect lower bound in StampTool
Lukas Stadler <lukas.stadler@jku.at>
parents: 11352
diff changeset
271 public void testAnd() {
17199
88012c1750a0 Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents: 17198
diff changeset
272 assertEquals(new IntegerStamp(32, Integer.MIN_VALUE, 0x40000000L, 0, 0xc0000000L),
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18124
diff changeset
273 IntegerStamp.OPS.getAnd().foldStamp(StampFactory.forKind(Kind.Int), StampFactory.forConstant(JavaConstant.forInt(0xc0000000))));
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
274 }
14015
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
275
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
276 private static void testSignExtendShort(long lower, long upper) {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
277 Stamp shortStamp = StampFactory.forInteger(16, lower, upper);
18124
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
278 Stamp intStamp = IntegerStamp.OPS.getSignExtend().foldStamp(16, 32, shortStamp);
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
279 assertEquals(StampFactory.forInteger(32, lower, upper), intStamp);
14015
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
280 }
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
281
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
282 @Test
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
283 public void testSignExtend() {
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
284 testSignExtendShort(5, 7);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
285 testSignExtendShort(0, 42);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
286 testSignExtendShort(-42, -1);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
287 testSignExtendShort(-42, 0);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
288 testSignExtendShort(-1, 1);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
289 testSignExtendShort(Short.MIN_VALUE, Short.MAX_VALUE);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
290 }
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
291
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
292 private static void testZeroExtendShort(long lower, long upper, long newLower, long newUpper) {
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
293 Stamp shortStamp = StampFactory.forInteger(16, lower, upper);
18124
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
294 Stamp intStamp = IntegerStamp.OPS.getZeroExtend().foldStamp(16, 32, shortStamp);
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14015
diff changeset
295 assertEquals(StampFactory.forInteger(32, newLower, newUpper), intStamp);
14015
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
296 }
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
297
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
298 @Test
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
299 public void testZeroExtend() {
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
300 testZeroExtendShort(5, 7, 5, 7);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
301 testZeroExtendShort(0, 42, 0, 42);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
302 testZeroExtendShort(-42, -1, 0xFFFF - 41, 0xFFFF);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
303 testZeroExtendShort(-42, 0, 0, 0xFFFF);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
304 testZeroExtendShort(-1, 1, 0, 0xFFFF);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
305 testZeroExtendShort(Short.MIN_VALUE, Short.MAX_VALUE, 0, 0xFFFF);
0354f629431a Bug fixes in StampTool.(zero|sign)Extend.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
306 }
15572
01bce59c2749 test for integer stamp join
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15198
diff changeset
307
01bce59c2749 test for integer stamp join
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15198
diff changeset
308 @Test
01bce59c2749 test for integer stamp join
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15198
diff changeset
309 public void testIllegalJoin() {
20928
35e1b66f2810 Rename Stamp.illegal() to Stamp.empty().
Roland Schatz <roland.schatz@oracle.com>
parents: 19306
diff changeset
310 assertFalse(new IntegerStamp(32, 0, 0xff00, 0, 0xff00).join(new IntegerStamp(32, 1, 0xff, 0x00, 0xff)).hasValues());
35e1b66f2810 Rename Stamp.illegal() to Stamp.empty().
Roland Schatz <roland.schatz@oracle.com>
parents: 19306
diff changeset
311 assertFalse(new IntegerStamp(32, 0x100, 0xff00, 0, 0xff00).join(new IntegerStamp(32, 0, 0xff, 0x00, 0xff)).hasValues());
15572
01bce59c2749 test for integer stamp join
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15198
diff changeset
312 }
16452
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15572
diff changeset
313
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15572
diff changeset
314 @Test
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15572
diff changeset
315 public void testShiftLeft() {
18839
1b7dbb81df4f Use ArithmeticOpTable for shift operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
316 ShiftOp<?> shl = IntegerStamp.OPS.getShl();
1b7dbb81df4f Use ArithmeticOpTable for shift operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
317 assertEquals(new IntegerStamp(32, 0, 0x1ff, 0, 0x1ff), shl.foldStamp(new IntegerStamp(32, 0, 0xff, 0, 0xff), new IntegerStamp(32, 0, 1, 0, 1)));
1b7dbb81df4f Use ArithmeticOpTable for shift operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
318 assertEquals(new IntegerStamp(32, 0, 0x1fe0, 0, 0x1fe0), shl.foldStamp(new IntegerStamp(32, 0, 0xff, 0, 0xff), new IntegerStamp(32, 5, 5, 5, 5)));
1b7dbb81df4f Use ArithmeticOpTable for shift operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
319 assertEquals(new IntegerStamp(32, 0x1e0, 0x1fe0, 0, 0x1fe0), shl.foldStamp(new IntegerStamp(32, 0xf, 0xff, 0, 0xff), new IntegerStamp(32, 5, 5, 5, 5)));
16452
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15572
diff changeset
320
18839
1b7dbb81df4f Use ArithmeticOpTable for shift operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
321 assertEquals(new IntegerStamp(64, 0, 0x1ff, 0, 0x1ff), shl.foldStamp(new IntegerStamp(64, 0, 0xff, 0, 0xff), new IntegerStamp(32, 0, 1, 0, 1)));
1b7dbb81df4f Use ArithmeticOpTable for shift operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
322 assertEquals(new IntegerStamp(64, 0, 0x1fe0, 0, 0x1fe0), shl.foldStamp(new IntegerStamp(64, 0, 0xff, 0, 0xff), new IntegerStamp(32, 5, 5, 5, 5)));
1b7dbb81df4f Use ArithmeticOpTable for shift operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
323 assertEquals(new IntegerStamp(64, 0x1e0, 0x1fe0, 0, 0x1fe0), shl.foldStamp(new IntegerStamp(64, 0xf, 0xff, 0, 0xff), new IntegerStamp(32, 5, 5, 5, 5)));
16452
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15572
diff changeset
324
41906973537e better stamps for left shifts with fixed shift amount
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15572
diff changeset
325 }
10723
097a634b57b1 fix stamps for constants of boolean, byte, char and short type, add tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff changeset
326 }