src/share/vm/opto/divnode.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/opto/divnode.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,187 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_OPTO_DIVNODE_HPP
    1.29 +#define SHARE_VM_OPTO_DIVNODE_HPP
    1.30 +
    1.31 +#include "opto/multnode.hpp"
    1.32 +#include "opto/node.hpp"
    1.33 +#include "opto/opcodes.hpp"
    1.34 +#include "opto/type.hpp"
    1.35 +
    1.36 +// Portions of code courtesy of Clifford Click
    1.37 +
    1.38 +// Optimization - Graph Style
    1.39 +
    1.40 +
    1.41 +//------------------------------DivINode---------------------------------------
    1.42 +// Integer division
    1.43 +// Note: this is division as defined by JVMS, i.e., MinInt/-1 == MinInt.
    1.44 +// On processors which don't naturally support this special case (e.g., x86),
    1.45 +// the matcher or runtime system must take care of this.
    1.46 +class DivINode : public Node {
    1.47 +public:
    1.48 +  DivINode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor ) {}
    1.49 +  virtual int Opcode() const;
    1.50 +  virtual Node *Identity( PhaseTransform *phase );
    1.51 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
    1.52 +  virtual const Type *Value( PhaseTransform *phase ) const;
    1.53 +  virtual const Type *bottom_type() const { return TypeInt::INT; }
    1.54 +  virtual uint ideal_reg() const { return Op_RegI; }
    1.55 +};
    1.56 +
    1.57 +//------------------------------DivLNode---------------------------------------
    1.58 +// Long division
    1.59 +class DivLNode : public Node {
    1.60 +public:
    1.61 +  DivLNode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor ) {}
    1.62 +  virtual int Opcode() const;
    1.63 +  virtual Node *Identity( PhaseTransform *phase );
    1.64 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
    1.65 +  virtual const Type *Value( PhaseTransform *phase ) const;
    1.66 +  virtual const Type *bottom_type() const { return TypeLong::LONG; }
    1.67 +  virtual uint ideal_reg() const { return Op_RegL; }
    1.68 +};
    1.69 +
    1.70 +//------------------------------DivFNode---------------------------------------
    1.71 +// Float division
    1.72 +class DivFNode : public Node {
    1.73 +public:
    1.74 +  DivFNode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor) {}
    1.75 +  virtual int Opcode() const;
    1.76 +  virtual Node *Identity( PhaseTransform *phase );
    1.77 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
    1.78 +  virtual const Type *Value( PhaseTransform *phase ) const;
    1.79 +  virtual const Type *bottom_type() const { return Type::FLOAT; }
    1.80 +  virtual uint ideal_reg() const { return Op_RegF; }
    1.81 +};
    1.82 +
    1.83 +//------------------------------DivDNode---------------------------------------
    1.84 +// Double division
    1.85 +class DivDNode : public Node {
    1.86 +public:
    1.87 +  DivDNode( Node *c, Node *dividend, Node *divisor ) : Node(c,dividend, divisor) {}
    1.88 +  virtual int Opcode() const;
    1.89 +  virtual Node *Identity( PhaseTransform *phase );
    1.90 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
    1.91 +  virtual const Type *Value( PhaseTransform *phase ) const;
    1.92 +  virtual const Type *bottom_type() const { return Type::DOUBLE; }
    1.93 +  virtual uint ideal_reg() const { return Op_RegD; }
    1.94 +};
    1.95 +
    1.96 +//------------------------------ModINode---------------------------------------
    1.97 +// Integer modulus
    1.98 +class ModINode : public Node {
    1.99 +public:
   1.100 +  ModINode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {}
   1.101 +  virtual int Opcode() const;
   1.102 +  virtual const Type *Value( PhaseTransform *phase ) const;
   1.103 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   1.104 +  virtual const Type *bottom_type() const { return TypeInt::INT; }
   1.105 +  virtual uint ideal_reg() const { return Op_RegI; }
   1.106 +};
   1.107 +
   1.108 +//------------------------------ModLNode---------------------------------------
   1.109 +// Long modulus
   1.110 +class ModLNode : public Node {
   1.111 +public:
   1.112 +  ModLNode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {}
   1.113 +  virtual int Opcode() const;
   1.114 +  virtual const Type *Value( PhaseTransform *phase ) const;
   1.115 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   1.116 +  virtual const Type *bottom_type() const { return TypeLong::LONG; }
   1.117 +  virtual uint ideal_reg() const { return Op_RegL; }
   1.118 +};
   1.119 +
   1.120 +//------------------------------ModFNode---------------------------------------
   1.121 +// Float Modulus
   1.122 +class ModFNode : public Node {
   1.123 +public:
   1.124 +  ModFNode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {}
   1.125 +  virtual int Opcode() const;
   1.126 +  virtual const Type *Value( PhaseTransform *phase ) const;
   1.127 +  virtual const Type *bottom_type() const { return Type::FLOAT; }
   1.128 +  virtual uint ideal_reg() const { return Op_RegF; }
   1.129 +};
   1.130 +
   1.131 +//------------------------------ModDNode---------------------------------------
   1.132 +// Double Modulus
   1.133 +class ModDNode : public Node {
   1.134 +public:
   1.135 +  ModDNode( Node *c, Node *in1, Node *in2 ) : Node(c, in1, in2) {}
   1.136 +  virtual int Opcode() const;
   1.137 +  virtual const Type *Value( PhaseTransform *phase ) const;
   1.138 +  virtual const Type *bottom_type() const { return Type::DOUBLE; }
   1.139 +  virtual uint ideal_reg() const { return Op_RegD; }
   1.140 +};
   1.141 +
   1.142 +//------------------------------DivModNode---------------------------------------
   1.143 +// Division with remainder result.
   1.144 +class DivModNode : public MultiNode {
   1.145 +protected:
   1.146 +  DivModNode( Node *c, Node *dividend, Node *divisor );
   1.147 +public:
   1.148 +  enum {
   1.149 +    div_proj_num =  0,      // quotient
   1.150 +    mod_proj_num =  1       // remainder
   1.151 +  };
   1.152 +  virtual int Opcode() const;
   1.153 +  virtual Node *Identity( PhaseTransform *phase ) { return this; }
   1.154 +  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape) { return NULL; }
   1.155 +  virtual const Type *Value( PhaseTransform *phase ) const { return bottom_type(); }
   1.156 +  virtual uint hash() const { return Node::hash(); }
   1.157 +  virtual bool is_CFG() const  { return false; }
   1.158 +  virtual uint ideal_reg() const { return NotAMachineReg; }
   1.159 +
   1.160 +  ProjNode* div_proj() { return proj_out(div_proj_num); }
   1.161 +  ProjNode* mod_proj() { return proj_out(mod_proj_num); }
   1.162 +};
   1.163 +
   1.164 +//------------------------------DivModINode---------------------------------------
   1.165 +// Integer division with remainder result.
   1.166 +class DivModINode : public DivModNode {
   1.167 +public:
   1.168 +  DivModINode( Node *c, Node *dividend, Node *divisor ) : DivModNode(c, dividend, divisor) {}
   1.169 +  virtual int Opcode() const;
   1.170 +  virtual const Type *bottom_type() const { return TypeTuple::INT_PAIR; }
   1.171 +  virtual Node *match( const ProjNode *proj, const Matcher *m );
   1.172 +
   1.173 +  // Make a divmod and associated projections from a div or mod.
   1.174 +  static DivModINode* make(Compile* C, Node* div_or_mod);
   1.175 +};
   1.176 +
   1.177 +//------------------------------DivModLNode---------------------------------------
   1.178 +// Long division with remainder result.
   1.179 +class DivModLNode : public DivModNode {
   1.180 +public:
   1.181 +  DivModLNode( Node *c, Node *dividend, Node *divisor ) : DivModNode(c, dividend, divisor) {}
   1.182 +  virtual int Opcode() const;
   1.183 +  virtual const Type *bottom_type() const { return TypeTuple::LONG_PAIR; }
   1.184 +  virtual Node *match( const ProjNode *proj, const Matcher *m );
   1.185 +
   1.186 +  // Make a divmod and associated projections from a div or mod.
   1.187 +  static DivModLNode* make(Compile* C, Node* div_or_mod);
   1.188 +};
   1.189 +
   1.190 +#endif // SHARE_VM_OPTO_DIVNODE_HPP

mercurial