src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/NegateNode.java
changeset 58533 46b0b7fe255c
parent 52910 583fd71c47d6
equal deleted inserted replaced
58532:b4f2e13d20ea 58533:46b0b7fe255c
     1 /*
     1 /*
     2  * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2009, 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.
    24 
    24 
    25 package org.graalvm.compiler.nodes.calc;
    25 package org.graalvm.compiler.nodes.calc;
    26 
    26 
    27 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_2;
    27 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_2;
    28 import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_1;
    28 import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_1;
       
    29 import static org.graalvm.compiler.nodes.calc.BinaryArithmeticNode.getArithmeticOpTable;
    29 
    30 
    30 import org.graalvm.compiler.core.common.type.ArithmeticOpTable;
    31 import org.graalvm.compiler.core.common.type.ArithmeticOpTable;
       
    32 import org.graalvm.compiler.core.common.type.ArithmeticOpTable.UnaryOp;
    31 import org.graalvm.compiler.core.common.type.ArithmeticOpTable.UnaryOp.Neg;
    33 import org.graalvm.compiler.core.common.type.ArithmeticOpTable.UnaryOp.Neg;
    32 import org.graalvm.compiler.core.common.type.FloatStamp;
    34 import org.graalvm.compiler.core.common.type.FloatStamp;
    33 import org.graalvm.compiler.core.common.type.Stamp;
    35 import org.graalvm.compiler.core.common.type.Stamp;
    34 import org.graalvm.compiler.graph.NodeClass;
    36 import org.graalvm.compiler.graph.NodeClass;
    35 import org.graalvm.compiler.graph.spi.CanonicalizerTool;
    37 import org.graalvm.compiler.graph.spi.CanonicalizerTool;
    47 public final class NegateNode extends UnaryArithmeticNode<Neg> implements NarrowableArithmeticNode, StampInverter {
    49 public final class NegateNode extends UnaryArithmeticNode<Neg> implements NarrowableArithmeticNode, StampInverter {
    48 
    50 
    49     public static final NodeClass<NegateNode> TYPE = NodeClass.create(NegateNode.class);
    51     public static final NodeClass<NegateNode> TYPE = NodeClass.create(NegateNode.class);
    50 
    52 
    51     public NegateNode(ValueNode value) {
    53     public NegateNode(ValueNode value) {
    52         super(TYPE, ArithmeticOpTable::getNeg, value);
    54         super(TYPE, getArithmeticOpTable(value).getNeg(), value);
    53     }
    55     }
    54 
    56 
    55     public static ValueNode create(ValueNode value, NodeView view) {
    57     public static ValueNode create(ValueNode value, NodeView view) {
    56         ValueNode synonym = findSynonym(value, view);
    58         ValueNode synonym = findSynonym(value, view);
    57         if (synonym != null) {
    59         if (synonym != null) {
    58             return synonym;
    60             return synonym;
    59         }
    61         }
    60         return new NegateNode(value);
    62         return new NegateNode(value);
       
    63     }
       
    64 
       
    65     @Override
       
    66     protected UnaryOp<Neg> getOp(ArithmeticOpTable table) {
       
    67         return table.getNeg();
    61     }
    68     }
    62 
    69 
    63     @Override
    70     @Override
    64     public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) {
    71     public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) {
    65         ValueNode synonym = findSynonym(forValue, getOp(forValue));
    72         ValueNode synonym = findSynonym(forValue, getOp(forValue));