0N/A/*
1879N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_OPTO_DIVNODE_HPP
1879N/A#define SHARE_VM_OPTO_DIVNODE_HPP
1879N/A
1879N/A#include "opto/multnode.hpp"
1879N/A#include "opto/node.hpp"
1879N/A#include "opto/opcodes.hpp"
1879N/A#include "opto/type.hpp"
1879N/A
0N/A// Portions of code courtesy of Clifford Click
0N/A
0N/A// Optimization - Graph Style
0N/A
0N/A
0N/A//------------------------------DivINode---------------------------------------
0N/A// Integer division
0N/A// Note: this is division as defined by JVMS, i.e., MinInt/-1 == MinInt.
0N/A// On processors which don't naturally support this special case (e.g., x86),
0N/A// the matcher or runtime system must take care of this.
0N/Aclass DivINode : public Node {
0N/Apublic:
0N/A DivINode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor ) {}
0N/A virtual int Opcode() const;
0N/A virtual Node *Identity( PhaseTransform *phase );
0N/A virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
0N/A virtual const Type *Value( PhaseTransform *phase ) const;
0N/A virtual const Type *bottom_type() const { return TypeInt::INT; }
0N/A virtual uint ideal_reg() const { return Op_RegI; }
0N/A};
0N/A
0N/A//------------------------------DivLNode---------------------------------------
0N/A// Long division
0N/Aclass DivLNode : public Node {
0N/Apublic:
0N/A DivLNode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor ) {}
0N/A virtual int Opcode() const;
0N/A virtual Node *Identity( PhaseTransform *phase );
0N/A virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
0N/A virtual const Type *Value( PhaseTransform *phase ) const;
0N/A virtual const Type *bottom_type() const { return TypeLong::LONG; }
0N/A virtual uint ideal_reg() const { return Op_RegL; }
0N/A};
0N/A
0N/A//------------------------------DivFNode---------------------------------------
0N/A// Float division
0N/Aclass DivFNode : public Node {
0N/Apublic:
0N/A DivFNode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor) {}
0N/A virtual int Opcode() const;
0N/A virtual Node *Identity( PhaseTransform *phase );
0N/A virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
0N/A virtual const Type *Value( PhaseTransform *phase ) const;
0N/A virtual const Type *bottom_type() const { return Type::FLOAT; }
0N/A virtual uint ideal_reg() const { return Op_RegF; }
0N/A};
0N/A
0N/A//------------------------------DivDNode---------------------------------------
0N/A// Double division
0N/Aclass DivDNode : public Node {
0N/Apublic:
0N/A DivDNode( Node *c, Node *dividend, Node *divisor ) : Node(c,dividend, divisor) {}
0N/A virtual int Opcode() const;
0N/A virtual Node *Identity( PhaseTransform *phase );
0N/A virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
0N/A virtual const Type *Value( PhaseTransform *phase ) const;
0N/A virtual const Type *bottom_type() const { return Type::DOUBLE; }
0N/A virtual uint ideal_reg() const { return Op_RegD; }
0N/A};
0N/A
0N/A//------------------------------ModINode---------------------------------------
0N/A// Integer modulus
0N/Aclass ModINode : public Node {
0N/Apublic:
0N/A ModINode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {}
0N/A virtual int Opcode() const;
0N/A virtual const Type *Value( PhaseTransform *phase ) const;
0N/A virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
0N/A virtual const Type *bottom_type() const { return TypeInt::INT; }
0N/A virtual uint ideal_reg() const { return Op_RegI; }
0N/A};
0N/A
0N/A//------------------------------ModLNode---------------------------------------
0N/A// Long modulus
0N/Aclass ModLNode : public Node {
0N/Apublic:
0N/A ModLNode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {}
0N/A virtual int Opcode() const;
0N/A virtual const Type *Value( PhaseTransform *phase ) const;
0N/A virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
0N/A virtual const Type *bottom_type() const { return TypeLong::LONG; }
0N/A virtual uint ideal_reg() const { return Op_RegL; }
0N/A};
0N/A
0N/A//------------------------------ModFNode---------------------------------------
0N/A// Float Modulus
0N/Aclass ModFNode : public Node {
0N/Apublic:
0N/A ModFNode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {}
0N/A virtual int Opcode() const;
0N/A virtual const Type *Value( PhaseTransform *phase ) const;
0N/A virtual const Type *bottom_type() const { return Type::FLOAT; }
0N/A virtual uint ideal_reg() const { return Op_RegF; }
0N/A};
0N/A
0N/A//------------------------------ModDNode---------------------------------------
0N/A// Double Modulus
0N/Aclass ModDNode : public Node {
0N/Apublic:
0N/A ModDNode( Node *c, Node *in1, Node *in2 ) : Node(c, in1, in2) {}
0N/A virtual int Opcode() const;
0N/A virtual const Type *Value( PhaseTransform *phase ) const;
0N/A virtual const Type *bottom_type() const { return Type::DOUBLE; }
0N/A virtual uint ideal_reg() const { return Op_RegD; }
0N/A};
0N/A
0N/A//------------------------------DivModNode---------------------------------------
0N/A// Division with remainder result.
0N/Aclass DivModNode : public MultiNode {
0N/Aprotected:
0N/A DivModNode( Node *c, Node *dividend, Node *divisor );
0N/Apublic:
0N/A enum {
0N/A div_proj_num = 0, // quotient
0N/A mod_proj_num = 1 // remainder
0N/A };
0N/A virtual int Opcode() const;
0N/A virtual Node *Identity( PhaseTransform *phase ) { return this; }
0N/A virtual Node *Ideal(PhaseGVN *phase, bool can_reshape) { return NULL; }
0N/A virtual const Type *Value( PhaseTransform *phase ) const { return bottom_type(); }
0N/A virtual uint hash() const { return Node::hash(); }
0N/A virtual bool is_CFG() const { return false; }
0N/A virtual uint ideal_reg() const { return NotAMachineReg; }
0N/A
0N/A ProjNode* div_proj() { return proj_out(div_proj_num); }
0N/A ProjNode* mod_proj() { return proj_out(mod_proj_num); }
0N/A};
0N/A
0N/A//------------------------------DivModINode---------------------------------------
0N/A// Integer division with remainder result.
0N/Aclass DivModINode : public DivModNode {
0N/Apublic:
0N/A DivModINode( Node *c, Node *dividend, Node *divisor ) : DivModNode(c, dividend, divisor) {}
0N/A virtual int Opcode() const;
0N/A virtual const Type *bottom_type() const { return TypeTuple::INT_PAIR; }
0N/A virtual Node *match( const ProjNode *proj, const Matcher *m );
0N/A
0N/A // Make a divmod and associated projections from a div or mod.
0N/A static DivModINode* make(Compile* C, Node* div_or_mod);
0N/A};
0N/A
0N/A//------------------------------DivModLNode---------------------------------------
0N/A// Long division with remainder result.
0N/Aclass DivModLNode : public DivModNode {
0N/Apublic:
0N/A DivModLNode( Node *c, Node *dividend, Node *divisor ) : DivModNode(c, dividend, divisor) {}
0N/A virtual int Opcode() const;
0N/A virtual const Type *bottom_type() const { return TypeTuple::LONG_PAIR; }
0N/A virtual Node *match( const ProjNode *proj, const Matcher *m );
0N/A
0N/A // Make a divmod and associated projections from a div or mod.
0N/A static DivModLNode* make(Compile* C, Node* div_or_mod);
0N/A};
1879N/A
1879N/A#endif // SHARE_VM_OPTO_DIVNODE_HPP