src/share/vm/opto/divnode.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_OPTO_DIVNODE_HPP
aoqi@0 26 #define SHARE_VM_OPTO_DIVNODE_HPP
aoqi@0 27
aoqi@0 28 #include "opto/multnode.hpp"
aoqi@0 29 #include "opto/node.hpp"
aoqi@0 30 #include "opto/opcodes.hpp"
aoqi@0 31 #include "opto/type.hpp"
aoqi@0 32
aoqi@0 33 // Portions of code courtesy of Clifford Click
aoqi@0 34
aoqi@0 35 // Optimization - Graph Style
aoqi@0 36
aoqi@0 37
aoqi@0 38 //------------------------------DivINode---------------------------------------
aoqi@0 39 // Integer division
aoqi@0 40 // Note: this is division as defined by JVMS, i.e., MinInt/-1 == MinInt.
aoqi@0 41 // On processors which don't naturally support this special case (e.g., x86),
aoqi@0 42 // the matcher or runtime system must take care of this.
aoqi@0 43 class DivINode : public Node {
aoqi@0 44 public:
aoqi@0 45 DivINode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor ) {}
aoqi@0 46 virtual int Opcode() const;
aoqi@0 47 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 48 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 49 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 50 virtual const Type *bottom_type() const { return TypeInt::INT; }
aoqi@0 51 virtual uint ideal_reg() const { return Op_RegI; }
aoqi@0 52 };
aoqi@0 53
aoqi@0 54 //------------------------------DivLNode---------------------------------------
aoqi@0 55 // Long division
aoqi@0 56 class DivLNode : public Node {
aoqi@0 57 public:
aoqi@0 58 DivLNode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor ) {}
aoqi@0 59 virtual int Opcode() const;
aoqi@0 60 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 61 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 62 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 63 virtual const Type *bottom_type() const { return TypeLong::LONG; }
aoqi@0 64 virtual uint ideal_reg() const { return Op_RegL; }
aoqi@0 65 };
aoqi@0 66
aoqi@0 67 //------------------------------DivFNode---------------------------------------
aoqi@0 68 // Float division
aoqi@0 69 class DivFNode : public Node {
aoqi@0 70 public:
aoqi@0 71 DivFNode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor) {}
aoqi@0 72 virtual int Opcode() const;
aoqi@0 73 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 74 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 75 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 76 virtual const Type *bottom_type() const { return Type::FLOAT; }
aoqi@0 77 virtual uint ideal_reg() const { return Op_RegF; }
aoqi@0 78 };
aoqi@0 79
aoqi@0 80 //------------------------------DivDNode---------------------------------------
aoqi@0 81 // Double division
aoqi@0 82 class DivDNode : public Node {
aoqi@0 83 public:
aoqi@0 84 DivDNode( Node *c, Node *dividend, Node *divisor ) : Node(c,dividend, divisor) {}
aoqi@0 85 virtual int Opcode() const;
aoqi@0 86 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 87 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 88 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 89 virtual const Type *bottom_type() const { return Type::DOUBLE; }
aoqi@0 90 virtual uint ideal_reg() const { return Op_RegD; }
aoqi@0 91 };
aoqi@0 92
aoqi@0 93 //------------------------------ModINode---------------------------------------
aoqi@0 94 // Integer modulus
aoqi@0 95 class ModINode : public Node {
aoqi@0 96 public:
aoqi@0 97 ModINode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {}
aoqi@0 98 virtual int Opcode() const;
aoqi@0 99 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 100 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 101 virtual const Type *bottom_type() const { return TypeInt::INT; }
aoqi@0 102 virtual uint ideal_reg() const { return Op_RegI; }
aoqi@0 103 };
aoqi@0 104
aoqi@0 105 //------------------------------ModLNode---------------------------------------
aoqi@0 106 // Long modulus
aoqi@0 107 class ModLNode : public Node {
aoqi@0 108 public:
aoqi@0 109 ModLNode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {}
aoqi@0 110 virtual int Opcode() const;
aoqi@0 111 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 112 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 113 virtual const Type *bottom_type() const { return TypeLong::LONG; }
aoqi@0 114 virtual uint ideal_reg() const { return Op_RegL; }
aoqi@0 115 };
aoqi@0 116
aoqi@0 117 //------------------------------ModFNode---------------------------------------
aoqi@0 118 // Float Modulus
aoqi@0 119 class ModFNode : public Node {
aoqi@0 120 public:
aoqi@0 121 ModFNode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {}
aoqi@0 122 virtual int Opcode() const;
aoqi@0 123 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 124 virtual const Type *bottom_type() const { return Type::FLOAT; }
aoqi@0 125 virtual uint ideal_reg() const { return Op_RegF; }
aoqi@0 126 };
aoqi@0 127
aoqi@0 128 //------------------------------ModDNode---------------------------------------
aoqi@0 129 // Double Modulus
aoqi@0 130 class ModDNode : public Node {
aoqi@0 131 public:
aoqi@0 132 ModDNode( Node *c, Node *in1, Node *in2 ) : Node(c, in1, in2) {}
aoqi@0 133 virtual int Opcode() const;
aoqi@0 134 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 135 virtual const Type *bottom_type() const { return Type::DOUBLE; }
aoqi@0 136 virtual uint ideal_reg() const { return Op_RegD; }
aoqi@0 137 };
aoqi@0 138
aoqi@0 139 //------------------------------DivModNode---------------------------------------
aoqi@0 140 // Division with remainder result.
aoqi@0 141 class DivModNode : public MultiNode {
aoqi@0 142 protected:
aoqi@0 143 DivModNode( Node *c, Node *dividend, Node *divisor );
aoqi@0 144 public:
aoqi@0 145 enum {
aoqi@0 146 div_proj_num = 0, // quotient
aoqi@0 147 mod_proj_num = 1 // remainder
aoqi@0 148 };
aoqi@0 149 virtual int Opcode() const;
aoqi@0 150 virtual Node *Identity( PhaseTransform *phase ) { return this; }
aoqi@0 151 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape) { return NULL; }
aoqi@0 152 virtual const Type *Value( PhaseTransform *phase ) const { return bottom_type(); }
aoqi@0 153 virtual uint hash() const { return Node::hash(); }
aoqi@0 154 virtual bool is_CFG() const { return false; }
aoqi@0 155 virtual uint ideal_reg() const { return NotAMachineReg; }
aoqi@0 156
aoqi@0 157 ProjNode* div_proj() { return proj_out(div_proj_num); }
aoqi@0 158 ProjNode* mod_proj() { return proj_out(mod_proj_num); }
aoqi@0 159 };
aoqi@0 160
aoqi@0 161 //------------------------------DivModINode---------------------------------------
aoqi@0 162 // Integer division with remainder result.
aoqi@0 163 class DivModINode : public DivModNode {
aoqi@0 164 public:
aoqi@0 165 DivModINode( Node *c, Node *dividend, Node *divisor ) : DivModNode(c, dividend, divisor) {}
aoqi@0 166 virtual int Opcode() const;
aoqi@0 167 virtual const Type *bottom_type() const { return TypeTuple::INT_PAIR; }
aoqi@0 168 virtual Node *match( const ProjNode *proj, const Matcher *m );
aoqi@0 169
aoqi@0 170 // Make a divmod and associated projections from a div or mod.
aoqi@0 171 static DivModINode* make(Compile* C, Node* div_or_mod);
aoqi@0 172 };
aoqi@0 173
aoqi@0 174 //------------------------------DivModLNode---------------------------------------
aoqi@0 175 // Long division with remainder result.
aoqi@0 176 class DivModLNode : public DivModNode {
aoqi@0 177 public:
aoqi@0 178 DivModLNode( Node *c, Node *dividend, Node *divisor ) : DivModNode(c, dividend, divisor) {}
aoqi@0 179 virtual int Opcode() const;
aoqi@0 180 virtual const Type *bottom_type() const { return TypeTuple::LONG_PAIR; }
aoqi@0 181 virtual Node *match( const ProjNode *proj, const Matcher *m );
aoqi@0 182
aoqi@0 183 // Make a divmod and associated projections from a div or mod.
aoqi@0 184 static DivModLNode* make(Compile* C, Node* div_or_mod);
aoqi@0 185 };
aoqi@0 186
aoqi@0 187 #endif // SHARE_VM_OPTO_DIVNODE_HPP

mercurial