Mercurial > hg > truffle
annotate graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ArithmeticOpTable.java @ 18124:689092d5cf44
Store explicit input bit width in IntegerConvertNode.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Mon, 20 Oct 2014 16:26:05 +0200 |
parents | 83c3dd41ca64 |
children | c88ab4f1f04a |
rev | line source |
---|---|
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
1 /* |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
4 * |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
8 * |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
14 * |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
18 * |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
21 * questions. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
22 */ |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.compiler.common.type; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
24 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
25 import java.util.*; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
26 import java.util.function.*; |
17368
a613bd4e6f67
Generic getters in ArithmeticOpTable.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
27 import java.util.stream.*; |
a613bd4e6f67
Generic getters in ArithmeticOpTable.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
28 |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.api.meta.*; |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
30 import com.oracle.graal.compiler.common.calc.*; |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
31 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.BinaryOp.Add; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
32 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.BinaryOp.And; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
33 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.BinaryOp.Div; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
34 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.BinaryOp.Mul; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
35 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.BinaryOp.Or; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
36 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.BinaryOp.Rem; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
37 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.BinaryOp.Sub; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
38 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.BinaryOp.Xor; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
39 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.IntegerConvertOp.Narrow; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
40 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.IntegerConvertOp.SignExtend; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
41 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.IntegerConvertOp.ZeroExtend; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
42 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.UnaryOp.Neg; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
43 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.UnaryOp.Not; |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
44 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
45 /** |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
46 * Information about arithmetic operations. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
47 */ |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
48 public final class ArithmeticOpTable { |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
49 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
50 private final UnaryOp<Neg> neg; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
51 private final BinaryOp<Add> add; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
52 private final BinaryOp<Sub> sub; |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
53 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
54 private final BinaryOp<Mul> mul; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
55 private final BinaryOp<Div> div; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
56 private final BinaryOp<Rem> rem; |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
57 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
58 private final UnaryOp<Not> not; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
59 private final BinaryOp<And> and; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
60 private final BinaryOp<Or> or; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
61 private final BinaryOp<Xor> xor; |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
62 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
63 private final IntegerConvertOp<ZeroExtend> zeroExtend; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
64 private final IntegerConvertOp<SignExtend> signExtend; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
65 private final IntegerConvertOp<Narrow> narrow; |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
66 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
67 private final FloatConvertOp[] floatConvert; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
68 |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
69 public static ArithmeticOpTable forStamp(Stamp s) { |
17269
83ebc10fb5e9
Return empty ArithmeticOpTable for non-arithmetic stamps.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
70 if (s instanceof ArithmeticStamp) { |
83ebc10fb5e9
Return empty ArithmeticOpTable for non-arithmetic stamps.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
71 return ((ArithmeticStamp) s).getOps(); |
83ebc10fb5e9
Return empty ArithmeticOpTable for non-arithmetic stamps.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
72 } else { |
83ebc10fb5e9
Return empty ArithmeticOpTable for non-arithmetic stamps.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
73 return EMPTY; |
83ebc10fb5e9
Return empty ArithmeticOpTable for non-arithmetic stamps.
Roland Schatz <roland.schatz@oracle.com>
parents:
17199
diff
changeset
|
74 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
75 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
76 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
77 public static final ArithmeticOpTable EMPTY = new ArithmeticOpTable(null, null, null, null, null, null, null, null, null, null, null, null, null); |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
78 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
79 public ArithmeticOpTable(UnaryOp<Neg> neg, BinaryOp<Add> add, BinaryOp<Sub> sub, BinaryOp<Mul> mul, BinaryOp<Div> div, BinaryOp<Rem> rem, UnaryOp<Not> not, BinaryOp<And> and, BinaryOp<Or> or, |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
80 BinaryOp<Xor> xor, IntegerConvertOp<ZeroExtend> zeroExtend, IntegerConvertOp<SignExtend> signExtend, IntegerConvertOp<Narrow> narrow, FloatConvertOp... floatConvert) { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
81 this(neg, add, sub, mul, div, rem, not, and, or, xor, zeroExtend, signExtend, narrow, Stream.of(floatConvert)); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
82 } |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
83 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
84 public interface ArithmeticOpWrapper { |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
85 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
86 <OP> UnaryOp<OP> wrapUnaryOp(UnaryOp<OP> op); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
87 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
88 <OP> BinaryOp<OP> wrapBinaryOp(BinaryOp<OP> op); |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
89 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
90 <OP> IntegerConvertOp<OP> wrapIntegerConvertOp(IntegerConvertOp<OP> op); |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
91 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
92 FloatConvertOp wrapFloatConvertOp(FloatConvertOp op); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
93 } |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
94 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
95 private static <T> T wrapIfNonNull(Function<T, T> wrapper, T obj) { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
96 if (obj == null) { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
97 return null; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
98 } else { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
99 return wrapper.apply(obj); |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
100 } |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
101 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
102 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
103 public static ArithmeticOpTable wrap(ArithmeticOpWrapper wrapper, ArithmeticOpTable inner) { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
104 UnaryOp<Neg> neg = wrapIfNonNull(wrapper::wrapUnaryOp, inner.getNeg()); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
105 BinaryOp<Add> add = wrapIfNonNull(wrapper::wrapBinaryOp, inner.getAdd()); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
106 BinaryOp<Sub> sub = wrapIfNonNull(wrapper::wrapBinaryOp, inner.getSub()); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
107 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
108 BinaryOp<Mul> mul = wrapIfNonNull(wrapper::wrapBinaryOp, inner.getMul()); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
109 BinaryOp<Div> div = wrapIfNonNull(wrapper::wrapBinaryOp, inner.getDiv()); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
110 BinaryOp<Rem> rem = wrapIfNonNull(wrapper::wrapBinaryOp, inner.getRem()); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
111 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
112 UnaryOp<Not> not = wrapIfNonNull(wrapper::wrapUnaryOp, inner.getNot()); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
113 BinaryOp<And> and = wrapIfNonNull(wrapper::wrapBinaryOp, inner.getAnd()); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
114 BinaryOp<Or> or = wrapIfNonNull(wrapper::wrapBinaryOp, inner.getOr()); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
115 BinaryOp<Xor> xor = wrapIfNonNull(wrapper::wrapBinaryOp, inner.getXor()); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
116 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
117 IntegerConvertOp<ZeroExtend> zeroExtend = wrapIfNonNull(wrapper::wrapIntegerConvertOp, inner.getZeroExtend()); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
118 IntegerConvertOp<SignExtend> signExtend = wrapIfNonNull(wrapper::wrapIntegerConvertOp, inner.getSignExtend()); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
119 IntegerConvertOp<Narrow> narrow = wrapIfNonNull(wrapper::wrapIntegerConvertOp, inner.getNarrow()); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
120 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
121 Stream<FloatConvertOp> floatConvert = Stream.of(inner.floatConvert).filter(Objects::nonNull).map(wrapper::wrapFloatConvertOp); |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
122 |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
123 return new ArithmeticOpTable(neg, add, sub, mul, div, rem, not, and, or, xor, zeroExtend, signExtend, narrow, floatConvert); |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
124 } |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
125 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
126 private ArithmeticOpTable(UnaryOp<Neg> neg, BinaryOp<Add> add, BinaryOp<Sub> sub, BinaryOp<Mul> mul, BinaryOp<Div> div, BinaryOp<Rem> rem, UnaryOp<Not> not, BinaryOp<And> and, BinaryOp<Or> or, |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
127 BinaryOp<Xor> xor, IntegerConvertOp<ZeroExtend> zeroExtend, IntegerConvertOp<SignExtend> signExtend, IntegerConvertOp<Narrow> narrow, Stream<FloatConvertOp> floatConvert) { |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
128 this.neg = neg; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
129 this.add = add; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
130 this.sub = sub; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
131 this.mul = mul; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
132 this.div = div; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
133 this.rem = rem; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
134 this.not = not; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
135 this.and = and; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
136 this.or = or; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
137 this.xor = xor; |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
138 this.zeroExtend = zeroExtend; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
139 this.signExtend = signExtend; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
140 this.narrow = narrow; |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
141 this.floatConvert = new FloatConvertOp[FloatConvert.values().length]; |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
142 floatConvert.forEach(op -> this.floatConvert[op.getFloatConvert().ordinal()] = op); |
17368
a613bd4e6f67
Generic getters in ArithmeticOpTable.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
143 } |
a613bd4e6f67
Generic getters in ArithmeticOpTable.
Roland Schatz <roland.schatz@oracle.com>
parents:
17344
diff
changeset
|
144 |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
145 /** |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
146 * Describes the unary negation operation. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
147 */ |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
148 public final UnaryOp<Neg> getNeg() { |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
149 return neg; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
150 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
151 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
152 /** |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
153 * Describes the addition operation. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
154 */ |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
155 public final BinaryOp<Add> getAdd() { |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
156 return add; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
157 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
158 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
159 /** |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
160 * Describes the subtraction operation. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
161 */ |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
162 public final BinaryOp<Sub> getSub() { |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
163 return sub; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
164 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
165 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
166 /** |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
167 * Describes the multiplication operation. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
168 */ |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
169 public final BinaryOp<Mul> getMul() { |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
170 return mul; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
171 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
172 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
173 /** |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
174 * Describes the division operation. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
175 */ |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
176 public final BinaryOp<Div> getDiv() { |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
177 return div; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
178 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
179 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
180 /** |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
181 * Describes the remainder operation. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
182 */ |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
183 public final BinaryOp<Rem> getRem() { |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
184 return rem; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
185 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
186 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
187 /** |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
188 * Describes the bitwise not operation. |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
189 */ |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
190 public final UnaryOp<Not> getNot() { |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
191 return not; |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
192 } |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
193 |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
194 /** |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
195 * Describes the bitwise and operation. |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
196 */ |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
197 public final BinaryOp<And> getAnd() { |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
198 return and; |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
199 } |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
200 |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
201 /** |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
202 * Describes the bitwise or operation. |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
203 */ |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
204 public final BinaryOp<Or> getOr() { |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
205 return or; |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
206 } |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
207 |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
208 /** |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
209 * Describes the bitwise xor operation. |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
210 */ |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
211 public final BinaryOp<Xor> getXor() { |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
212 return xor; |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
213 } |
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
214 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
215 /** |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
216 * Describes the zero extend conversion. |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
217 */ |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
218 public IntegerConvertOp<ZeroExtend> getZeroExtend() { |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
219 return zeroExtend; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
220 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
221 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
222 /** |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
223 * Describes the sign extend conversion. |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
224 */ |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
225 public IntegerConvertOp<SignExtend> getSignExtend() { |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
226 return signExtend; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
227 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
228 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
229 /** |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
230 * Describes the narrowing conversion. |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
231 */ |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
232 public IntegerConvertOp<Narrow> getNarrow() { |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
233 return narrow; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
234 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
235 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
236 /** |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
237 * Describes integer/float/double conversions. |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
238 */ |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
239 public FloatConvertOp getFloatConvert(FloatConvert op) { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
240 return floatConvert[op.ordinal()]; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
241 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
242 |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
243 public abstract static class Op { |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
244 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
245 private final String operator; |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
246 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
247 protected Op(String operator) { |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
248 this.operator = operator; |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
249 } |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
250 |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
251 @Override |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
252 public String toString() { |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
253 return operator; |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
254 } |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
255 } |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
256 |
17199
88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
257 /** |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
258 * Describes a unary arithmetic operation. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
259 */ |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
260 public abstract static class UnaryOp<T> extends Op { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
261 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
262 public abstract static class Neg extends UnaryOp<Neg> { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
263 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
264 protected Neg() { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
265 super("-"); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
266 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
267 } |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
268 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
269 public abstract static class Not extends UnaryOp<Not> { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
270 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
271 protected Not() { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
272 super("~"); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
273 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
274 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
275 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
276 protected UnaryOp(String operation) { |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
277 super(operation); |
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
278 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
279 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
280 /** |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
281 * Apply the operation to a {@link Constant}. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
282 */ |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
283 public abstract Constant foldConstant(Constant value); |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
284 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
285 /** |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
286 * Apply the operation to a {@link Stamp}. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
287 */ |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
288 public abstract Stamp foldStamp(Stamp stamp); |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
289 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
290 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
291 /** |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
292 * Describes a binary arithmetic operation. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
293 */ |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
294 public abstract static class BinaryOp<T> extends Op { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
295 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
296 public abstract static class Add extends BinaryOp<Add> { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
297 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
298 protected Add(boolean associative, boolean commutative) { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
299 super("+", associative, commutative); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
300 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
301 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
302 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
303 public abstract static class Sub extends BinaryOp<Sub> { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
304 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
305 protected Sub(boolean associative, boolean commutative) { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
306 super("-", associative, commutative); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
307 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
308 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
309 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
310 public abstract static class Mul extends BinaryOp<Mul> { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
311 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
312 protected Mul(boolean associative, boolean commutative) { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
313 super("*", associative, commutative); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
314 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
315 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
316 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
317 public abstract static class Div extends BinaryOp<Div> { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
318 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
319 protected Div(boolean associative, boolean commutative) { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
320 super("/", associative, commutative); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
321 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
322 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
323 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
324 public abstract static class Rem extends BinaryOp<Rem> { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
325 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
326 protected Rem(boolean associative, boolean commutative) { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
327 super("%", associative, commutative); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
328 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
329 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
330 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
331 public abstract static class And extends BinaryOp<And> { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
332 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
333 protected And(boolean associative, boolean commutative) { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
334 super("&", associative, commutative); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
335 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
336 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
337 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
338 public abstract static class Or extends BinaryOp<Or> { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
339 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
340 protected Or(boolean associative, boolean commutative) { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
341 super("|", associative, commutative); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
342 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
343 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
344 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
345 public abstract static class Xor extends BinaryOp<Xor> { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
346 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
347 protected Xor(boolean associative, boolean commutative) { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
348 super("^", associative, commutative); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
349 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
350 } |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
351 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
352 private final boolean associative; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
353 private final boolean commutative; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
354 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
355 protected BinaryOp(String operation, boolean associative, boolean commutative) { |
17271
fa3637e235b1
Make ArithmeticOpTable fields final.
Roland Schatz <roland.schatz@oracle.com>
parents:
17269
diff
changeset
|
356 super(operation); |
17197
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
357 this.associative = associative; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
358 this.commutative = commutative; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
359 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
360 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
361 /** |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
362 * Apply the operation to two {@linkplain Constant Constants}. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
363 */ |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
364 public abstract Constant foldConstant(Constant a, Constant b); |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
365 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
366 /** |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
367 * Apply the operation to two {@linkplain Stamp Stamps}. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
368 */ |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
369 public abstract Stamp foldStamp(Stamp a, Stamp b); |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
370 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
371 /** |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
372 * Checks whether this operation is associative. An operation is associative when |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
373 * {@code (a . b) . c == a . (b . c)} for all a, b, c. Note that you still have to be |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
374 * careful with inverses. For example the integer subtraction operation will report |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
375 * {@code true} here, since you can still reassociate as long as the correct negations are |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
376 * inserted. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
377 */ |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
378 public final boolean isAssociative() { |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
379 return associative; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
380 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
381 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
382 /** |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
383 * Checks whether this operation is commutative. An operation is commutative when |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
384 * {@code a . b == b . a} for all a, b. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
385 */ |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
386 public final boolean isCommutative() { |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
387 return commutative; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
388 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
389 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
390 /** |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
391 * Check whether a {@link Constant} is a neutral element for this operation. A neutral |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
392 * element is any element {@code n} where {@code a . n == a} for all a. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
393 * |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
394 * @param n the {@link Constant} that should be tested |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
395 * @return true iff for all {@code a}: {@code a . n == a} |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
396 */ |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
397 public boolean isNeutral(Constant n) { |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
398 return false; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
399 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
400 |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
401 /** |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
402 * Check whether this operation has a zero {@code z == a . a} for each a. Examples of |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
403 * operations having such an element are subtraction and exclusive-or. Note that this may be |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
404 * different from the numbers tested by {@link #isNeutral}. |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
405 * |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
406 * @param stamp a {@link Stamp} |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
407 * @return a unique {@code z} such that {@code z == a . a} for each {@code a} in |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
408 * {@code stamp} if it exists, otherwise {@code null} |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
409 */ |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
410 public Constant getZero(Stamp stamp) { |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
411 return null; |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
412 } |
ec35bb4eccb8
Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
413 } |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
414 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
415 public abstract static class FloatConvertOp extends UnaryOp<FloatConvertOp> { |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
416 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
417 private final FloatConvert op; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
418 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
419 protected FloatConvertOp(FloatConvert op) { |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
420 super(op.name()); |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
421 this.op = op; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
422 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
423 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
424 public FloatConvert getFloatConvert() { |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
425 return op; |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
426 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
427 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
428 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
429 public abstract static class IntegerConvertOp<T> extends Op { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
430 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
431 public abstract static class ZeroExtend extends IntegerConvertOp<ZeroExtend> { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
432 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
433 protected ZeroExtend() { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
434 super("ZeroExtend"); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
435 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
436 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
437 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
438 public abstract static class SignExtend extends IntegerConvertOp<SignExtend> { |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
439 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
440 protected SignExtend() { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
441 super("SignExtend"); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
442 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
443 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
444 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
445 public abstract static class Narrow extends IntegerConvertOp<Narrow> { |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
446 |
17419
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
447 protected Narrow() { |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
448 super("Narrow"); |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
449 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
450 } |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
451 |
83c3dd41ca64
Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents:
17368
diff
changeset
|
452 protected IntegerConvertOp(String op) { |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
453 super(op); |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
454 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
455 |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
456 public abstract 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
|
457 |
18124
689092d5cf44
Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
17419
diff
changeset
|
458 public abstract Stamp foldStamp(int inputBits, int resultBits, Stamp stamp); |
17344
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
459 } |
98e60bdf6d05
Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents:
17271
diff
changeset
|
460 } |