< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/IntegerConvertNode.java

Print this page




 112         return this;
 113     }
 114 
 115     protected static <T> ValueNode findSynonym(IntegerConvertOp<T> operation, ValueNode value, int inputBits, int resultBits, Stamp stamp) {
 116         if (inputBits == resultBits) {
 117             return value;
 118         } else if (value.isConstant()) {
 119             return ConstantNode.forPrimitive(stamp, operation.foldConstant(inputBits, resultBits, value.asConstant()));
 120         }
 121         return null;
 122     }
 123 
 124     public static ValueNode convert(ValueNode input, Stamp stamp) {
 125         return convert(input, stamp, false);
 126     }
 127 
 128     public static ValueNode convert(ValueNode input, Stamp stamp, StructuredGraph graph) {
 129         ValueNode convert = convert(input, stamp, false);
 130         if (!convert.isAlive()) {
 131             assert !convert.isDeleted();
 132             convert = graph.addOrUnique(convert);
 133         }
 134         return convert;
 135     }
 136 
 137     public static ValueNode convertUnsigned(ValueNode input, Stamp stamp) {
 138         return convert(input, stamp, true);
 139     }
 140 
 141     public static ValueNode convert(ValueNode input, Stamp stamp, boolean zeroExtend) {
 142         IntegerStamp fromStamp = (IntegerStamp) input.stamp();
 143         IntegerStamp toStamp = (IntegerStamp) stamp;
 144 
 145         ValueNode result;
 146         if (toStamp.getBits() == fromStamp.getBits()) {
 147             result = input;
 148         } else if (toStamp.getBits() < fromStamp.getBits()) {
 149             result = new NarrowNode(input, fromStamp.getBits(), toStamp.getBits());
 150         } else if (zeroExtend) {
 151             // toStamp.getBits() > fromStamp.getBits()
 152             result = ZeroExtendNode.create(input, toStamp.getBits());


 112         return this;
 113     }
 114 
 115     protected static <T> ValueNode findSynonym(IntegerConvertOp<T> operation, ValueNode value, int inputBits, int resultBits, Stamp stamp) {
 116         if (inputBits == resultBits) {
 117             return value;
 118         } else if (value.isConstant()) {
 119             return ConstantNode.forPrimitive(stamp, operation.foldConstant(inputBits, resultBits, value.asConstant()));
 120         }
 121         return null;
 122     }
 123 
 124     public static ValueNode convert(ValueNode input, Stamp stamp) {
 125         return convert(input, stamp, false);
 126     }
 127 
 128     public static ValueNode convert(ValueNode input, Stamp stamp, StructuredGraph graph) {
 129         ValueNode convert = convert(input, stamp, false);
 130         if (!convert.isAlive()) {
 131             assert !convert.isDeleted();
 132             convert = graph.addOrUniqueWithInputs(convert);
 133         }
 134         return convert;
 135     }
 136 
 137     public static ValueNode convertUnsigned(ValueNode input, Stamp stamp) {
 138         return convert(input, stamp, true);
 139     }
 140 
 141     public static ValueNode convert(ValueNode input, Stamp stamp, boolean zeroExtend) {
 142         IntegerStamp fromStamp = (IntegerStamp) input.stamp();
 143         IntegerStamp toStamp = (IntegerStamp) stamp;
 144 
 145         ValueNode result;
 146         if (toStamp.getBits() == fromStamp.getBits()) {
 147             result = input;
 148         } else if (toStamp.getBits() < fromStamp.getBits()) {
 149             result = new NarrowNode(input, fromStamp.getBits(), toStamp.getBits());
 150         } else if (zeroExtend) {
 151             // toStamp.getBits() > fromStamp.getBits()
 152             result = ZeroExtendNode.create(input, toStamp.getBits());
< prev index next >