1 /* 2 * Copyright (c) 1997, 2025, 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: 42 SubNode( Node *in1, Node *in2 ) : Node(nullptr,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(PhaseValues* 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: 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; 77 const Type *add_id() const { return TypeInt::ZERO; } 78 const Type *bottom_type() const { return TypeInt::INT; } 79 virtual uint ideal_reg() const { return Op_RegI; } 80 }; 81 82 //------------------------------SubLNode--------------------------------------- 83 // Subtract 2 integers 84 class SubLNode : public SubNode { 85 public: 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; 90 const Type *add_id() const { return TypeLong::ZERO; } 91 const Type *bottom_type() const { return TypeLong::LONG; } 92 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: 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: 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; 114 const Type *add_id() const { return TypeF::ZERO; } 115 const Type *bottom_type() const { return Type::FLOAT; } 116 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: 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; 128 const Type *add_id() const { return TypeD::ZERO; } 129 const Type *bottom_type() const { return Type::DOUBLE; } 130 virtual uint ideal_reg() const { return Op_RegD; } 131 }; 132 133 //------------------------------SubHFNode-------------------------------------- 134 // Subtract 2 half floats 135 class SubHFNode : public SubFPNode { 136 public: 137 SubHFNode(Node* in1, Node* in2) : SubFPNode(in1, in2) {} 138 virtual int Opcode() const; 139 virtual const Type* sub(const Type*, const Type*) const; 140 const Type* add_id() const { return TypeH::ZERO; } 141 const Type* bottom_type() const { return Type::HALF_FLOAT; } 142 virtual uint ideal_reg() const { return Op_RegF; } 143 }; 144 145 //------------------------------CmpNode--------------------------------------- 146 // Compare 2 values, returning condition codes (-1, 0 or 1). 147 class CmpNode : public SubNode { 148 public: 149 CmpNode( Node *in1, Node *in2 ) : SubNode(in1,in2) { 150 init_class_id(Class_Cmp); 151 } 152 virtual Node* Identity(PhaseGVN* phase); 153 const Type *add_id() const { return TypeInt::ZERO; } 154 const Type *bottom_type() const { return TypeInt::CC; } 155 virtual uint ideal_reg() const { return Op_RegFlags; } 156 157 static CmpNode *make(Node *in1, Node *in2, BasicType bt, bool unsigned_comp = false); 158 }; 159 160 //------------------------------CmpINode--------------------------------------- 161 // Compare 2 signed values, returning condition codes (-1, 0 or 1). 162 class CmpINode : public CmpNode { 163 public: 164 CmpINode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} 165 virtual int Opcode() const; 166 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 167 virtual const Type *sub( const Type *, const Type * ) const; 168 virtual const Type* Value(PhaseGVN* phase) const; 169 }; 170 171 //------------------------------CmpUNode--------------------------------------- 172 // Compare 2 unsigned values (integer or pointer), returning condition codes (-1, 0 or 1). 173 class CmpUNode : public CmpNode { 174 public: 175 CmpUNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} 176 virtual int Opcode() const; 177 virtual const Type *sub( const Type *, const Type * ) const; 178 const Type* Value(PhaseGVN* phase) const; 179 bool is_index_range_check() const; 180 }; 181 182 //------------------------------CmpU3Node-------------------------------------- 183 // Compare 2 unsigned values, returning integer value (-1, 0 or 1). 184 class CmpU3Node : public CmpUNode { 185 public: 186 CmpU3Node( Node *in1, Node *in2 ) : CmpUNode(in1,in2) { 187 // Since it is not consumed by Bools, it is not really a Cmp. 188 init_class_id(Class_Sub); 189 } 190 virtual int Opcode() const; 191 virtual uint ideal_reg() const { return Op_RegI; } 192 }; 193 194 //------------------------------CmpPNode--------------------------------------- 195 // Compare 2 pointer values, returning condition codes (-1, 0 or 1). 196 class CmpPNode : public CmpNode { 197 public: 198 CmpPNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} 199 virtual int Opcode() const; 200 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 201 virtual const Type *sub( const Type *, const Type * ) const; 202 }; 203 204 //------------------------------CmpNNode-------------------------------------- 205 // Compare 2 narrow oop values, returning condition codes (-1, 0 or 1). 206 class CmpNNode : public CmpNode { 207 public: 208 CmpNNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} 209 virtual int Opcode() const; 210 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 211 virtual const Type *sub( const Type *, const Type * ) const; 212 }; 213 214 //------------------------------CmpLNode--------------------------------------- 215 // Compare 2 long values, returning condition codes (-1, 0 or 1). 216 class CmpLNode : public CmpNode { 217 public: 218 CmpLNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} 219 virtual int Opcode() const; 220 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); 221 virtual const Type* Value(PhaseGVN* phase) const; 222 virtual const Type *sub( const Type *, const Type * ) const; 223 bool is_double_null_check(PhaseGVN* phase, Node*& a, Node*& b) const; 224 }; 225 226 //------------------------------CmpULNode--------------------------------------- 227 // Compare 2 unsigned long values, returning condition codes (-1, 0 or 1). 228 class CmpULNode : public CmpNode { 229 public: 230 CmpULNode(Node* in1, Node* in2) : CmpNode(in1, in2) { } 231 virtual int Opcode() const; 232 virtual const Type* sub(const Type*, const Type*) const; 233 }; 234 235 //------------------------------CmpL3Node-------------------------------------- 236 // Compare 2 long values, returning integer value (-1, 0 or 1). 237 class CmpL3Node : public CmpLNode { 238 public: 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; 244 virtual uint ideal_reg() const { return Op_RegI; } 245 }; 246 247 //------------------------------CmpUL3Node------------------------------------- 248 // Compare 2 unsigned long values, returning integer value (-1, 0 or 1). 249 class CmpUL3Node : public CmpULNode { 250 public: 251 CmpUL3Node( Node *in1, Node *in2 ) : CmpULNode(in1,in2) { 252 // Since it is not consumed by Bools, it is not really a Cmp. 253 init_class_id(Class_Sub); 254 } 255 virtual int Opcode() const; 256 virtual uint ideal_reg() const { return Op_RegI; } 257 }; 258 259 //------------------------------CmpFNode--------------------------------------- 260 // Compare 2 float values, returning condition codes (-1, 0 or 1). 261 // This implements the Java bytecode fcmpl, so unordered returns -1. 262 // Operands may not commute. 263 class CmpFNode : public CmpNode { 264 public: 265 CmpFNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} 266 virtual int Opcode() const; 267 virtual const Type *sub( const Type *, const Type * ) const { ShouldNotReachHere(); return nullptr; } 268 const Type* Value(PhaseGVN* phase) const; 269 }; 270 271 //------------------------------CmpF3Node-------------------------------------- 272 // Compare 2 float values, returning integer value (-1, 0 or 1). 273 // This implements the Java bytecode fcmpl, so unordered returns -1. 274 // Operands may not commute. 275 class CmpF3Node : public CmpFNode { 276 public: 277 CmpF3Node( Node *in1, Node *in2 ) : CmpFNode(in1,in2) { 278 // Since it is not consumed by Bools, it is not really a Cmp. 279 init_class_id(Class_Sub); 280 } 281 virtual int Opcode() const; 282 // Since it is not consumed by Bools, it is not really a Cmp. 283 virtual uint ideal_reg() const { return Op_RegI; } 284 }; 285 286 287 //------------------------------CmpDNode--------------------------------------- 288 // Compare 2 double values, returning condition codes (-1, 0 or 1). 289 // This implements the Java bytecode dcmpl, so unordered returns -1. 290 // Operands may not commute. 291 class CmpDNode : public CmpNode { 292 public: 293 CmpDNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {} 294 virtual int Opcode() const; 295 virtual const Type *sub( const Type *, const Type * ) const { ShouldNotReachHere(); return nullptr; } 296 const Type* Value(PhaseGVN* phase) const; 297 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 298 }; 299 300 //------------------------------CmpD3Node-------------------------------------- 301 // Compare 2 double values, returning integer value (-1, 0 or 1). 302 // This implements the Java bytecode dcmpl, so unordered returns -1. 303 // Operands may not commute. 304 class CmpD3Node : public CmpDNode { 305 public: 306 CmpD3Node( Node *in1, Node *in2 ) : CmpDNode(in1,in2) { 307 // Since it is not consumed by Bools, it is not really a Cmp. 308 init_class_id(Class_Sub); 309 } 310 virtual int Opcode() const; 311 virtual uint ideal_reg() const { return Op_RegI; } 312 }; 313 314 //--------------------------FlatArrayCheckNode--------------------------------- 315 // Returns true if one of the input array objects or array klass ptrs (there 316 // can be multiple) is flat. 317 class FlatArrayCheckNode : public CmpNode { 318 public: 319 enum { 320 Control, 321 Memory, 322 ArrayOrKlass 323 }; 324 FlatArrayCheckNode(Compile* C, Node* mem, Node* array_or_klass) : CmpNode(mem, array_or_klass) { 325 init_class_id(Class_FlatArrayCheck); 326 init_flags(Flag_is_macro); 327 C->add_macro_node(this); 328 } 329 virtual int Opcode() const; 330 virtual const Type* sub(const Type*, const Type*) const { ShouldNotReachHere(); return nullptr; } 331 const Type* Value(PhaseGVN* phase) const; 332 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); 333 }; 334 335 //------------------------------BoolTest--------------------------------------- 336 // Convert condition codes to a boolean test value (0 or -1). 337 // We pick the values as 3 bits; the low order 2 bits we compare against the 338 // condition codes, the high bit flips the sense of the result. 339 // For vector compares, additionally, the 4th bit indicates if the compare is unsigned 340 struct BoolTest { 341 enum mask { eq = 0, ne = 4, le = 5, ge = 7, lt = 3, gt = 1, overflow = 2, no_overflow = 6, never = 8, illegal = 9, 342 // The following values are used with vector compares 343 // A BoolTest value should not be constructed for such values 344 unsigned_compare = 16, 345 ule = unsigned_compare | le, uge = unsigned_compare | ge, ult = unsigned_compare | lt, ugt = unsigned_compare | gt }; 346 mask _test; 347 BoolTest( mask btm ) : _test(btm) { assert((btm & unsigned_compare) == 0, "unsupported");} 348 const Type *cc2logical( const Type *CC ) const; 349 // Commute the test. I use a small table lookup. The table is created as 350 // a simple char array where each element is the ASCII version of a 'mask' 351 // enum from above. 352 mask commute( ) const { return mask("032147658"[_test]-'0'); } 353 mask negate( ) const { return mask(_test^4); } 354 bool is_canonical( ) const { return (_test == BoolTest::ne || _test == BoolTest::lt || _test == BoolTest::le || _test == BoolTest::overflow); } 355 bool is_less( ) const { return _test == BoolTest::lt || _test == BoolTest::le; } 356 bool is_greater( ) const { return _test == BoolTest::gt || _test == BoolTest::ge; } 357 void dump_on(outputStream *st) const; 358 mask merge(BoolTest other) const; 359 }; 360 361 //------------------------------BoolNode--------------------------------------- 362 // A Node to convert a Condition Codes to a Logical result. 363 class BoolNode : public Node { 364 virtual uint hash() const; 365 virtual bool cmp( const Node &n ) const; 366 virtual uint size_of() const; 367 368 // Try to optimize signed integer comparison 369 Node* fold_cmpI(PhaseGVN* phase, SubNode* cmp, Node* cmp1, int cmp_op, 370 int cmp1_op, const TypeInt* cmp2_type); 371 public: 372 const BoolTest _test; 373 BoolNode(Node *cc, BoolTest::mask t): Node(nullptr,cc), _test(t) { 374 init_class_id(Class_Bool); 375 } 376 // Convert an arbitrary int value to a Bool or other suitable predicate. 377 static Node* make_predicate(Node* test_value, PhaseGVN* phase); 378 // Convert self back to an integer value. 379 Node* as_int_value(PhaseGVN* phase); 380 // Invert sense of self, returning new Bool. 381 BoolNode* negate(PhaseGVN* phase); 382 virtual int Opcode() const; 383 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 384 const Type* Value_cmpu_and_mask(PhaseValues* phase) const; 385 virtual const Type* Value(PhaseGVN* phase) const; 386 virtual const Type *bottom_type() const { return TypeInt::BOOL; } 387 uint match_edge(uint idx) const { return 0; } 388 virtual uint ideal_reg() const { return Op_RegI; } 389 390 bool is_counted_loop_exit_test(); 391 #ifndef PRODUCT 392 virtual void dump_spec(outputStream *st) const; 393 #endif 394 }; 395 396 //------------------------------AbsNode---------------------------------------- 397 // Abstract class for absolute value. Mostly used to get a handy wrapper 398 // for finding this pattern in the graph. 399 class AbsNode : public Node { 400 public: 401 AbsNode( Node *value ) : Node(nullptr,value) {} 402 virtual Node* Identity(PhaseGVN* phase); 403 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); 404 virtual const Type* Value(PhaseGVN* phase) const; 405 }; 406 407 //------------------------------AbsINode--------------------------------------- 408 // Absolute value an integer. Since a naive graph involves control flow, we 409 // "match" it in the ideal world (so the control flow can be removed). 410 class AbsINode : public AbsNode { 411 public: 412 AbsINode( Node *in1 ) : AbsNode(in1) {} 413 virtual int Opcode() const; 414 const Type *bottom_type() const { return TypeInt::INT; } 415 virtual uint ideal_reg() const { return Op_RegI; } 416 }; 417 418 //------------------------------AbsLNode--------------------------------------- 419 // Absolute value a long. Since a naive graph involves control flow, we 420 // "match" it in the ideal world (so the control flow can be removed). 421 class AbsLNode : public AbsNode { 422 public: 423 AbsLNode( Node *in1 ) : AbsNode(in1) {} 424 virtual int Opcode() const; 425 const Type *bottom_type() const { return TypeLong::LONG; } 426 virtual uint ideal_reg() const { return Op_RegL; } 427 }; 428 429 //------------------------------AbsFNode--------------------------------------- 430 // Absolute value a float, a common float-point idiom with a cheap hardware 431 // implementation on most chips. Since a naive graph involves control flow, we 432 // "match" it in the ideal world (so the control flow can be removed). 433 class AbsFNode : public AbsNode { 434 public: 435 AbsFNode( Node *in1 ) : AbsNode(in1) {} 436 virtual int Opcode() const; 437 const Type *bottom_type() const { return Type::FLOAT; } 438 virtual uint ideal_reg() const { return Op_RegF; } 439 }; 440 441 //------------------------------AbsDNode--------------------------------------- 442 // Absolute value a double, a common float-point idiom with a cheap hardware 443 // implementation on most chips. Since a naive graph involves control flow, we 444 // "match" it in the ideal world (so the control flow can be removed). 445 class AbsDNode : public AbsNode { 446 public: 447 AbsDNode( Node *in1 ) : AbsNode(in1) {} 448 virtual int Opcode() const; 449 const Type *bottom_type() const { return Type::DOUBLE; } 450 virtual uint ideal_reg() const { return Op_RegD; } 451 }; 452 453 454 //------------------------------CmpLTMaskNode---------------------------------- 455 // If p < q, return -1 else return 0. Nice for flow-free idioms. 456 class CmpLTMaskNode : public Node { 457 public: 458 CmpLTMaskNode( Node *p, Node *q ) : Node(nullptr, p, q) {} 459 virtual int Opcode() const; 460 const Type *bottom_type() const { return TypeInt::INT; } 461 virtual uint ideal_reg() const { return Op_RegI; } 462 }; 463 464 //------------------------------InvolutionNode---------------------------------- 465 // Represents a self-inverse operation, i.e., op(op(x)) = x for any x 466 class InvolutionNode : public Node { 467 public: 468 InvolutionNode(Node* in) : Node(nullptr, in) {} 469 virtual Node* Identity(PhaseGVN* phase); 470 }; 471 472 //------------------------------NegNode---------------------------------------- 473 class NegNode : public InvolutionNode { 474 public: 475 NegNode(Node* in1) : InvolutionNode(in1) { 476 init_class_id(Class_Neg); 477 } 478 }; 479 480 //------------------------------NegINode--------------------------------------- 481 // Negate value an int. For int values, negation is the same as subtraction 482 // from zero 483 class NegINode : public NegNode { 484 public: 485 NegINode(Node *in1) : NegNode(in1) {} 486 virtual int Opcode() const; 487 const Type *bottom_type() const { return TypeInt::INT; } 488 virtual uint ideal_reg() const { return Op_RegI; } 489 }; 490 491 //------------------------------NegLNode--------------------------------------- 492 // Negate value an int. For int values, negation is the same as subtraction 493 // from zero 494 class NegLNode : public NegNode { 495 public: 496 NegLNode(Node *in1) : NegNode(in1) {} 497 virtual int Opcode() const; 498 const Type *bottom_type() const { return TypeLong::LONG; } 499 virtual uint ideal_reg() const { return Op_RegL; } 500 }; 501 502 //------------------------------NegFNode--------------------------------------- 503 // Negate value a float. Negating 0.0 returns -0.0, but subtracting from 504 // zero returns +0.0 (per JVM spec on 'fneg' bytecode). As subtraction 505 // cannot be used to replace negation we have to implement negation as ideal 506 // node; note that negation and addition can replace subtraction. 507 class NegFNode : public NegNode { 508 public: 509 NegFNode( Node *in1 ) : NegNode(in1) {} 510 virtual int Opcode() const; 511 const Type *bottom_type() const { return Type::FLOAT; } 512 virtual uint ideal_reg() const { return Op_RegF; } 513 }; 514 515 //------------------------------NegDNode--------------------------------------- 516 // Negate value a double. Negating 0.0 returns -0.0, but subtracting from 517 // zero returns +0.0 (per JVM spec on 'dneg' bytecode). As subtraction 518 // cannot be used to replace negation we have to implement negation as ideal 519 // node; note that negation and addition can replace subtraction. 520 class NegDNode : public NegNode { 521 public: 522 NegDNode( Node *in1 ) : NegNode(in1) {} 523 virtual int Opcode() const; 524 const Type *bottom_type() const { return Type::DOUBLE; } 525 virtual uint ideal_reg() const { return Op_RegD; } 526 }; 527 528 //------------------------------AtanDNode-------------------------------------- 529 // arcus tangens of a double 530 class AtanDNode : public Node { 531 public: 532 AtanDNode(Node *c, Node *in1, Node *in2 ) : Node(c, in1, in2) {} 533 virtual int Opcode() const; 534 const Type *bottom_type() const { return Type::DOUBLE; } 535 virtual uint ideal_reg() const { return Op_RegD; } 536 }; 537 538 539 //------------------------------SqrtDNode-------------------------------------- 540 // square root a double 541 class SqrtDNode : public Node { 542 public: 543 SqrtDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) { 544 init_flags(Flag_is_expensive); 545 C->add_expensive_node(this); 546 } 547 virtual int Opcode() const; 548 const Type *bottom_type() const { return Type::DOUBLE; } 549 virtual uint ideal_reg() const { return Op_RegD; } 550 virtual const Type* Value(PhaseGVN* phase) const; 551 }; 552 553 //------------------------------SqrtFNode-------------------------------------- 554 // square root a float 555 class SqrtFNode : public Node { 556 public: 557 SqrtFNode(Compile* C, Node *c, Node *in1) : Node(c, in1) { 558 init_flags(Flag_is_expensive); 559 if (c != nullptr) { 560 // Treat node only as expensive if a control input is set because it might 561 // be created from a SqrtDNode in ConvD2FNode::Ideal() that was found to 562 // be unique and therefore has no control input. 563 C->add_expensive_node(this); 564 } 565 } 566 virtual int Opcode() const; 567 const Type *bottom_type() const { return Type::FLOAT; } 568 virtual uint ideal_reg() const { return Op_RegF; } 569 virtual const Type* Value(PhaseGVN* phase) const; 570 }; 571 572 //------------------------------SqrtHFNode------------------------------------- 573 // square root of a half-precision float 574 class SqrtHFNode : public Node { 575 public: 576 SqrtHFNode(Compile* C, Node* c, Node* in1) : Node(c, in1) { 577 init_flags(Flag_is_expensive); 578 C->add_expensive_node(this); 579 } 580 virtual int Opcode() const; 581 const Type* bottom_type() const { return Type::HALF_FLOAT; } 582 virtual uint ideal_reg() const { return Op_RegF; } 583 virtual const Type* Value(PhaseGVN* phase) const; 584 }; 585 586 //-------------------------------ReverseBytesINode-------------------------------- 587 // reverse bytes of an integer 588 class ReverseBytesINode : public InvolutionNode { 589 public: 590 ReverseBytesINode(Node* in) : InvolutionNode(in) {} 591 virtual int Opcode() const; 592 const Type* bottom_type() const { return TypeInt::INT; } 593 virtual uint ideal_reg() const { return Op_RegI; } 594 }; 595 596 //-------------------------------ReverseBytesLNode-------------------------------- 597 // reverse bytes of a long 598 class ReverseBytesLNode : public InvolutionNode { 599 public: 600 ReverseBytesLNode(Node* in) : InvolutionNode(in) {} 601 virtual int Opcode() const; 602 const Type* bottom_type() const { return TypeLong::LONG; } 603 virtual uint ideal_reg() const { return Op_RegL; } 604 }; 605 606 //-------------------------------ReverseBytesUSNode-------------------------------- 607 // reverse bytes of an unsigned short / char 608 class ReverseBytesUSNode : public InvolutionNode { 609 public: 610 ReverseBytesUSNode(Node* in1) : InvolutionNode(in1) {} 611 virtual int Opcode() const; 612 const Type* bottom_type() const { return TypeInt::CHAR; } 613 virtual uint ideal_reg() const { return Op_RegI; } 614 }; 615 616 //-------------------------------ReverseBytesSNode-------------------------------- 617 // reverse bytes of a short 618 class ReverseBytesSNode : public InvolutionNode { 619 public: 620 ReverseBytesSNode(Node* in) : InvolutionNode(in) {} 621 virtual int Opcode() const; 622 const Type* bottom_type() const { return TypeInt::SHORT; } 623 virtual uint ideal_reg() const { return Op_RegI; } 624 }; 625 626 //-------------------------------ReverseINode-------------------------------- 627 // reverse bits of an int 628 class ReverseINode : public InvolutionNode { 629 public: 630 ReverseINode(Node* in) : InvolutionNode(in) {} 631 virtual int Opcode() const; 632 const Type* bottom_type() const { return TypeInt::INT; } 633 virtual uint ideal_reg() const { return Op_RegI; } 634 virtual const Type* Value(PhaseGVN* phase) const; 635 }; 636 637 //-------------------------------ReverseLNode-------------------------------- 638 // reverse bits of a long 639 class ReverseLNode : public InvolutionNode { 640 public: 641 ReverseLNode(Node* in) : InvolutionNode(in) {} 642 virtual int Opcode() const; 643 const Type* bottom_type() const { return TypeLong::LONG; } 644 virtual uint ideal_reg() const { return Op_RegL; } 645 virtual const Type* Value(PhaseGVN* phase) const; 646 }; 647 648 #endif // SHARE_OPTO_SUBNODE_HPP