src/share/vm/opto/divnode.hpp

changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/opto/divnode.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,177 @@
     1.4 +/*
     1.5 + * Copyright 1997-2005 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +// Portions of code courtesy of Clifford Click
    1.29 +
    1.30 +// Optimization - Graph Style
    1.31 +
    1.32 +
    1.33 +//------------------------------DivINode---------------------------------------
    1.34 +// Integer division
    1.35 +// Note: this is division as defined by JVMS, i.e., MinInt/-1 == MinInt.
    1.36 +// On processors which don't naturally support this special case (e.g., x86),
    1.37 +// the matcher or runtime system must take care of this.
    1.38 +class DivINode : public Node {
    1.39 +public:
    1.40 +  DivINode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor ) {}
    1.41 +  virtual int Opcode() const;
    1.42 +  virtual Node *Identity( PhaseTransform *phase );
    1.43 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
    1.44 +  virtual const Type *Value( PhaseTransform *phase ) const;
    1.45 +  virtual const Type *bottom_type() const { return TypeInt::INT; }
    1.46 +  virtual uint ideal_reg() const { return Op_RegI; }
    1.47 +};
    1.48 +
    1.49 +//------------------------------DivLNode---------------------------------------
    1.50 +// Long division
    1.51 +class DivLNode : public Node {
    1.52 +public:
    1.53 +  DivLNode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor ) {}
    1.54 +  virtual int Opcode() const;
    1.55 +  virtual Node *Identity( PhaseTransform *phase );
    1.56 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
    1.57 +  virtual const Type *Value( PhaseTransform *phase ) const;
    1.58 +  virtual const Type *bottom_type() const { return TypeLong::LONG; }
    1.59 +  virtual uint ideal_reg() const { return Op_RegL; }
    1.60 +};
    1.61 +
    1.62 +//------------------------------DivFNode---------------------------------------
    1.63 +// Float division
    1.64 +class DivFNode : public Node {
    1.65 +public:
    1.66 +  DivFNode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor) {}
    1.67 +  virtual int Opcode() const;
    1.68 +  virtual Node *Identity( PhaseTransform *phase );
    1.69 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
    1.70 +  virtual const Type *Value( PhaseTransform *phase ) const;
    1.71 +  virtual const Type *bottom_type() const { return Type::FLOAT; }
    1.72 +  virtual uint ideal_reg() const { return Op_RegF; }
    1.73 +};
    1.74 +
    1.75 +//------------------------------DivDNode---------------------------------------
    1.76 +// Double division
    1.77 +class DivDNode : public Node {
    1.78 +public:
    1.79 +  DivDNode( Node *c, Node *dividend, Node *divisor ) : Node(c,dividend, divisor) {}
    1.80 +  virtual int Opcode() const;
    1.81 +  virtual Node *Identity( PhaseTransform *phase );
    1.82 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
    1.83 +  virtual const Type *Value( PhaseTransform *phase ) const;
    1.84 +  virtual const Type *bottom_type() const { return Type::DOUBLE; }
    1.85 +  virtual uint ideal_reg() const { return Op_RegD; }
    1.86 +};
    1.87 +
    1.88 +//------------------------------ModINode---------------------------------------
    1.89 +// Integer modulus
    1.90 +class ModINode : public Node {
    1.91 +public:
    1.92 +  ModINode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {}
    1.93 +  virtual int Opcode() const;
    1.94 +  virtual const Type *Value( PhaseTransform *phase ) const;
    1.95 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
    1.96 +  virtual const Type *bottom_type() const { return TypeInt::INT; }
    1.97 +  virtual uint ideal_reg() const { return Op_RegI; }
    1.98 +};
    1.99 +
   1.100 +//------------------------------ModLNode---------------------------------------
   1.101 +// Long modulus
   1.102 +class ModLNode : public Node {
   1.103 +public:
   1.104 +  ModLNode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {}
   1.105 +  virtual int Opcode() const;
   1.106 +  virtual const Type *Value( PhaseTransform *phase ) const;
   1.107 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   1.108 +  virtual const Type *bottom_type() const { return TypeLong::LONG; }
   1.109 +  virtual uint ideal_reg() const { return Op_RegL; }
   1.110 +};
   1.111 +
   1.112 +//------------------------------ModFNode---------------------------------------
   1.113 +// Float Modulus
   1.114 +class ModFNode : public Node {
   1.115 +public:
   1.116 +  ModFNode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {}
   1.117 +  virtual int Opcode() const;
   1.118 +  virtual const Type *Value( PhaseTransform *phase ) const;
   1.119 +  virtual const Type *bottom_type() const { return Type::FLOAT; }
   1.120 +  virtual uint ideal_reg() const { return Op_RegF; }
   1.121 +};
   1.122 +
   1.123 +//------------------------------ModDNode---------------------------------------
   1.124 +// Double Modulus
   1.125 +class ModDNode : public Node {
   1.126 +public:
   1.127 +  ModDNode( Node *c, Node *in1, Node *in2 ) : Node(c, in1, in2) {}
   1.128 +  virtual int Opcode() const;
   1.129 +  virtual const Type *Value( PhaseTransform *phase ) const;
   1.130 +  virtual const Type *bottom_type() const { return Type::DOUBLE; }
   1.131 +  virtual uint ideal_reg() const { return Op_RegD; }
   1.132 +};
   1.133 +
   1.134 +//------------------------------DivModNode---------------------------------------
   1.135 +// Division with remainder result.
   1.136 +class DivModNode : public MultiNode {
   1.137 +protected:
   1.138 +  DivModNode( Node *c, Node *dividend, Node *divisor );
   1.139 +public:
   1.140 +  enum {
   1.141 +    div_proj_num =  0,      // quotient
   1.142 +    mod_proj_num =  1       // remainder
   1.143 +  };
   1.144 +  virtual int Opcode() const;
   1.145 +  virtual Node *Identity( PhaseTransform *phase ) { return this; }
   1.146 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape) { return NULL; }
   1.147 +  virtual const Type *Value( PhaseTransform *phase ) const { return bottom_type(); }
   1.148 +  virtual uint hash() const { return Node::hash(); }
   1.149 +  virtual bool is_CFG() const  { return false; }
   1.150 +  virtual uint ideal_reg() const { return NotAMachineReg; }
   1.151 +
   1.152 +  ProjNode* div_proj() { return proj_out(div_proj_num); }
   1.153 +  ProjNode* mod_proj() { return proj_out(mod_proj_num); }
   1.154 +};
   1.155 +
   1.156 +//------------------------------DivModINode---------------------------------------
   1.157 +// Integer division with remainder result.
   1.158 +class DivModINode : public DivModNode {
   1.159 +public:
   1.160 +  DivModINode( Node *c, Node *dividend, Node *divisor ) : DivModNode(c, dividend, divisor) {}
   1.161 +  virtual int Opcode() const;
   1.162 +  virtual const Type *bottom_type() const { return TypeTuple::INT_PAIR; }
   1.163 +  virtual Node *match( const ProjNode *proj, const Matcher *m );
   1.164 +
   1.165 +  // Make a divmod and associated projections from a div or mod.
   1.166 +  static DivModINode* make(Compile* C, Node* div_or_mod);
   1.167 +};
   1.168 +
   1.169 +//------------------------------DivModLNode---------------------------------------
   1.170 +// Long division with remainder result.
   1.171 +class DivModLNode : public DivModNode {
   1.172 +public:
   1.173 +  DivModLNode( Node *c, Node *dividend, Node *divisor ) : DivModNode(c, dividend, divisor) {}
   1.174 +  virtual int Opcode() const;
   1.175 +  virtual const Type *bottom_type() const { return TypeTuple::LONG_PAIR; }
   1.176 +  virtual Node *match( const ProjNode *proj, const Matcher *m );
   1.177 +
   1.178 +  // Make a divmod and associated projections from a div or mod.
   1.179 +  static DivModLNode* make(Compile* C, Node* div_or_mod);
   1.180 +};

mercurial