1 /* 2 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_OPTO_SUBNODE_HPP 26 #define SHARE_OPTO_SUBNODE_HPP 27 28 #include "opto/node.hpp" 29 #include "opto/opcodes.hpp" 30 #include "opto/type.hpp" 31 32 // Portions of code courtesy of Clifford Click 33 34 //------------------------------SUBNode---------------------------------------- 35 // Class SUBTRACTION functionality. This covers all the usual 'subtract' 36 // behaviors. Subtract-integer, -float, -double, binary xor, compare-integer, 37 // -float, and -double are all inherited from this class. The compare 38 // functions behave like subtract functions, except that all negative answers 39 // are compressed into -1, and all positive answers compressed to 1. 40 class SubNode : public Node { 41 public: SubNode(Node * in1,Node * in2)42 SubNode( Node *in1, Node *in2 ) : Node(0,in1,in2) { 43 init_class_id(Class_Sub); 44 } 45 46 // Handle algebraic identities here. If we have an identity, return the Node 47 // we are equivalent to. We look for "add of zero" as an identity. 48 virtual Node* Identity(PhaseGVN* phase); 49 50 // Compute a new Type for this node. Basically we just do the pre-check, 51 // then call the virtual add() to set the type. 52 virtual const Type* Value(PhaseGVN* phase) const; 53 const Type* Value_common( PhaseTransform *phase ) const; 54 55 // Supplied function returns the subtractend of the inputs. 56 // This also type-checks the inputs for sanity. Guaranteed never to 57 // be passed a TOP or BOTTOM type, these are filtered out by a pre-check. 58 virtual const Type *sub( const Type *, const Type * ) const = 0; 59 60 // Supplied function to return the additive identity type. 61 // This is returned whenever the subtracts inputs are the same. 62 virtual const Type *add_id() const = 0; 63 64 static SubNode* make(Node* in1, Node* in2, BasicType bt); 65 }; 66 67 68 // NOTE: SubINode should be taken away and replaced by add and negate 69 //------------------------------SubINode--------------------------------------- 70 // Subtract 2 integers 71 class SubINode : public SubNode { 72 public: SubINode(Node * in1,Node * in2)73 SubINode( Node *in1, Node *in2 ) : SubNode(in1,in2) {} 74 virtual int Opcode() const; 75 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 76 virtual const Type *sub( const Type *, const Type * ) const; add_id() const77 const Type *add_id() const { return TypeInt::ZERO; } bottom_type() const78 const Type *bottom_type() const { return TypeInt::INT; } ideal_reg() const79 virtual uint ideal_reg() const { return Op_RegI; } 80 }; 81 82 //------------------------------SubLNode--------------------------------------- 83 // Subtract 2 integers 84 class SubLNode : public SubNode { 85 public: SubLNode(Node * in1,Node * in2)86 SubLNode( Node *in1, Node *in2 ) : SubNode(in1,in2) {} 87 virtual int Opcode() const; 88 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 89 virtual const Type *sub( const Type *, const Type * ) const; add_id() const90 const Type *add_id() const { return TypeLong::ZERO; } bottom_type() const91 const Type *bottom_type() const { return TypeLong::LONG; } ideal_reg() const92 virtual uint ideal_reg() const { return Op_RegL; } 93 }; 94 95 // NOTE: SubFPNode should be taken away and replaced by add and negate 96 //------------------------------SubFPNode-------------------------------------- 97 // Subtract 2 floats or doubles 98 class SubFPNode : public SubNode { 99 protected: SubFPNode(Node * in1,Node * in2)100 SubFPNode( Node *in1, Node *in2 ) : SubNode(in1,in2) {} 101 public: 102 const Type* Value(PhaseGVN* phase) const; 103 }; 104 105 // NOTE: SubFNode should be taken away and replaced by add and negate 106 //------------------------------SubFNode--------------------------------------- 107 // Subtract 2 doubles 108 class SubFNode : public SubFPNode { 109 public: SubFNode(Node * in1,Node * in2)110 SubFNode( Node *in1, Node *in2 ) : SubFPNode(in1,in2) {} 111 virtual int Opcode() const; 112 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 113 virtual const Type *sub( const Type *, const Type * ) const; add_id() const114 const Type *add_id() const { return TypeF::ZERO; } bottom_type() const115 const Type *bottom_type() const { return Type::FLOAT; } ideal_reg() const116 virtual uint ideal_reg() const { return Op_RegF; } 117 }; 118 119 // NOTE: SubDNode should be taken away and replaced by add and negate 120 //------------------------------SubDNode--------------------------------------- 121 // Subtract 2 doubles 122 class SubDNode : public SubFPNode { 123 public: SubDNode(Node * in1,Node * in2)124 SubDNode( Node *in1, Node *in2 ) : SubFPNode(in1,in2) {} 125 virtual int Opcode() const; 126 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 127 virtual const Type *sub( const Type *, const Type * ) const; add_id() const128 const Type *add_id() const { return TypeD::ZERO; } bottom_type() const129 const Type *bottom_type() const { return Type::DOUBLE; } ideal_reg() const130 virtual uint ideal_reg() const { return Op_RegD; } 131 }; 132 133 //------------------------------CmpNode--------------------------------------- 134 // Compare 2 values, returning condition codes (-1, 0 or 1). 135 class CmpNode : public SubNode { 136 public: CmpNode(Node * in1,Node * in2)137 CmpNode( Node *in1, Node *in2 ) : SubNode(in1,in2) { 138 init_class_id(Class_Cmp); 139 } 140 virtual Node* Identity(PhaseGVN* phase); add_id() const141 const Type *add_id() const { return TypeInt::ZERO; } bottom_type() const142 const Type *bottom_type() const { return TypeInt::CC; } ideal_reg() const143 virtual uint ideal_reg() const { return Op_RegFlags; } 144 145 static CmpNode *make(Node *in1, Node *in2, BasicType bt, bool unsigned_comp = false); 146 147 #ifndef PRODUCT 148 // CmpNode and subclasses include all data inputs (until hitting a control 149 // boundary) in their related node set, as well as all outputs until and 150 // including eventual control nodes and their projections. 151 virtual void related(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const; 152 #endif operates_on(BasicType bt,bool signed_int) const153 virtual bool operates_on(BasicType bt, bool signed_int) const { 154 assert(bt == T_INT || bt == T_LONG, "unsupported"); 155 return false; 156 } 157 }; 158 159 //------------------------------CmpINode--------------------------------------- 160 // Compare 2 signed values, returning condition codes (-1, 0 or 1). 161 class CmpINode : public CmpNode { 162 public: CmpINode(Node * in1,Node * in2)163 CmpINode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} 164 virtual int Opcode() const; 165 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 166 virtual const Type *sub( const Type *, const Type * ) const; operates_on(BasicType bt,bool signed_int) const167 virtual bool operates_on(BasicType bt, bool signed_int) const { 168 assert(bt == T_INT || bt == T_LONG, "unsupported"); 169 return bt == T_INT && signed_int; 170 } 171 }; 172 173 //------------------------------CmpUNode--------------------------------------- 174 // Compare 2 unsigned values (integer or pointer), returning condition codes (-1, 0 or 1). 175 class CmpUNode : public CmpNode { 176 public: CmpUNode(Node * in1,Node * in2)177 CmpUNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} 178 virtual int Opcode() const; 179 virtual const Type *sub( const Type *, const Type * ) const; 180 const Type* Value(PhaseGVN* phase) const; 181 bool is_index_range_check() const; operates_on(BasicType bt,bool signed_int) const182 virtual bool operates_on(BasicType bt, bool signed_int) const { 183 assert(bt == T_INT || bt == T_LONG, "unsupported"); 184 return bt == T_INT && !signed_int; 185 } 186 }; 187 188 //------------------------------CmpPNode--------------------------------------- 189 // Compare 2 pointer values, returning condition codes (-1, 0 or 1). 190 class CmpPNode : public CmpNode { 191 public: CmpPNode(Node * in1,Node * in2)192 CmpPNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} 193 virtual int Opcode() const; 194 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 195 virtual const Type *sub( const Type *, const Type * ) const; 196 }; 197 198 //------------------------------CmpNNode-------------------------------------- 199 // Compare 2 narrow oop values, returning condition codes (-1, 0 or 1). 200 class CmpNNode : public CmpNode { 201 public: CmpNNode(Node * in1,Node * in2)202 CmpNNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} 203 virtual int Opcode() const; 204 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 205 virtual const Type *sub( const Type *, const Type * ) const; 206 }; 207 208 //------------------------------CmpLNode--------------------------------------- 209 // Compare 2 long values, returning condition codes (-1, 0 or 1). 210 class CmpLNode : public CmpNode { 211 public: CmpLNode(Node * in1,Node * in2)212 CmpLNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} 213 virtual int Opcode() const; 214 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 215 virtual const Type *sub( const Type *, const Type * ) const; operates_on(BasicType bt,bool signed_int) const216 virtual bool operates_on(BasicType bt, bool signed_int) const { 217 assert(bt == T_INT || bt == T_LONG, "unsupported"); 218 return bt == T_LONG && signed_int; 219 } 220 }; 221 222 //------------------------------CmpULNode--------------------------------------- 223 // Compare 2 unsigned long values, returning condition codes (-1, 0 or 1). 224 class CmpULNode : public CmpNode { 225 public: CmpULNode(Node * in1,Node * in2)226 CmpULNode(Node* in1, Node* in2) : CmpNode(in1, in2) { } 227 virtual int Opcode() const; 228 virtual const Type* sub(const Type*, const Type*) const; operates_on(BasicType bt,bool signed_int) const229 virtual bool operates_on(BasicType bt, bool signed_int) const { 230 assert(bt == T_INT || bt == T_LONG, "unsupported"); 231 return bt == T_LONG && !signed_int; 232 } 233 }; 234 235 //------------------------------CmpL3Node-------------------------------------- 236 // Compare 2 long values, returning integer value (-1, 0 or 1). 237 class CmpL3Node : public CmpLNode { 238 public: CmpL3Node(Node * in1,Node * in2)239 CmpL3Node( Node *in1, Node *in2 ) : CmpLNode(in1,in2) { 240 // Since it is not consumed by Bools, it is not really a Cmp. 241 init_class_id(Class_Sub); 242 } 243 virtual int Opcode() const; ideal_reg() const244 virtual uint ideal_reg() const { return Op_RegI; } 245 }; 246 247 //------------------------------CmpFNode--------------------------------------- 248 // Compare 2 float values, returning condition codes (-1, 0 or 1). 249 // This implements the Java bytecode fcmpl, so unordered returns -1. 250 // Operands may not commute. 251 class CmpFNode : public CmpNode { 252 public: CmpFNode(Node * in1,Node * in2)253 CmpFNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} 254 virtual int Opcode() const; sub(const Type *,const Type *) const255 virtual const Type *sub( const Type *, const Type * ) const { ShouldNotReachHere(); return NULL; } 256 const Type* Value(PhaseGVN* phase) const; 257 }; 258 259 //------------------------------CmpF3Node-------------------------------------- 260 // Compare 2 float values, returning integer value (-1, 0 or 1). 261 // This implements the Java bytecode fcmpl, so unordered returns -1. 262 // Operands may not commute. 263 class CmpF3Node : public CmpFNode { 264 public: CmpF3Node(Node * in1,Node * in2)265 CmpF3Node( Node *in1, Node *in2 ) : CmpFNode(in1,in2) { 266 // Since it is not consumed by Bools, it is not really a Cmp. 267 init_class_id(Class_Sub); 268 } 269 virtual int Opcode() const; 270 // Since it is not consumed by Bools, it is not really a Cmp. ideal_reg() const271 virtual uint ideal_reg() const { return Op_RegI; } 272 }; 273 274 275 //------------------------------CmpDNode--------------------------------------- 276 // Compare 2 double values, returning condition codes (-1, 0 or 1). 277 // This implements the Java bytecode dcmpl, so unordered returns -1. 278 // Operands may not commute. 279 class CmpDNode : public CmpNode { 280 public: CmpDNode(Node * in1,Node * in2)281 CmpDNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} 282 virtual int Opcode() const; sub(const Type *,const Type *) const283 virtual const Type *sub( const Type *, const Type * ) const { ShouldNotReachHere(); return NULL; } 284 const Type* Value(PhaseGVN* phase) const; 285 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 286 }; 287 288 //------------------------------CmpD3Node-------------------------------------- 289 // Compare 2 double values, returning integer value (-1, 0 or 1). 290 // This implements the Java bytecode dcmpl, so unordered returns -1. 291 // Operands may not commute. 292 class CmpD3Node : public CmpDNode { 293 public: CmpD3Node(Node * in1,Node * in2)294 CmpD3Node( Node *in1, Node *in2 ) : CmpDNode(in1,in2) { 295 // Since it is not consumed by Bools, it is not really a Cmp. 296 init_class_id(Class_Sub); 297 } 298 virtual int Opcode() const; ideal_reg() const299 virtual uint ideal_reg() const { return Op_RegI; } 300 }; 301 302 303 //------------------------------BoolTest--------------------------------------- 304 // Convert condition codes to a boolean test value (0 or -1). 305 // We pick the values as 3 bits; the low order 2 bits we compare against the 306 // condition codes, the high bit flips the sense of the result. 307 struct BoolTest { 308 enum mask { eq = 0, ne = 4, le = 5, ge = 7, lt = 3, gt = 1, overflow = 2, no_overflow = 6, never = 8, illegal = 9 }; 309 mask _test; BoolTestBoolTest310 BoolTest( mask btm ) : _test(btm) {} 311 const Type *cc2logical( const Type *CC ) const; 312 // Commute the test. I use a small table lookup. The table is created as 313 // a simple char array where each element is the ASCII version of a 'mask' 314 // enum from above. commuteBoolTest315 mask commute( ) const { return mask("032147658"[_test]-'0'); } negateBoolTest316 mask negate( ) const { return mask(_test^4); } is_canonicalBoolTest317 bool is_canonical( ) const { return (_test == BoolTest::ne || _test == BoolTest::lt || _test == BoolTest::le || _test == BoolTest::overflow); } is_lessBoolTest318 bool is_less( ) const { return _test == BoolTest::lt || _test == BoolTest::le; } is_greaterBoolTest319 bool is_greater( ) const { return _test == BoolTest::gt || _test == BoolTest::ge; } 320 void dump_on(outputStream *st) const; 321 mask merge(BoolTest other) const; 322 }; 323 324 //------------------------------BoolNode--------------------------------------- 325 // A Node to convert a Condition Codes to a Logical result. 326 class BoolNode : public Node { 327 virtual uint hash() const; 328 virtual bool cmp( const Node &n ) const; 329 virtual uint size_of() const; 330 331 // Try to optimize signed integer comparison 332 Node* fold_cmpI(PhaseGVN* phase, SubNode* cmp, Node* cmp1, int cmp_op, 333 int cmp1_op, const TypeInt* cmp2_type); 334 public: 335 const BoolTest _test; BoolNode(Node * cc,BoolTest::mask t)336 BoolNode(Node *cc, BoolTest::mask t): Node(NULL,cc), _test(t) { 337 init_class_id(Class_Bool); 338 } 339 // Convert an arbitrary int value to a Bool or other suitable predicate. 340 static Node* make_predicate(Node* test_value, PhaseGVN* phase); 341 // Convert self back to an integer value. 342 Node* as_int_value(PhaseGVN* phase); 343 // Invert sense of self, returning new Bool. 344 BoolNode* negate(PhaseGVN* phase); 345 virtual int Opcode() const; 346 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 347 virtual const Type* Value(PhaseGVN* phase) const; bottom_type() const348 virtual const Type *bottom_type() const { return TypeInt::BOOL; } match_edge(uint idx) const349 uint match_edge(uint idx) const { return 0; } ideal_reg() const350 virtual uint ideal_reg() const { return Op_RegI; } 351 352 bool is_counted_loop_exit_test(); 353 #ifndef PRODUCT 354 virtual void dump_spec(outputStream *st) const; 355 virtual void related(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const; 356 #endif 357 }; 358 359 //------------------------------AbsNode---------------------------------------- 360 // Abstract class for absolute value. Mostly used to get a handy wrapper 361 // for finding this pattern in the graph. 362 class AbsNode : public Node { 363 public: AbsNode(Node * value)364 AbsNode( Node *value ) : Node(0,value) {} 365 }; 366 367 //------------------------------AbsINode--------------------------------------- 368 // Absolute value an integer. Since a naive graph involves control flow, we 369 // "match" it in the ideal world (so the control flow can be removed). 370 class AbsINode : public AbsNode { 371 public: AbsINode(Node * in1)372 AbsINode( Node *in1 ) : AbsNode(in1) {} 373 virtual int Opcode() const; bottom_type() const374 const Type *bottom_type() const { return TypeInt::INT; } ideal_reg() const375 virtual uint ideal_reg() const { return Op_RegI; } 376 }; 377 378 //------------------------------AbsLNode--------------------------------------- 379 // Absolute value a long. Since a naive graph involves control flow, we 380 // "match" it in the ideal world (so the control flow can be removed). 381 class AbsLNode : public AbsNode { 382 public: AbsLNode(Node * in1)383 AbsLNode( Node *in1 ) : AbsNode(in1) {} 384 virtual int Opcode() const; bottom_type() const385 const Type *bottom_type() const { return TypeLong::LONG; } ideal_reg() const386 virtual uint ideal_reg() const { return Op_RegL; } 387 }; 388 389 //------------------------------AbsFNode--------------------------------------- 390 // Absolute value a float, a common float-point idiom with a cheap hardware 391 // implemention on most chips. Since a naive graph involves control flow, we 392 // "match" it in the ideal world (so the control flow can be removed). 393 class AbsFNode : public AbsNode { 394 public: AbsFNode(Node * in1)395 AbsFNode( Node *in1 ) : AbsNode(in1) {} 396 virtual int Opcode() const; bottom_type() const397 const Type *bottom_type() const { return Type::FLOAT; } ideal_reg() const398 virtual uint ideal_reg() const { return Op_RegF; } 399 }; 400 401 //------------------------------AbsDNode--------------------------------------- 402 // Absolute value a double, a common float-point idiom with a cheap hardware 403 // implemention on most chips. Since a naive graph involves control flow, we 404 // "match" it in the ideal world (so the control flow can be removed). 405 class AbsDNode : public AbsNode { 406 public: AbsDNode(Node * in1)407 AbsDNode( Node *in1 ) : AbsNode(in1) {} 408 virtual int Opcode() const; bottom_type() const409 const Type *bottom_type() const { return Type::DOUBLE; } ideal_reg() const410 virtual uint ideal_reg() const { return Op_RegD; } 411 }; 412 413 414 //------------------------------CmpLTMaskNode---------------------------------- 415 // If p < q, return -1 else return 0. Nice for flow-free idioms. 416 class CmpLTMaskNode : public Node { 417 public: CmpLTMaskNode(Node * p,Node * q)418 CmpLTMaskNode( Node *p, Node *q ) : Node(0, p, q) {} 419 virtual int Opcode() const; bottom_type() const420 const Type *bottom_type() const { return TypeInt::INT; } ideal_reg() const421 virtual uint ideal_reg() const { return Op_RegI; } 422 }; 423 424 425 //------------------------------NegNode---------------------------------------- 426 class NegNode : public Node { 427 public: NegNode(Node * in1)428 NegNode( Node *in1 ) : Node(0,in1) {} 429 }; 430 431 //------------------------------NegINode--------------------------------------- 432 // Negate value an int. For int values, negation is the same as subtraction 433 // from zero 434 class NegINode : public NegNode { 435 public: NegINode(Node * in1)436 NegINode(Node *in1) : NegNode(in1) {} 437 virtual int Opcode() const; bottom_type() const438 const Type *bottom_type() const { return TypeInt::INT; } ideal_reg() const439 virtual uint ideal_reg() const { return Op_RegI; } 440 }; 441 442 //------------------------------NegLNode--------------------------------------- 443 // Negate value an int. For int values, negation is the same as subtraction 444 // from zero 445 class NegLNode : public NegNode { 446 public: NegLNode(Node * in1)447 NegLNode(Node *in1) : NegNode(in1) {} 448 virtual int Opcode() const; bottom_type() const449 const Type *bottom_type() const { return TypeLong::LONG; } ideal_reg() const450 virtual uint ideal_reg() const { return Op_RegL; } 451 }; 452 453 //------------------------------NegFNode--------------------------------------- 454 // Negate value a float. Negating 0.0 returns -0.0, but subtracting from 455 // zero returns +0.0 (per JVM spec on 'fneg' bytecode). As subtraction 456 // cannot be used to replace negation we have to implement negation as ideal 457 // node; note that negation and addition can replace subtraction. 458 class NegFNode : public NegNode { 459 public: NegFNode(Node * in1)460 NegFNode( Node *in1 ) : NegNode(in1) {} 461 virtual int Opcode() const; bottom_type() const462 const Type *bottom_type() const { return Type::FLOAT; } ideal_reg() const463 virtual uint ideal_reg() const { return Op_RegF; } 464 }; 465 466 //------------------------------NegDNode--------------------------------------- 467 // Negate value a double. Negating 0.0 returns -0.0, but subtracting from 468 // zero returns +0.0 (per JVM spec on 'dneg' bytecode). As subtraction 469 // cannot be used to replace negation we have to implement negation as ideal 470 // node; note that negation and addition can replace subtraction. 471 class NegDNode : public NegNode { 472 public: NegDNode(Node * in1)473 NegDNode( Node *in1 ) : NegNode(in1) {} 474 virtual int Opcode() const; bottom_type() const475 const Type *bottom_type() const { return Type::DOUBLE; } ideal_reg() const476 virtual uint ideal_reg() const { return Op_RegD; } 477 }; 478 479 //------------------------------AtanDNode-------------------------------------- 480 // arcus tangens of a double 481 class AtanDNode : public Node { 482 public: AtanDNode(Node * c,Node * in1,Node * in2)483 AtanDNode(Node *c, Node *in1, Node *in2 ) : Node(c, in1, in2) {} 484 virtual int Opcode() const; bottom_type() const485 const Type *bottom_type() const { return Type::DOUBLE; } ideal_reg() const486 virtual uint ideal_reg() const { return Op_RegD; } 487 }; 488 489 490 //------------------------------SqrtDNode-------------------------------------- 491 // square root a double 492 class SqrtDNode : public Node { 493 public: SqrtDNode(Compile * C,Node * c,Node * in1)494 SqrtDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) { 495 init_flags(Flag_is_expensive); 496 C->add_expensive_node(this); 497 } 498 virtual int Opcode() const; bottom_type() const499 const Type *bottom_type() const { return Type::DOUBLE; } ideal_reg() const500 virtual uint ideal_reg() const { return Op_RegD; } 501 virtual const Type* Value(PhaseGVN* phase) const; 502 }; 503 504 //------------------------------SqrtFNode-------------------------------------- 505 // square root a float 506 class SqrtFNode : public Node { 507 public: SqrtFNode(Compile * C,Node * c,Node * in1)508 SqrtFNode(Compile* C, Node *c, Node *in1) : Node(c, in1) { 509 init_flags(Flag_is_expensive); 510 if (c != NULL) { 511 // Treat node only as expensive if a control input is set because it might 512 // be created from a SqrtDNode in ConvD2FNode::Ideal() that was found to 513 // be unique and therefore has no control input. 514 C->add_expensive_node(this); 515 } 516 } 517 virtual int Opcode() const; bottom_type() const518 const Type *bottom_type() const { return Type::FLOAT; } ideal_reg() const519 virtual uint ideal_reg() const { return Op_RegF; } 520 virtual const Type* Value(PhaseGVN* phase) const; 521 }; 522 523 //-------------------------------ReverseBytesINode-------------------------------- 524 // reverse bytes of an integer 525 class ReverseBytesINode : public Node { 526 public: ReverseBytesINode(Node * c,Node * in1)527 ReverseBytesINode(Node *c, Node *in1) : Node(c, in1) {} 528 virtual int Opcode() const; bottom_type() const529 const Type *bottom_type() const { return TypeInt::INT; } ideal_reg() const530 virtual uint ideal_reg() const { return Op_RegI; } 531 }; 532 533 //-------------------------------ReverseBytesLNode-------------------------------- 534 // reverse bytes of a long 535 class ReverseBytesLNode : public Node { 536 public: ReverseBytesLNode(Node * c,Node * in1)537 ReverseBytesLNode(Node *c, Node *in1) : Node(c, in1) {} 538 virtual int Opcode() const; bottom_type() const539 const Type *bottom_type() const { return TypeLong::LONG; } ideal_reg() const540 virtual uint ideal_reg() const { return Op_RegL; } 541 }; 542 543 //-------------------------------ReverseBytesUSNode-------------------------------- 544 // reverse bytes of an unsigned short / char 545 class ReverseBytesUSNode : public Node { 546 public: ReverseBytesUSNode(Node * c,Node * in1)547 ReverseBytesUSNode(Node *c, Node *in1) : Node(c, in1) {} 548 virtual int Opcode() const; bottom_type() const549 const Type *bottom_type() const { return TypeInt::CHAR; } ideal_reg() const550 virtual uint ideal_reg() const { return Op_RegI; } 551 }; 552 553 //-------------------------------ReverseBytesSNode-------------------------------- 554 // reverse bytes of a short 555 class ReverseBytesSNode : public Node { 556 public: ReverseBytesSNode(Node * c,Node * in1)557 ReverseBytesSNode(Node *c, Node *in1) : Node(c, in1) {} 558 virtual int Opcode() const; bottom_type() const559 const Type *bottom_type() const { return TypeInt::SHORT; } ideal_reg() const560 virtual uint ideal_reg() const { return Op_RegI; } 561 }; 562 563 #endif // SHARE_OPTO_SUBNODE_HPP 564