src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/AddNode.java
changeset 58533 46b0b7fe255c
parent 52578 7dd81e82d083
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.
    52     public AddNode(ValueNode x, ValueNode y) {
    52     public AddNode(ValueNode x, ValueNode y) {
    53         this(TYPE, x, y);
    53         this(TYPE, x, y);
    54     }
    54     }
    55 
    55 
    56     protected AddNode(NodeClass<? extends AddNode> c, ValueNode x, ValueNode y) {
    56     protected AddNode(NodeClass<? extends AddNode> c, ValueNode x, ValueNode y) {
    57         super(c, ArithmeticOpTable::getAdd, x, y);
    57         super(c, getArithmeticOpTable(x).getAdd(), x, y);
    58     }
    58     }
    59 
    59 
    60     public static ValueNode create(ValueNode x, ValueNode y, NodeView view) {
    60     public static ValueNode create(ValueNode x, ValueNode y, NodeView view) {
    61         BinaryOp<Add> op = ArithmeticOpTable.forStamp(x.stamp(view)).getAdd();
    61         BinaryOp<Add> op = ArithmeticOpTable.forStamp(x.stamp(view)).getAdd();
    62         Stamp stamp = op.foldStamp(x.stamp(view), y.stamp(view));
    62         Stamp stamp = op.foldStamp(x.stamp(view), y.stamp(view));
    67         if (x.isConstant() && !y.isConstant()) {
    67         if (x.isConstant() && !y.isConstant()) {
    68             return canonical(null, op, y, x, view);
    68             return canonical(null, op, y, x, view);
    69         } else {
    69         } else {
    70             return canonical(null, op, x, y, view);
    70             return canonical(null, op, x, y, view);
    71         }
    71         }
       
    72     }
       
    73 
       
    74     @Override
       
    75     protected BinaryOp<Add> getOp(ArithmeticOpTable table) {
       
    76         return table.getAdd();
    72     }
    77     }
    73 
    78 
    74     private static ValueNode canonical(AddNode addNode, BinaryOp<Add> op, ValueNode forX, ValueNode forY, NodeView view) {
    79     private static ValueNode canonical(AddNode addNode, BinaryOp<Add> op, ValueNode forX, ValueNode forY, NodeView view) {
    75         AddNode self = addNode;
    80         AddNode self = addNode;
    76         boolean associative = op.isAssociative();
    81         boolean associative = op.isAssociative();