src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/LeftShiftNode.java
changeset 58533 46b0b7fe255c
parent 52910 583fd71c47d6
equal deleted inserted replaced
58532:b4f2e13d20ea 58533:46b0b7fe255c
     1 /*
     1 /*
     2  * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    22  */
    22  */
    23 
    23 
    24 
    24 
    25 package org.graalvm.compiler.nodes.calc;
    25 package org.graalvm.compiler.nodes.calc;
    26 
    26 
       
    27 import static org.graalvm.compiler.nodes.calc.BinaryArithmeticNode.getArithmeticOpTable;
       
    28 
    27 import org.graalvm.compiler.core.common.type.ArithmeticOpTable;
    29 import org.graalvm.compiler.core.common.type.ArithmeticOpTable;
       
    30 import org.graalvm.compiler.core.common.type.ArithmeticOpTable.ShiftOp;
    28 import org.graalvm.compiler.core.common.type.ArithmeticOpTable.ShiftOp.Shl;
    31 import org.graalvm.compiler.core.common.type.ArithmeticOpTable.ShiftOp.Shl;
    29 import org.graalvm.compiler.core.common.type.IntegerStamp;
    32 import org.graalvm.compiler.core.common.type.IntegerStamp;
    30 import org.graalvm.compiler.core.common.type.Stamp;
    33 import org.graalvm.compiler.core.common.type.Stamp;
    31 import org.graalvm.compiler.graph.NodeClass;
    34 import org.graalvm.compiler.graph.NodeClass;
    32 import org.graalvm.compiler.graph.spi.CanonicalizerTool;
    35 import org.graalvm.compiler.graph.spi.CanonicalizerTool;
    43 public final class LeftShiftNode extends ShiftNode<Shl> {
    46 public final class LeftShiftNode extends ShiftNode<Shl> {
    44 
    47 
    45     public static final NodeClass<LeftShiftNode> TYPE = NodeClass.create(LeftShiftNode.class);
    48     public static final NodeClass<LeftShiftNode> TYPE = NodeClass.create(LeftShiftNode.class);
    46 
    49 
    47     public LeftShiftNode(ValueNode x, ValueNode y) {
    50     public LeftShiftNode(ValueNode x, ValueNode y) {
    48         super(TYPE, ArithmeticOpTable::getShl, x, y);
    51         super(TYPE, getArithmeticOpTable(x).getShl(), x, y);
    49     }
    52     }
    50 
    53 
    51     public static ValueNode create(ValueNode x, ValueNode y, NodeView view) {
    54     public static ValueNode create(ValueNode x, ValueNode y, NodeView view) {
    52         ArithmeticOpTable.ShiftOp<Shl> op = ArithmeticOpTable.forStamp(x.stamp(view)).getShl();
    55         ArithmeticOpTable.ShiftOp<Shl> op = ArithmeticOpTable.forStamp(x.stamp(view)).getShl();
    53         Stamp stamp = op.foldStamp(x.stamp(view), (IntegerStamp) y.stamp(view));
    56         Stamp stamp = op.foldStamp(x.stamp(view), (IntegerStamp) y.stamp(view));
    55         if (value != null) {
    58         if (value != null) {
    56             return value;
    59             return value;
    57         }
    60         }
    58 
    61 
    59         return canonical(null, op, stamp, x, y);
    62         return canonical(null, op, stamp, x, y);
       
    63     }
       
    64 
       
    65     @Override
       
    66     protected ShiftOp<Shl> getOp(ArithmeticOpTable table) {
       
    67         return table.getShl();
    60     }
    68     }
    61 
    69 
    62     @Override
    70     @Override
    63     public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
    71     public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
    64         ValueNode ret = super.canonical(tool, forX, forY);
    72         ValueNode ret = super.canonical(tool, forX, forY);