annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerConvertNode.java @ 18720:ab9d3ff6829b

Pass constant reflection into ConvertNode.convert
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Thu, 18 Dec 2014 09:17:22 -0800
parents 290dc460feb3
children f57d86eb036f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
1 /*
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18124
diff changeset
2 * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
4 *
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
8 *
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
13 * accompanied this code).
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
14 *
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
18 *
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
21 * questions.
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
22 */
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.nodes.calc;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
24
18646
290dc460feb3 use better types to simplify instantiation of Serializable lambdas
Doug Simon <doug.simon@oracle.com>
parents: 18188
diff changeset
25 import java.io.*;
17418
393fe459eadc Don't cache op field in arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 17369
diff changeset
26 import java.util.function.*;
393fe459eadc Don't cache op field in arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 17369
diff changeset
27
17344
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17328
diff changeset
28 import com.oracle.graal.api.meta.*;
17418
393fe459eadc Don't cache op field in arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 17369
diff changeset
29 import com.oracle.graal.compiler.common.type.*;
18646
290dc460feb3 use better types to simplify instantiation of Serializable lambdas
Doug Simon <doug.simon@oracle.com>
parents: 18188
diff changeset
30 import com.oracle.graal.compiler.common.type.ArithmeticOpTable.*;
17344
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17328
diff changeset
31 import com.oracle.graal.graph.spi.*;
16841
cbd42807a31f moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents: 16811
diff changeset
32 import com.oracle.graal.nodeinfo.*;
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
33 import com.oracle.graal.nodes.*;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
34 import com.oracle.graal.nodes.spi.*;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
35
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
36 /**
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
37 * An {@code IntegerConvert} converts an integer to an integer of different width.
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
38 */
16811
5d468add216f added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents: 16248
diff changeset
39 @NodeInfo
17419
83c3dd41ca64 Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents: 17418
diff changeset
40 public abstract class IntegerConvertNode<OP, REV> extends UnaryNode implements ConvertNode, ArithmeticLIRLowerable {
17344
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17328
diff changeset
41
18646
290dc460feb3 use better types to simplify instantiation of Serializable lambdas
Doug Simon <doug.simon@oracle.com>
parents: 18188
diff changeset
42 protected final SerializableIntegerConvertFunction<OP> getOp;
290dc460feb3 use better types to simplify instantiation of Serializable lambdas
Doug Simon <doug.simon@oracle.com>
parents: 18188
diff changeset
43 protected final SerializableIntegerConvertFunction<REV> getReverseOp;
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
44
18124
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
45 protected final int inputBits;
17328
c9bb0da795d4 Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents: 17327
diff changeset
46 protected final int resultBits;
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
47
18646
290dc460feb3 use better types to simplify instantiation of Serializable lambdas
Doug Simon <doug.simon@oracle.com>
parents: 18188
diff changeset
48 protected interface SerializableIntegerConvertFunction<T> extends Function<ArithmeticOpTable, IntegerConvertOp<T>>, Serializable {
290dc460feb3 use better types to simplify instantiation of Serializable lambdas
Doug Simon <doug.simon@oracle.com>
parents: 18188
diff changeset
49 }
290dc460feb3 use better types to simplify instantiation of Serializable lambdas
Doug Simon <doug.simon@oracle.com>
parents: 18188
diff changeset
50
290dc460feb3 use better types to simplify instantiation of Serializable lambdas
Doug Simon <doug.simon@oracle.com>
parents: 18188
diff changeset
51 protected IntegerConvertNode(SerializableIntegerConvertFunction<OP> getOp, SerializableIntegerConvertFunction<REV> getReverseOp, int inputBits, int resultBits, ValueNode input) {
18124
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
52 super(getOp.apply(ArithmeticOpTable.forStamp(input.stamp())).foldStamp(inputBits, resultBits, input.stamp()), input);
17418
393fe459eadc Don't cache op field in arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 17369
diff changeset
53 this.getOp = getOp;
393fe459eadc Don't cache op field in arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 17369
diff changeset
54 this.getReverseOp = getReverseOp;
18124
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
55 this.inputBits = inputBits;
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
56 this.resultBits = resultBits;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
57 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
58
18124
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
59 public int getInputBits() {
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
60 return inputBits;
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
61 }
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
62
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
63 public int getResultBits() {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
64 return resultBits;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
65 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
66
17419
83c3dd41ca64 Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents: 17418
diff changeset
67 protected final IntegerConvertOp<OP> getOp(ValueNode forValue) {
17418
393fe459eadc Don't cache op field in arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 17369
diff changeset
68 return getOp.apply(ArithmeticOpTable.forStamp(forValue.stamp()));
393fe459eadc Don't cache op field in arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 17369
diff changeset
69 }
393fe459eadc Don't cache op field in arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 17369
diff changeset
70
17344
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17328
diff changeset
71 @Override
18720
ab9d3ff6829b Pass constant reflection into ConvertNode.convert
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18646
diff changeset
72 public Constant convert(Constant c, ConstantReflectionProvider constantReflection) {
17418
393fe459eadc Don't cache op field in arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 17369
diff changeset
73 return getOp(getValue()).foldConstant(getInputBits(), getResultBits(), c);
17344
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17328
diff changeset
74 }
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17328
diff changeset
75
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17328
diff changeset
76 @Override
18720
ab9d3ff6829b Pass constant reflection into ConvertNode.convert
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18646
diff changeset
77 public Constant reverse(Constant c, ConstantReflectionProvider constantReflection) {
17419
83c3dd41ca64 Simplify ArithmeticOpTable implementation and make it type safe.
Roland Schatz <roland.schatz@oracle.com>
parents: 17418
diff changeset
78 IntegerConvertOp<REV> reverse = getReverseOp.apply(ArithmeticOpTable.forStamp(stamp()));
17418
393fe459eadc Don't cache op field in arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 17369
diff changeset
79 return reverse.foldConstant(getResultBits(), getInputBits(), c);
17344
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17328
diff changeset
80 }
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17328
diff changeset
81
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17328
diff changeset
82 @Override
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17328
diff changeset
83 public boolean inferStamp() {
18124
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
84 return updateStamp(getOp(getValue()).foldStamp(inputBits, resultBits, getValue().stamp()));
17344
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17328
diff changeset
85 }
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17328
diff changeset
86
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17328
diff changeset
87 @Override
98e60bdf6d05 Use ArithmeticOpTable for primitive convert operations.
Roland Schatz <roland.schatz@oracle.com>
parents: 17328
diff changeset
88 public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) {
18124
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
89 if (inputBits == resultBits) {
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
90 return value;
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
91 } else if (value.isConstant()) {
18720
ab9d3ff6829b Pass constant reflection into ConvertNode.convert
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18646
diff changeset
92 return ConstantNode.forPrimitive(stamp(), convert(forValue.asConstant(), tool.getConstantReflection()));
18124
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
93 } else {
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
94 return this;
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
95 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
96 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
97
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
98 public static ValueNode convert(ValueNode input, Stamp stamp) {
15756
10830a8ab30d ConditionalNode's boolean materialization canonicalization needs to insert a convert
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15413
diff changeset
99 return convert(input, stamp, false);
10830a8ab30d ConditionalNode's boolean materialization canonicalization needs to insert a convert
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15413
diff changeset
100 }
10830a8ab30d ConditionalNode's boolean materialization canonicalization needs to insert a convert
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15413
diff changeset
101
16248
c5b2a3c22318 refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16216
diff changeset
102 public static ValueNode convert(ValueNode input, Stamp stamp, StructuredGraph graph) {
c5b2a3c22318 refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16216
diff changeset
103 ValueNode convert = convert(input, stamp, false);
c5b2a3c22318 refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16216
diff changeset
104 if (!convert.isAlive()) {
c5b2a3c22318 refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16216
diff changeset
105 assert !convert.isDeleted();
c5b2a3c22318 refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16216
diff changeset
106 convert = graph.addOrUnique(convert);
c5b2a3c22318 refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16216
diff changeset
107 }
c5b2a3c22318 refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16216
diff changeset
108 return convert;
c5b2a3c22318 refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16216
diff changeset
109 }
c5b2a3c22318 refactor more Canonicalizable implementations to not add new nodes to the graph
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16216
diff changeset
110
15756
10830a8ab30d ConditionalNode's boolean materialization canonicalization needs to insert a convert
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15413
diff changeset
111 public static ValueNode convertUnsigned(ValueNode input, Stamp stamp) {
10830a8ab30d ConditionalNode's boolean materialization canonicalization needs to insert a convert
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15413
diff changeset
112 return convert(input, stamp, true);
10830a8ab30d ConditionalNode's boolean materialization canonicalization needs to insert a convert
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15413
diff changeset
113 }
10830a8ab30d ConditionalNode's boolean materialization canonicalization needs to insert a convert
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15413
diff changeset
114
10830a8ab30d ConditionalNode's boolean materialization canonicalization needs to insert a convert
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15413
diff changeset
115 public static ValueNode convert(ValueNode input, Stamp stamp, boolean zeroExtend) {
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
116 IntegerStamp fromStamp = (IntegerStamp) input.stamp();
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
117 IntegerStamp toStamp = (IntegerStamp) stamp;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
118
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
119 ValueNode result;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
120 if (toStamp.getBits() == fromStamp.getBits()) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
121 result = input;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
122 } else if (toStamp.getBits() < fromStamp.getBits()) {
18124
689092d5cf44 Store explicit input bit width in IntegerConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 17419
diff changeset
123 result = NarrowNode.create(input, fromStamp.getBits(), toStamp.getBits());
15756
10830a8ab30d ConditionalNode's boolean materialization canonicalization needs to insert a convert
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15413
diff changeset
124 } else if (zeroExtend) {
10830a8ab30d ConditionalNode's boolean materialization canonicalization needs to insert a convert
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15413
diff changeset
125 // toStamp.getBits() > fromStamp.getBits()
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
126 result = ZeroExtendNode.create(input, toStamp.getBits());
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
127 } else {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
128 // toStamp.getBits() > fromStamp.getBits()
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
129 result = SignExtendNode.create(input, toStamp.getBits());
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
130 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
131
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
132 IntegerStamp resultStamp = (IntegerStamp) result.stamp();
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
133 assert toStamp.getBits() == resultStamp.getBits();
15131
9c1e53adc159 Remove unsigned flag from IntegerStamp.
Roland Schatz <roland.schatz@oracle.com>
parents: 14707
diff changeset
134 return result;
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
135 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
136 }