1 /* 2 * Copyright (c) 2007, 2022, 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 #ifndef SHARE_OPTO_VECTORNODE_HPP 25 #define SHARE_OPTO_VECTORNODE_HPP 26 27 #include "opto/callnode.hpp" 28 #include "opto/matcher.hpp" 29 #include "opto/memnode.hpp" 30 #include "opto/node.hpp" 31 #include "opto/opcodes.hpp" 32 #include "prims/vectorSupport.hpp" 33 34 //------------------------------VectorNode------------------------------------- 35 // Vector Operation 36 class VectorNode : public TypeNode { 37 public: 38 39 VectorNode(Node* n1, const TypeVect* vt) : TypeNode(vt, 2) { 40 init_class_id(Class_Vector); 41 init_req(1, n1); 42 } 43 VectorNode(Node* n1, Node* n2, const TypeVect* vt) : TypeNode(vt, 3) { 44 init_class_id(Class_Vector); 45 init_req(1, n1); 46 init_req(2, n2); 47 } 48 49 VectorNode(Node* n1, Node* n2, Node* n3, const TypeVect* vt) : TypeNode(vt, 4) { 50 init_class_id(Class_Vector); 51 init_req(1, n1); 52 init_req(2, n2); 53 init_req(3, n3); 54 } 55 56 VectorNode(Node *n0, Node* n1, Node* n2, Node* n3, const TypeVect* vt) : TypeNode(vt, 5) { 57 init_class_id(Class_Vector); 58 init_req(1, n0); 59 init_req(2, n1); 60 init_req(3, n2); 61 init_req(4, n3); 62 } 63 64 const TypeVect* vect_type() const { return type()->is_vect(); } 65 uint length() const { return vect_type()->length(); } // Vector length 66 uint length_in_bytes() const { return vect_type()->length_in_bytes(); } 67 68 virtual int Opcode() const; 69 70 virtual uint ideal_reg() const { 71 return type()->ideal_reg(); 72 } 73 74 static VectorNode* scalar2vector(Node* s, uint vlen, const Type* opd_t, bool is_mask = false); 75 static VectorNode* shift_count(int opc, Node* cnt, uint vlen, BasicType bt); 76 static VectorNode* make(int opc, Node* n1, Node* n2, uint vlen, BasicType bt, bool is_var_shift = false); 77 static VectorNode* make(int vopc, Node* n1, Node* n2, const TypeVect* vt, bool is_mask = false, bool is_var_shift = false); 78 static VectorNode* make(int opc, Node* n1, Node* n2, Node* n3, uint vlen, BasicType bt); 79 static VectorNode* make(int vopc, Node* n1, Node* n2, Node* n3, const TypeVect* vt); 80 static VectorNode* make_mask_node(int vopc, Node* n1, Node* n2, uint vlen, BasicType bt); 81 82 static bool is_shift_opcode(int opc); 83 84 static bool is_vshift_cnt_opcode(int opc); 85 86 static bool is_rotate_opcode(int opc); 87 88 static int opcode(int opc, BasicType bt); 89 static int replicate_opcode(BasicType bt); 90 static bool implemented(int opc, uint vlen, BasicType bt); 91 static bool is_shift(Node* n); 92 static bool is_vshift_cnt(Node* n); 93 static bool is_type_transition_short_to_int(Node* n); 94 static bool is_type_transition_to_int(Node* n); 95 static bool is_muladds2i(Node* n); 96 static bool is_vpopcnt_long(Node* n); 97 static bool is_roundopD(Node* n); 98 static bool is_scalar_rotate(Node* n); 99 static bool is_vector_rotate_supported(int opc, uint vlen, BasicType bt); 100 static bool is_vector_integral_negate_supported(int opc, uint vlen, BasicType bt, bool use_predicate); 101 static bool is_invariant_vector(Node* n); 102 static bool is_all_ones_vector(Node* n); 103 static bool is_vector_bitwise_not_pattern(Node* n); 104 static Node* degenerate_vector_rotate(Node* n1, Node* n2, bool is_rotate_left, int vlen, 105 BasicType bt, PhaseGVN* phase); 106 107 // [Start, end) half-open range defining which operands are vectors 108 static void vector_operands(Node* n, uint* start, uint* end); 109 110 static bool is_vector_shift(int opc); 111 static bool is_vector_shift_count(int opc); 112 static bool is_vector_rotate(int opc); 113 static bool is_vector_integral_negate(int opc); 114 115 static bool is_vector_shift(Node* n) { 116 return is_vector_shift(n->Opcode()); 117 } 118 static bool is_vector_shift_count(Node* n) { 119 return is_vector_shift_count(n->Opcode()); 120 } 121 }; 122 123 //===========================Vector=ALU=Operations============================= 124 125 //------------------------------AddVBNode-------------------------------------- 126 // Vector add byte 127 class AddVBNode : public VectorNode { 128 public: 129 AddVBNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 130 virtual int Opcode() const; 131 }; 132 133 //------------------------------AddVSNode-------------------------------------- 134 // Vector add char/short 135 class AddVSNode : public VectorNode { 136 public: 137 AddVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 138 virtual int Opcode() const; 139 }; 140 141 //------------------------------AddVINode-------------------------------------- 142 // Vector add int 143 class AddVINode : public VectorNode { 144 public: 145 AddVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 146 virtual int Opcode() const; 147 }; 148 149 //------------------------------AddVLNode-------------------------------------- 150 // Vector add long 151 class AddVLNode : public VectorNode { 152 public: 153 AddVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 154 virtual int Opcode() const; 155 }; 156 157 //------------------------------AddVFNode-------------------------------------- 158 // Vector add float 159 class AddVFNode : public VectorNode { 160 public: 161 AddVFNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 162 virtual int Opcode() const; 163 }; 164 165 //------------------------------AddVDNode-------------------------------------- 166 // Vector add double 167 class AddVDNode : public VectorNode { 168 public: 169 AddVDNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 170 virtual int Opcode() const; 171 }; 172 173 //------------------------------ReductionNode------------------------------------ 174 // Perform reduction of a vector 175 class ReductionNode : public Node { 176 private: 177 const Type* _bottom_type; 178 public: 179 ReductionNode(Node *ctrl, Node* in1, Node* in2) : Node(ctrl, in1, in2), 180 _bottom_type(Type::get_const_basic_type(in1->bottom_type()->basic_type())) {} 181 182 static ReductionNode* make(int opc, Node *ctrl, Node* in1, Node* in2, BasicType bt); 183 static int opcode(int opc, BasicType bt); 184 static bool implemented(int opc, uint vlen, BasicType bt); 185 static Node* make_reduction_input(PhaseGVN& gvn, int opc, BasicType bt); 186 187 virtual const Type* bottom_type() const { 188 return _bottom_type; 189 } 190 191 virtual uint ideal_reg() const { 192 return bottom_type()->ideal_reg(); 193 } 194 195 // Needed for proper cloning. 196 virtual uint size_of() const { return sizeof(*this); } 197 }; 198 199 //------------------------------AddReductionVINode-------------------------------------- 200 // Vector add byte, short and int as a reduction 201 class AddReductionVINode : public ReductionNode { 202 public: 203 AddReductionVINode(Node * ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 204 virtual int Opcode() const; 205 }; 206 207 //------------------------------AddReductionVLNode-------------------------------------- 208 // Vector add long as a reduction 209 class AddReductionVLNode : public ReductionNode { 210 public: 211 AddReductionVLNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 212 virtual int Opcode() const; 213 }; 214 215 //------------------------------AddReductionVFNode-------------------------------------- 216 // Vector add float as a reduction 217 class AddReductionVFNode : public ReductionNode { 218 public: 219 AddReductionVFNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 220 virtual int Opcode() const; 221 }; 222 223 //------------------------------AddReductionVDNode-------------------------------------- 224 // Vector add double as a reduction 225 class AddReductionVDNode : public ReductionNode { 226 public: 227 AddReductionVDNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 228 virtual int Opcode() const; 229 }; 230 231 //------------------------------SubVBNode-------------------------------------- 232 // Vector subtract byte 233 class SubVBNode : public VectorNode { 234 public: 235 SubVBNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 236 virtual int Opcode() const; 237 }; 238 239 //------------------------------SubVSNode-------------------------------------- 240 // Vector subtract short 241 class SubVSNode : public VectorNode { 242 public: 243 SubVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 244 virtual int Opcode() const; 245 }; 246 247 //------------------------------SubVINode-------------------------------------- 248 // Vector subtract int 249 class SubVINode : public VectorNode { 250 public: 251 SubVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 252 virtual int Opcode() const; 253 }; 254 255 //------------------------------SubVLNode-------------------------------------- 256 // Vector subtract long 257 class SubVLNode : public VectorNode { 258 public: 259 SubVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 260 virtual int Opcode() const; 261 }; 262 263 //------------------------------SubVFNode-------------------------------------- 264 // Vector subtract float 265 class SubVFNode : public VectorNode { 266 public: 267 SubVFNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 268 virtual int Opcode() const; 269 }; 270 271 //------------------------------SubVDNode-------------------------------------- 272 // Vector subtract double 273 class SubVDNode : public VectorNode { 274 public: 275 SubVDNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 276 virtual int Opcode() const; 277 }; 278 279 //------------------------------MulVBNode-------------------------------------- 280 // Vector multiply byte 281 class MulVBNode : public VectorNode { 282 public: 283 MulVBNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 284 virtual int Opcode() const; 285 }; 286 287 //------------------------------MulVSNode-------------------------------------- 288 // Vector multiply short 289 class MulVSNode : public VectorNode { 290 public: 291 MulVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 292 virtual int Opcode() const; 293 }; 294 295 //------------------------------MulVINode-------------------------------------- 296 // Vector multiply int 297 class MulVINode : public VectorNode { 298 public: 299 MulVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 300 virtual int Opcode() const; 301 }; 302 303 //------------------------------MulVLNode-------------------------------------- 304 // Vector multiply long 305 class MulVLNode : public VectorNode { 306 public: 307 MulVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 308 virtual int Opcode() const; 309 }; 310 311 //------------------------------MulVFNode-------------------------------------- 312 // Vector multiply float 313 class MulVFNode : public VectorNode { 314 public: 315 MulVFNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 316 virtual int Opcode() const; 317 }; 318 319 //------------------------------MulVDNode-------------------------------------- 320 // Vector multiply double 321 class MulVDNode : public VectorNode { 322 public: 323 MulVDNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 324 virtual int Opcode() const; 325 }; 326 327 //------------------------------MulAddVS2VINode-------------------------------- 328 // Vector multiply shorts to int and add adjacent ints. 329 class MulAddVS2VINode : public VectorNode { 330 public: 331 MulAddVS2VINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 332 virtual int Opcode() const; 333 }; 334 335 //------------------------------FmaVDNode-------------------------------------- 336 // Vector multiply double 337 class FmaVDNode : public VectorNode { 338 public: 339 FmaVDNode(Node* in1, Node* in2, Node* in3, const TypeVect* vt) : VectorNode(in1, in2, in3, vt) {} 340 virtual int Opcode() const; 341 }; 342 343 //------------------------------FmaVFNode-------------------------------------- 344 // Vector multiply float 345 class FmaVFNode : public VectorNode { 346 public: 347 FmaVFNode(Node* in1, Node* in2, Node* in3, const TypeVect* vt) : VectorNode(in1, in2, in3, vt) {} 348 virtual int Opcode() const; 349 }; 350 351 //------------------------------CMoveVFNode-------------------------------------- 352 // Vector float conditional move 353 class CMoveVFNode : public VectorNode { 354 public: 355 CMoveVFNode(Node* in1, Node* in2, Node* in3, const TypeVect* vt) : VectorNode(in1, in2, in3, vt) {} 356 virtual int Opcode() const; 357 }; 358 359 //------------------------------CMoveVDNode-------------------------------------- 360 // Vector double conditional move 361 class CMoveVDNode : public VectorNode { 362 public: 363 CMoveVDNode(Node* in1, Node* in2, Node* in3, const TypeVect* vt) : VectorNode(in1, in2, in3, vt) {} 364 virtual int Opcode() const; 365 }; 366 367 //------------------------------MulReductionVINode-------------------------------------- 368 // Vector multiply byte, short and int as a reduction 369 class MulReductionVINode : public ReductionNode { 370 public: 371 MulReductionVINode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 372 virtual int Opcode() const; 373 }; 374 375 //------------------------------MulReductionVLNode-------------------------------------- 376 // Vector multiply int as a reduction 377 class MulReductionVLNode : public ReductionNode { 378 public: 379 MulReductionVLNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 380 virtual int Opcode() const; 381 }; 382 383 //------------------------------MulReductionVFNode-------------------------------------- 384 // Vector multiply float as a reduction 385 class MulReductionVFNode : public ReductionNode { 386 public: 387 MulReductionVFNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 388 virtual int Opcode() const; 389 }; 390 391 //------------------------------MulReductionVDNode-------------------------------------- 392 // Vector multiply double as a reduction 393 class MulReductionVDNode : public ReductionNode { 394 public: 395 MulReductionVDNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 396 virtual int Opcode() const; 397 }; 398 399 //------------------------------DivVFNode-------------------------------------- 400 // Vector divide float 401 class DivVFNode : public VectorNode { 402 public: 403 DivVFNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 404 virtual int Opcode() const; 405 }; 406 407 //------------------------------DivVDNode-------------------------------------- 408 // Vector Divide double 409 class DivVDNode : public VectorNode { 410 public: 411 DivVDNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 412 virtual int Opcode() const; 413 }; 414 415 //------------------------------AbsVBNode-------------------------------------- 416 // Vector Abs byte 417 class AbsVBNode : public VectorNode { 418 public: 419 AbsVBNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) {} 420 virtual int Opcode() const; 421 }; 422 423 //------------------------------AbsVSNode-------------------------------------- 424 // Vector Abs short 425 class AbsVSNode : public VectorNode { 426 public: 427 AbsVSNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) {} 428 virtual int Opcode() const; 429 }; 430 431 //------------------------------MinVNode-------------------------------------- 432 // Vector Min 433 class MinVNode : public VectorNode { 434 public: 435 MinVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 436 virtual int Opcode() const; 437 }; 438 439 //------------------------------MaxVNode-------------------------------------- 440 // Vector Max 441 class MaxVNode : public VectorNode { 442 public: 443 MaxVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 444 virtual int Opcode() const; 445 }; 446 447 //------------------------------AbsVINode-------------------------------------- 448 // Vector Abs int 449 class AbsVINode : public VectorNode { 450 public: 451 AbsVINode(Node* in, const TypeVect* vt) : VectorNode(in, vt) {} 452 virtual int Opcode() const; 453 }; 454 455 //------------------------------AbsVLNode-------------------------------------- 456 // Vector Abs long 457 class AbsVLNode : public VectorNode { 458 public: 459 AbsVLNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) {} 460 virtual int Opcode() const; 461 }; 462 463 //------------------------------AbsVFNode-------------------------------------- 464 // Vector Abs float 465 class AbsVFNode : public VectorNode { 466 public: 467 AbsVFNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {} 468 virtual int Opcode() const; 469 }; 470 471 //------------------------------AbsVDNode-------------------------------------- 472 // Vector Abs double 473 class AbsVDNode : public VectorNode { 474 public: 475 AbsVDNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {} 476 virtual int Opcode() const; 477 }; 478 479 //------------------------------NegVNode--------------------------------------- 480 // Vector Neg parent class (not for code generation). 481 class NegVNode : public VectorNode { 482 public: 483 NegVNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) {} 484 virtual int Opcode() const = 0; 485 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); 486 487 private: 488 Node* degenerate_integral_negate(PhaseGVN* phase, bool is_predicated); 489 }; 490 491 //------------------------------NegVINode-------------------------------------- 492 // Vector Neg byte/short/int 493 class NegVINode : public NegVNode { 494 public: 495 NegVINode(Node* in, const TypeVect* vt) : NegVNode(in, vt) {} 496 virtual int Opcode() const; 497 }; 498 499 //------------------------------NegVLNode-------------------------------------- 500 // Vector Neg long 501 class NegVLNode : public NegVNode { 502 public: 503 NegVLNode(Node* in, const TypeVect* vt) : NegVNode(in, vt) {} 504 virtual int Opcode() const; 505 }; 506 507 //------------------------------NegVFNode-------------------------------------- 508 // Vector Neg float 509 class NegVFNode : public NegVNode { 510 public: 511 NegVFNode(Node* in, const TypeVect* vt) : NegVNode(in, vt) {} 512 virtual int Opcode() const; 513 }; 514 515 //------------------------------NegVDNode-------------------------------------- 516 // Vector Neg double 517 class NegVDNode : public NegVNode { 518 public: 519 NegVDNode(Node* in, const TypeVect* vt) : NegVNode(in, vt) {} 520 virtual int Opcode() const; 521 }; 522 523 //------------------------------PopCountVINode--------------------------------- 524 // Vector popcount integer bits 525 class PopCountVINode : public VectorNode { 526 public: 527 PopCountVINode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {} 528 virtual int Opcode() const; 529 }; 530 531 //------------------------------PopCountVLNode--------------------------------- 532 // Vector popcount long bits 533 class PopCountVLNode : public VectorNode { 534 public: 535 PopCountVLNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {} 536 virtual int Opcode() const; 537 }; 538 539 //------------------------------SqrtVFNode-------------------------------------- 540 // Vector Sqrt float 541 class SqrtVFNode : public VectorNode { 542 public: 543 SqrtVFNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {} 544 virtual int Opcode() const; 545 }; 546 //------------------------------RoundDoubleVNode-------------------------------- 547 // Vector round double 548 class RoundDoubleModeVNode : public VectorNode { 549 public: 550 RoundDoubleModeVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 551 virtual int Opcode() const; 552 }; 553 554 //------------------------------SqrtVDNode-------------------------------------- 555 // Vector Sqrt double 556 class SqrtVDNode : public VectorNode { 557 public: 558 SqrtVDNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {} 559 virtual int Opcode() const; 560 }; 561 562 //------------------------------ShiftVNode----------------------------------- 563 // Class ShiftV functionality. This covers the common behaviors for all kinds 564 // of vector shifts. 565 class ShiftVNode : public VectorNode { 566 private: 567 bool _is_var_shift; 568 public: 569 ShiftVNode(Node* in1, Node* in2, const TypeVect* vt, bool is_var_shift) : 570 VectorNode(in1,in2,vt), _is_var_shift(is_var_shift) { 571 init_class_id(Class_ShiftV); 572 } 573 virtual Node* Identity(PhaseGVN* phase); 574 virtual int Opcode() const = 0; 575 virtual uint hash() const { return VectorNode::hash() + _is_var_shift; } 576 virtual bool cmp(const Node& n) const { 577 return VectorNode::cmp(n) && _is_var_shift == ((ShiftVNode&)n)._is_var_shift; 578 } 579 bool is_var_shift() { return _is_var_shift;} 580 virtual uint size_of() const { return sizeof(ShiftVNode); } 581 }; 582 583 //------------------------------LShiftVBNode----------------------------------- 584 // Vector left shift bytes 585 class LShiftVBNode : public ShiftVNode { 586 public: 587 LShiftVBNode(Node* in1, Node* in2, const TypeVect* vt, bool is_var_shift=false) : 588 ShiftVNode(in1,in2,vt,is_var_shift) {} 589 virtual int Opcode() const; 590 }; 591 592 //------------------------------LShiftVSNode----------------------------------- 593 // Vector left shift shorts 594 class LShiftVSNode : public ShiftVNode { 595 public: 596 LShiftVSNode(Node* in1, Node* in2, const TypeVect* vt, bool is_var_shift=false) : 597 ShiftVNode(in1,in2,vt,is_var_shift) {} 598 virtual int Opcode() const; 599 }; 600 601 //------------------------------LShiftVINode----------------------------------- 602 // Vector left shift ints 603 class LShiftVINode : public ShiftVNode { 604 public: 605 LShiftVINode(Node* in1, Node* in2, const TypeVect* vt, bool is_var_shift=false) : 606 ShiftVNode(in1,in2,vt,is_var_shift) {} 607 virtual int Opcode() const; 608 }; 609 610 //------------------------------LShiftVLNode----------------------------------- 611 // Vector left shift longs 612 class LShiftVLNode : public ShiftVNode { 613 public: 614 LShiftVLNode(Node* in1, Node* in2, const TypeVect* vt, bool is_var_shift=false) : 615 ShiftVNode(in1,in2,vt,is_var_shift) {} 616 virtual int Opcode() const; 617 }; 618 619 //------------------------------RShiftVBNode----------------------------------- 620 // Vector right arithmetic (signed) shift bytes 621 class RShiftVBNode : public ShiftVNode { 622 public: 623 RShiftVBNode(Node* in1, Node* in2, const TypeVect* vt, bool is_var_shift=false) : 624 ShiftVNode(in1,in2,vt,is_var_shift) {} 625 virtual int Opcode() const; 626 }; 627 628 //------------------------------RShiftVSNode----------------------------------- 629 // Vector right arithmetic (signed) shift shorts 630 class RShiftVSNode : public ShiftVNode { 631 public: 632 RShiftVSNode(Node* in1, Node* in2, const TypeVect* vt, bool is_var_shift=false) : 633 ShiftVNode(in1,in2,vt,is_var_shift) {} 634 virtual int Opcode() const; 635 }; 636 637 //------------------------------RShiftVINode----------------------------------- 638 // Vector right arithmetic (signed) shift ints 639 class RShiftVINode : public ShiftVNode { 640 public: 641 RShiftVINode(Node* in1, Node* in2, const TypeVect* vt, bool is_var_shift=false) : 642 ShiftVNode(in1,in2,vt,is_var_shift) {} 643 virtual int Opcode() const; 644 }; 645 646 //------------------------------RShiftVLNode----------------------------------- 647 // Vector right arithmetic (signed) shift longs 648 class RShiftVLNode : public ShiftVNode { 649 public: 650 RShiftVLNode(Node* in1, Node* in2, const TypeVect* vt, bool is_var_shift=false) : 651 ShiftVNode(in1,in2,vt,is_var_shift) {} 652 virtual int Opcode() const; 653 }; 654 655 //------------------------------URShiftVBNode---------------------------------- 656 // Vector right logical (unsigned) shift bytes 657 class URShiftVBNode : public ShiftVNode { 658 public: 659 URShiftVBNode(Node* in1, Node* in2, const TypeVect* vt, bool is_var_shift=false) : 660 ShiftVNode(in1,in2,vt,is_var_shift) {} 661 virtual int Opcode() const; 662 }; 663 664 //------------------------------URShiftVSNode---------------------------------- 665 // Vector right logical (unsigned) shift shorts 666 class URShiftVSNode : public ShiftVNode { 667 public: 668 URShiftVSNode(Node* in1, Node* in2, const TypeVect* vt, bool is_var_shift=false) : 669 ShiftVNode(in1,in2,vt,is_var_shift) {} 670 virtual int Opcode() const; 671 }; 672 673 //------------------------------URShiftVINode---------------------------------- 674 // Vector right logical (unsigned) shift ints 675 class URShiftVINode : public ShiftVNode { 676 public: 677 URShiftVINode(Node* in1, Node* in2, const TypeVect* vt, bool is_var_shift=false) : 678 ShiftVNode(in1,in2,vt,is_var_shift) {} 679 virtual int Opcode() const; 680 }; 681 682 //------------------------------URShiftVLNode---------------------------------- 683 // Vector right logical (unsigned) shift longs 684 class URShiftVLNode : public ShiftVNode { 685 public: 686 URShiftVLNode(Node* in1, Node* in2, const TypeVect* vt, bool is_var_shift=false) : 687 ShiftVNode(in1,in2,vt,is_var_shift) {} 688 virtual int Opcode() const; 689 }; 690 691 //------------------------------LShiftCntVNode--------------------------------- 692 // Vector left shift count 693 class LShiftCntVNode : public VectorNode { 694 public: 695 LShiftCntVNode(Node* cnt, const TypeVect* vt) : VectorNode(cnt,vt) {} 696 virtual int Opcode() const; 697 }; 698 699 //------------------------------RShiftCntVNode--------------------------------- 700 // Vector right shift count 701 class RShiftCntVNode : public VectorNode { 702 public: 703 RShiftCntVNode(Node* cnt, const TypeVect* vt) : VectorNode(cnt,vt) {} 704 virtual int Opcode() const; 705 }; 706 707 //------------------------------AndVNode--------------------------------------- 708 // Vector and integer 709 class AndVNode : public VectorNode { 710 public: 711 AndVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 712 virtual int Opcode() const; 713 }; 714 715 //------------------------------AndReductionVNode-------------------------------------- 716 // Vector and byte, short, int, long as a reduction 717 class AndReductionVNode : public ReductionNode { 718 public: 719 AndReductionVNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 720 virtual int Opcode() const; 721 }; 722 723 //------------------------------OrVNode--------------------------------------- 724 // Vector or byte, short, int, long as a reduction 725 class OrVNode : public VectorNode { 726 public: 727 OrVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 728 virtual int Opcode() const; 729 }; 730 731 //------------------------------OrReductionVNode-------------------------------------- 732 // Vector xor byte, short, int, long as a reduction 733 class OrReductionVNode : public ReductionNode { 734 public: 735 OrReductionVNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 736 virtual int Opcode() const; 737 }; 738 739 //------------------------------XorReductionVNode-------------------------------------- 740 // Vector and int, long as a reduction 741 class XorReductionVNode : public ReductionNode { 742 public: 743 XorReductionVNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 744 virtual int Opcode() const; 745 }; 746 747 //------------------------------XorVNode--------------------------------------- 748 // Vector xor integer 749 class XorVNode : public VectorNode { 750 public: 751 XorVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 752 virtual int Opcode() const; 753 }; 754 755 //------------------------------MinReductionVNode-------------------------------------- 756 // Vector min byte, short, int, long, float, double as a reduction 757 class MinReductionVNode : public ReductionNode { 758 public: 759 MinReductionVNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 760 virtual int Opcode() const; 761 }; 762 763 //------------------------------MaxReductionVNode-------------------------------------- 764 // Vector min byte, short, int, long, float, double as a reduction 765 class MaxReductionVNode : public ReductionNode { 766 public: 767 MaxReductionVNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 768 virtual int Opcode() const; 769 }; 770 771 //================================= M E M O R Y =============================== 772 773 //------------------------------LoadVectorNode--------------------------------- 774 // Load Vector from memory 775 class LoadVectorNode : public LoadNode { 776 public: 777 LoadVectorNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeVect* vt, ControlDependency control_dependency = LoadNode::DependsOnlyOnTest) 778 : LoadNode(c, mem, adr, at, vt, MemNode::unordered, control_dependency) { 779 init_class_id(Class_LoadVector); 780 set_mismatched_access(); 781 } 782 783 const TypeVect* vect_type() const { return type()->is_vect(); } 784 uint length() const { return vect_type()->length(); } // Vector length 785 786 virtual int Opcode() const; 787 788 virtual uint ideal_reg() const { return Matcher::vector_ideal_reg(memory_size()); } 789 virtual BasicType memory_type() const { return T_VOID; } 790 virtual int memory_size() const { return vect_type()->length_in_bytes(); } 791 792 virtual int store_Opcode() const { return Op_StoreVector; } 793 794 static LoadVectorNode* make(int opc, Node* ctl, Node* mem, 795 Node* adr, const TypePtr* atyp, 796 uint vlen, BasicType bt, 797 ControlDependency control_dependency = LoadNode::DependsOnlyOnTest); 798 uint element_size(void) { return type2aelembytes(vect_type()->element_basic_type()); } 799 }; 800 801 //------------------------------LoadVectorGatherNode------------------------------ 802 // Load Vector from memory via index map 803 class LoadVectorGatherNode : public LoadVectorNode { 804 public: 805 LoadVectorGatherNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeVect* vt, Node* indices) 806 : LoadVectorNode(c, mem, adr, at, vt) { 807 init_class_id(Class_LoadVectorGather); 808 assert(indices->bottom_type()->is_vect(), "indices must be in vector"); 809 add_req(indices); 810 assert(req() == MemNode::ValueIn + 1, "match_edge expects that last input is in MemNode::ValueIn"); 811 } 812 813 virtual int Opcode() const; 814 virtual uint match_edge(uint idx) const { return idx == MemNode::Address || idx == MemNode::ValueIn; } 815 }; 816 817 //------------------------------StoreVectorNode-------------------------------- 818 // Store Vector to memory 819 class StoreVectorNode : public StoreNode { 820 private: 821 const TypeVect* _vect_type; 822 public: 823 StoreVectorNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val) 824 : StoreNode(c, mem, adr, at, val, MemNode::unordered), _vect_type(val->bottom_type()->is_vect()) { 825 init_class_id(Class_StoreVector); 826 set_mismatched_access(); 827 } 828 829 const TypeVect* vect_type() const { return _vect_type; } 830 uint length() const { return vect_type()->length(); } // Vector length 831 832 virtual int Opcode() const; 833 834 virtual uint ideal_reg() const { return Matcher::vector_ideal_reg(memory_size()); } 835 virtual BasicType memory_type() const { return T_VOID; } 836 virtual int memory_size() const { return vect_type()->length_in_bytes(); } 837 838 static StoreVectorNode* make(int opc, Node* ctl, Node* mem, 839 Node* adr, const TypePtr* atyp, Node* val, 840 uint vlen); 841 842 uint element_size(void) { return type2aelembytes(vect_type()->element_basic_type()); } 843 844 // Needed for proper cloning. 845 virtual uint size_of() const { return sizeof(*this); } 846 }; 847 848 //------------------------------StoreVectorScatterNode------------------------------ 849 // Store Vector into memory via index map 850 851 class StoreVectorScatterNode : public StoreVectorNode { 852 public: 853 StoreVectorScatterNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val, Node* indices) 854 : StoreVectorNode(c, mem, adr, at, val) { 855 init_class_id(Class_StoreVectorScatter); 856 assert(indices->bottom_type()->is_vect(), "indices must be in vector"); 857 add_req(indices); 858 assert(req() == MemNode::ValueIn + 2, "match_edge expects that last input is in MemNode::ValueIn+1"); 859 } 860 virtual int Opcode() const; 861 virtual uint match_edge(uint idx) const { return idx == MemNode::Address || 862 idx == MemNode::ValueIn || 863 idx == MemNode::ValueIn + 1; } 864 }; 865 866 //------------------------------StoreVectorMaskedNode-------------------------------- 867 // Store Vector to memory under the influence of a predicate register(mask). 868 class StoreVectorMaskedNode : public StoreVectorNode { 869 public: 870 StoreVectorMaskedNode(Node* c, Node* mem, Node* dst, Node* src, const TypePtr* at, Node* mask) 871 : StoreVectorNode(c, mem, dst, at, src) { 872 assert(mask->bottom_type()->isa_vectmask(), "sanity"); 873 init_class_id(Class_StoreVector); 874 set_mismatched_access(); 875 add_req(mask); 876 } 877 878 virtual int Opcode() const; 879 880 virtual uint match_edge(uint idx) const { 881 return idx > 1; 882 } 883 Node* Ideal(PhaseGVN* phase, bool can_reshape); 884 }; 885 886 //------------------------------LoadVectorMaskedNode-------------------------------- 887 // Load Vector from memory under the influence of a predicate register(mask). 888 class LoadVectorMaskedNode : public LoadVectorNode { 889 public: 890 LoadVectorMaskedNode(Node* c, Node* mem, Node* src, const TypePtr* at, const TypeVect* vt, Node* mask) 891 : LoadVectorNode(c, mem, src, at, vt) { 892 assert(mask->bottom_type()->isa_vectmask(), "sanity"); 893 init_class_id(Class_LoadVector); 894 set_mismatched_access(); 895 add_req(mask); 896 } 897 898 virtual int Opcode() const; 899 900 virtual uint match_edge(uint idx) const { 901 return idx > 1; 902 } 903 Node* Ideal(PhaseGVN* phase, bool can_reshape); 904 }; 905 906 //-------------------------------LoadVectorGatherMaskedNode--------------------------------- 907 // Load Vector from memory via index map under the influence of a predicate register(mask). 908 class LoadVectorGatherMaskedNode : public LoadVectorNode { 909 public: 910 LoadVectorGatherMaskedNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeVect* vt, Node* indices, Node* mask) 911 : LoadVectorNode(c, mem, adr, at, vt) { 912 init_class_id(Class_LoadVector); 913 assert(indices->bottom_type()->is_vect(), "indices must be in vector"); 914 assert(mask->bottom_type()->isa_vectmask(), "sanity"); 915 add_req(indices); 916 add_req(mask); 917 assert(req() == MemNode::ValueIn + 2, "match_edge expects that last input is in MemNode::ValueIn+1"); 918 } 919 920 virtual int Opcode() const; 921 virtual uint match_edge(uint idx) const { return idx == MemNode::Address || 922 idx == MemNode::ValueIn || 923 idx == MemNode::ValueIn + 1; } 924 }; 925 926 //------------------------------StoreVectorScatterMaskedNode-------------------------------- 927 // Store Vector into memory via index map under the influence of a predicate register(mask). 928 class StoreVectorScatterMaskedNode : public StoreVectorNode { 929 public: 930 StoreVectorScatterMaskedNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val, Node* indices, Node* mask) 931 : StoreVectorNode(c, mem, adr, at, val) { 932 init_class_id(Class_StoreVector); 933 assert(indices->bottom_type()->is_vect(), "indices must be in vector"); 934 assert(mask->bottom_type()->isa_vectmask(), "sanity"); 935 add_req(indices); 936 add_req(mask); 937 assert(req() == MemNode::ValueIn + 3, "match_edge expects that last input is in MemNode::ValueIn+2"); 938 } 939 virtual int Opcode() const; 940 virtual uint match_edge(uint idx) const { return idx == MemNode::Address || 941 idx == MemNode::ValueIn || 942 idx == MemNode::ValueIn + 1 || 943 idx == MemNode::ValueIn + 2; } 944 }; 945 946 //------------------------------VectorCmpMaskedNode-------------------------------- 947 // Vector Comparison under the influence of a predicate register(mask). 948 class VectorCmpMaskedNode : public TypeNode { 949 public: 950 VectorCmpMaskedNode(Node* src1, Node* src2, Node* mask, const Type* ty): TypeNode(ty, 4) { 951 init_req(1, src1); 952 init_req(2, src2); 953 init_req(3, mask); 954 } 955 956 virtual int Opcode() const; 957 }; 958 959 //------------------------------VectorMaskGenNode---------------------------------- 960 class VectorMaskGenNode : public TypeNode { 961 public: 962 VectorMaskGenNode(Node* length, const Type* ty): TypeNode(ty, 2) { 963 init_req(1, length); 964 } 965 966 virtual int Opcode() const; 967 virtual uint ideal_reg() const { return Op_RegVectMask; } 968 static Node* make(Node* length, BasicType vmask_bt); 969 }; 970 971 //------------------------------VectorMaskOpNode----------------------------------- 972 class VectorMaskOpNode : public TypeNode { 973 public: 974 VectorMaskOpNode(Node* mask, const Type* ty, int mopc): 975 TypeNode(ty, 2), _mopc(mopc) { 976 assert(Matcher::has_predicated_vectors() || mask->bottom_type()->is_vect()->element_basic_type() == T_BOOLEAN, ""); 977 init_req(1, mask); 978 } 979 980 virtual int Opcode() const; 981 virtual uint size_of() const { return sizeof(VectorMaskOpNode); } 982 virtual uint ideal_reg() const { return Op_RegI; } 983 int get_mask_Opcode() const { return _mopc;} 984 static Node* make(Node* mask, const Type* ty, int mopc); 985 986 private: 987 int _mopc; 988 }; 989 990 class VectorMaskTrueCountNode : public VectorMaskOpNode { 991 public: 992 VectorMaskTrueCountNode(Node* mask, const Type* ty): 993 VectorMaskOpNode(mask, ty, Op_VectorMaskTrueCount) {} 994 virtual int Opcode() const; 995 }; 996 997 class VectorMaskFirstTrueNode : public VectorMaskOpNode { 998 public: 999 VectorMaskFirstTrueNode(Node* mask, const Type* ty): 1000 VectorMaskOpNode(mask, ty, Op_VectorMaskFirstTrue) {} 1001 virtual int Opcode() const; 1002 }; 1003 1004 class VectorMaskLastTrueNode : public VectorMaskOpNode { 1005 public: 1006 VectorMaskLastTrueNode(Node* mask, const Type* ty): 1007 VectorMaskOpNode(mask, ty, Op_VectorMaskLastTrue) {} 1008 virtual int Opcode() const; 1009 }; 1010 1011 class VectorMaskToLongNode : public VectorMaskOpNode { 1012 public: 1013 VectorMaskToLongNode(Node* mask, const Type* ty): 1014 VectorMaskOpNode(mask, ty, Op_VectorMaskToLong) {} 1015 virtual int Opcode() const; 1016 virtual uint ideal_reg() const { return Op_RegL; } 1017 virtual Node* Identity(PhaseGVN* phase); 1018 }; 1019 1020 class VectorLongToMaskNode : public VectorNode { 1021 public: 1022 VectorLongToMaskNode(Node* mask, const TypeVect* ty): 1023 VectorNode(mask, ty) { 1024 } 1025 virtual int Opcode() const; 1026 Node* Ideal(PhaseGVN* phase, bool can_reshape); 1027 }; 1028 1029 //-------------------------- Vector mask broadcast ----------------------------------- 1030 class MaskAllNode : public VectorNode { 1031 public: 1032 MaskAllNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) {} 1033 virtual int Opcode() const; 1034 }; 1035 1036 //--------------------------- Vector mask logical and -------------------------------- 1037 class AndVMaskNode : public VectorNode { 1038 public: 1039 AndVMaskNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 1040 virtual int Opcode() const; 1041 }; 1042 1043 //--------------------------- Vector mask logical or --------------------------------- 1044 class OrVMaskNode : public VectorNode { 1045 public: 1046 OrVMaskNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 1047 virtual int Opcode() const; 1048 }; 1049 1050 //--------------------------- Vector mask logical xor -------------------------------- 1051 class XorVMaskNode : public VectorNode { 1052 public: 1053 XorVMaskNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 1054 virtual int Opcode() const; 1055 }; 1056 1057 //=========================Promote_Scalar_to_Vector============================ 1058 1059 //------------------------------ReplicateBNode--------------------------------- 1060 // Replicate byte scalar to be vector 1061 class ReplicateBNode : public VectorNode { 1062 public: 1063 ReplicateBNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 1064 virtual int Opcode() const; 1065 }; 1066 1067 //------------------------------ReplicateSNode--------------------------------- 1068 // Replicate short scalar to be vector 1069 class ReplicateSNode : public VectorNode { 1070 public: 1071 ReplicateSNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 1072 virtual int Opcode() const; 1073 }; 1074 1075 //------------------------------ReplicateINode--------------------------------- 1076 // Replicate int scalar to be vector 1077 class ReplicateINode : public VectorNode { 1078 public: 1079 ReplicateINode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 1080 virtual int Opcode() const; 1081 }; 1082 1083 //------------------------------ReplicateLNode--------------------------------- 1084 // Replicate long scalar to be vector 1085 class ReplicateLNode : public VectorNode { 1086 public: 1087 ReplicateLNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 1088 virtual int Opcode() const; 1089 }; 1090 1091 //------------------------------ReplicateFNode--------------------------------- 1092 // Replicate float scalar to be vector 1093 class ReplicateFNode : public VectorNode { 1094 public: 1095 ReplicateFNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 1096 virtual int Opcode() const; 1097 }; 1098 1099 //------------------------------ReplicateDNode--------------------------------- 1100 // Replicate double scalar to be vector 1101 class ReplicateDNode : public VectorNode { 1102 public: 1103 ReplicateDNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 1104 virtual int Opcode() const; 1105 }; 1106 1107 //========================Pack_Scalars_into_a_Vector=========================== 1108 1109 //------------------------------PackNode--------------------------------------- 1110 // Pack parent class (not for code generation). 1111 class PackNode : public VectorNode { 1112 public: 1113 PackNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 1114 PackNode(Node* in1, Node* n2, const TypeVect* vt) : VectorNode(in1, n2, vt) {} 1115 virtual int Opcode() const; 1116 1117 void add_opd(Node* n) { 1118 add_req(n); 1119 } 1120 1121 // Create a binary tree form for Packs. [lo, hi) (half-open) range 1122 PackNode* binary_tree_pack(int lo, int hi); 1123 1124 static PackNode* make(Node* s, uint vlen, BasicType bt); 1125 }; 1126 1127 //------------------------------PackBNode-------------------------------------- 1128 // Pack byte scalars into vector 1129 class PackBNode : public PackNode { 1130 public: 1131 PackBNode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} 1132 virtual int Opcode() const; 1133 }; 1134 1135 //------------------------------PackSNode-------------------------------------- 1136 // Pack short scalars into a vector 1137 class PackSNode : public PackNode { 1138 public: 1139 PackSNode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} 1140 PackSNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 1141 virtual int Opcode() const; 1142 }; 1143 1144 //------------------------------PackINode-------------------------------------- 1145 // Pack integer scalars into a vector 1146 class PackINode : public PackNode { 1147 public: 1148 PackINode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} 1149 PackINode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 1150 virtual int Opcode() const; 1151 }; 1152 1153 //------------------------------PackLNode-------------------------------------- 1154 // Pack long scalars into a vector 1155 class PackLNode : public PackNode { 1156 public: 1157 PackLNode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} 1158 PackLNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 1159 virtual int Opcode() const; 1160 }; 1161 1162 //------------------------------Pack2LNode------------------------------------- 1163 // Pack 2 long scalars into a vector 1164 class Pack2LNode : public PackNode { 1165 public: 1166 Pack2LNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 1167 virtual int Opcode() const; 1168 }; 1169 1170 //------------------------------PackFNode-------------------------------------- 1171 // Pack float scalars into vector 1172 class PackFNode : public PackNode { 1173 public: 1174 PackFNode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} 1175 PackFNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 1176 virtual int Opcode() const; 1177 }; 1178 1179 //------------------------------PackDNode-------------------------------------- 1180 // Pack double scalars into a vector 1181 class PackDNode : public PackNode { 1182 public: 1183 PackDNode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} 1184 PackDNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 1185 virtual int Opcode() const; 1186 }; 1187 1188 //------------------------------Pack2DNode------------------------------------- 1189 // Pack 2 double scalars into a vector 1190 class Pack2DNode : public PackNode { 1191 public: 1192 Pack2DNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 1193 virtual int Opcode() const; 1194 }; 1195 1196 1197 class VectorLoadConstNode : public VectorNode { 1198 public: 1199 VectorLoadConstNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 1200 virtual int Opcode() const; 1201 }; 1202 1203 //========================Extract_Scalar_from_Vector=========================== 1204 1205 //------------------------------ExtractNode------------------------------------ 1206 // Extract a scalar from a vector at position "pos" 1207 class ExtractNode : public Node { 1208 public: 1209 ExtractNode(Node* src, ConINode* pos) : Node(NULL, src, (Node*)pos) { 1210 assert(in(2)->get_int() >= 0, "positive constants"); 1211 } 1212 virtual int Opcode() const; 1213 uint pos() const { return in(2)->get_int(); } 1214 1215 static Node* make(Node* v, uint position, BasicType bt); 1216 static int opcode(BasicType bt); 1217 }; 1218 1219 //------------------------------ExtractBNode----------------------------------- 1220 // Extract a byte from a vector at position "pos" 1221 class ExtractBNode : public ExtractNode { 1222 public: 1223 ExtractBNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 1224 virtual int Opcode() const; 1225 virtual const Type *bottom_type() const { return TypeInt::INT; } 1226 virtual uint ideal_reg() const { return Op_RegI; } 1227 }; 1228 1229 //------------------------------ExtractUBNode---------------------------------- 1230 // Extract a boolean from a vector at position "pos" 1231 class ExtractUBNode : public ExtractNode { 1232 public: 1233 ExtractUBNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 1234 virtual int Opcode() const; 1235 virtual const Type *bottom_type() const { return TypeInt::INT; } 1236 virtual uint ideal_reg() const { return Op_RegI; } 1237 }; 1238 1239 //------------------------------ExtractCNode----------------------------------- 1240 // Extract a char from a vector at position "pos" 1241 class ExtractCNode : public ExtractNode { 1242 public: 1243 ExtractCNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 1244 virtual int Opcode() const; 1245 virtual const Type *bottom_type() const { return TypeInt::CHAR; } 1246 virtual uint ideal_reg() const { return Op_RegI; } 1247 }; 1248 1249 //------------------------------ExtractSNode----------------------------------- 1250 // Extract a short from a vector at position "pos" 1251 class ExtractSNode : public ExtractNode { 1252 public: 1253 ExtractSNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 1254 virtual int Opcode() const; 1255 virtual const Type *bottom_type() const { return TypeInt::SHORT; } 1256 virtual uint ideal_reg() const { return Op_RegI; } 1257 }; 1258 1259 //------------------------------ExtractINode----------------------------------- 1260 // Extract an int from a vector at position "pos" 1261 class ExtractINode : public ExtractNode { 1262 public: 1263 ExtractINode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 1264 virtual int Opcode() const; 1265 virtual const Type *bottom_type() const { return TypeInt::INT; } 1266 virtual uint ideal_reg() const { return Op_RegI; } 1267 }; 1268 1269 //------------------------------ExtractLNode----------------------------------- 1270 // Extract a long from a vector at position "pos" 1271 class ExtractLNode : public ExtractNode { 1272 public: 1273 ExtractLNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 1274 virtual int Opcode() const; 1275 virtual const Type *bottom_type() const { return TypeLong::LONG; } 1276 virtual uint ideal_reg() const { return Op_RegL; } 1277 }; 1278 1279 //------------------------------ExtractFNode----------------------------------- 1280 // Extract a float from a vector at position "pos" 1281 class ExtractFNode : public ExtractNode { 1282 public: 1283 ExtractFNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 1284 virtual int Opcode() const; 1285 virtual const Type *bottom_type() const { return Type::FLOAT; } 1286 virtual uint ideal_reg() const { return Op_RegF; } 1287 }; 1288 1289 //------------------------------ExtractDNode----------------------------------- 1290 // Extract a double from a vector at position "pos" 1291 class ExtractDNode : public ExtractNode { 1292 public: 1293 ExtractDNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 1294 virtual int Opcode() const; 1295 virtual const Type *bottom_type() const { return Type::DOUBLE; } 1296 virtual uint ideal_reg() const { return Op_RegD; } 1297 }; 1298 1299 //------------------------------MacroLogicVNode------------------------------- 1300 // Vector logical operations packing node. 1301 class MacroLogicVNode : public VectorNode { 1302 private: 1303 MacroLogicVNode(Node* in1, Node* in2, Node* in3, Node* fn, Node* mask, const TypeVect* vt) 1304 : VectorNode(in1, in2, in3, fn, vt) { 1305 if (mask) { 1306 this->add_req(mask); 1307 this->add_flag(Node::Flag_is_predicated_vector); 1308 } 1309 } 1310 1311 public: 1312 virtual int Opcode() const; 1313 1314 static MacroLogicVNode* make(PhaseGVN& igvn, Node* in1, Node* in2, Node* in3, 1315 Node* mask, uint truth_table, const TypeVect* vt); 1316 }; 1317 1318 class VectorMaskCmpNode : public VectorNode { 1319 private: 1320 BoolTest::mask _predicate; 1321 1322 protected: 1323 virtual uint size_of() const { return sizeof(VectorMaskCmpNode); } 1324 1325 public: 1326 VectorMaskCmpNode(BoolTest::mask predicate, Node* in1, Node* in2, ConINode* predicate_node, const TypeVect* vt) : 1327 VectorNode(in1, in2, predicate_node, vt), 1328 _predicate(predicate) { 1329 assert(in1->bottom_type()->is_vect()->element_basic_type() == in2->bottom_type()->is_vect()->element_basic_type(), 1330 "VectorMaskCmp inputs must have same type for elements"); 1331 assert(in1->bottom_type()->is_vect()->length() == in2->bottom_type()->is_vect()->length(), 1332 "VectorMaskCmp inputs must have same number of elements"); 1333 assert((BoolTest::mask)predicate_node->get_int() == predicate, "Unmatched predicates"); 1334 init_class_id(Class_VectorMaskCmp); 1335 } 1336 1337 virtual int Opcode() const; 1338 virtual uint hash() const { return VectorNode::hash() + _predicate; } 1339 virtual bool cmp( const Node &n ) const { 1340 return VectorNode::cmp(n) && _predicate == ((VectorMaskCmpNode&)n)._predicate; 1341 } 1342 BoolTest::mask get_predicate() { return _predicate; } 1343 #ifndef PRODUCT 1344 virtual void dump_spec(outputStream *st) const; 1345 #endif // !PRODUCT 1346 }; 1347 1348 // Used to wrap other vector nodes in order to add masking functionality. 1349 class VectorMaskWrapperNode : public VectorNode { 1350 public: 1351 VectorMaskWrapperNode(Node* vector, Node* mask) 1352 : VectorNode(vector, mask, vector->bottom_type()->is_vect()) { 1353 assert(mask->is_VectorMaskCmp(), "VectorMaskWrapper requires that second argument be a mask"); 1354 } 1355 1356 virtual int Opcode() const; 1357 Node* vector_val() const { return in(1); } 1358 Node* vector_mask() const { return in(2); } 1359 }; 1360 1361 class VectorTestNode : public Node { 1362 private: 1363 BoolTest::mask _predicate; 1364 1365 protected: 1366 uint size_of() const { return sizeof(*this); } 1367 1368 public: 1369 VectorTestNode(Node* in1, Node* in2, BoolTest::mask predicate) : Node(NULL, in1, in2), _predicate(predicate) { 1370 assert(in2->bottom_type()->is_vect() == in2->bottom_type()->is_vect(), "same vector type"); 1371 } 1372 virtual int Opcode() const; 1373 virtual uint hash() const { return Node::hash() + _predicate; } 1374 virtual bool cmp( const Node &n ) const { 1375 return Node::cmp(n) && _predicate == ((VectorTestNode&)n)._predicate; 1376 } 1377 virtual const Type *bottom_type() const { return TypeInt::BOOL; } 1378 virtual uint ideal_reg() const { return Op_RegI; } // TODO Should be RegFlags but due to missing comparison flags for BoolTest 1379 // in middle-end, we make it boolean result directly. 1380 BoolTest::mask get_predicate() const { return _predicate; } 1381 }; 1382 1383 class VectorBlendNode : public VectorNode { 1384 public: 1385 VectorBlendNode(Node* vec1, Node* vec2, Node* mask) 1386 : VectorNode(vec1, vec2, mask, vec1->bottom_type()->is_vect()) { 1387 // assert(mask->is_VectorMask(), "VectorBlendNode requires that third argument be a mask"); 1388 } 1389 1390 virtual int Opcode() const; 1391 Node* vec1() const { return in(1); } 1392 Node* vec2() const { return in(2); } 1393 Node* vec_mask() const { return in(3); } 1394 }; 1395 1396 class VectorRearrangeNode : public VectorNode { 1397 public: 1398 VectorRearrangeNode(Node* vec1, Node* shuffle) 1399 : VectorNode(vec1, shuffle, vec1->bottom_type()->is_vect()) { 1400 // assert(mask->is_VectorMask(), "VectorBlendNode requires that third argument be a mask"); 1401 } 1402 1403 virtual int Opcode() const; 1404 Node* vec1() const { return in(1); } 1405 Node* vec_shuffle() const { return in(2); } 1406 }; 1407 1408 class VectorLoadShuffleNode : public VectorNode { 1409 public: 1410 VectorLoadShuffleNode(Node* in, const TypeVect* vt) 1411 : VectorNode(in, vt) { 1412 assert(in->bottom_type()->is_vect()->element_basic_type() == T_BYTE, "must be BYTE"); 1413 } 1414 1415 int GetOutShuffleSize() const { return type2aelembytes(vect_type()->element_basic_type()); } 1416 virtual int Opcode() const; 1417 }; 1418 1419 class VectorLoadMaskNode : public VectorNode { 1420 public: 1421 VectorLoadMaskNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) { 1422 assert(in->bottom_type()->is_vect()->element_basic_type() == T_BOOLEAN, "must be boolean"); 1423 } 1424 1425 virtual int Opcode() const; 1426 virtual Node* Identity(PhaseGVN* phase); 1427 }; 1428 1429 class VectorStoreMaskNode : public VectorNode { 1430 protected: 1431 VectorStoreMaskNode(Node* in1, ConINode* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 1432 1433 public: 1434 virtual int Opcode() const; 1435 virtual Node* Identity(PhaseGVN* phase); 1436 1437 static VectorStoreMaskNode* make(PhaseGVN& gvn, Node* in, BasicType in_type, uint num_elem); 1438 }; 1439 1440 class VectorMaskCastNode : public VectorNode { 1441 public: 1442 VectorMaskCastNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) { 1443 const TypeVect* in_vt = in->bottom_type()->is_vect(); 1444 assert(in_vt->length() == vt->length(), "vector length must match"); 1445 } 1446 static Node* makeCastNode(PhaseGVN* phase, Node* in1, const TypeVect * vt); 1447 virtual int Opcode() const; 1448 }; 1449 1450 // This is intended for use as a simple reinterpret node that has no cast. 1451 class VectorReinterpretNode : public VectorNode { 1452 private: 1453 const TypeVect* _src_vt; 1454 1455 protected: 1456 uint size_of() const { return sizeof(VectorReinterpretNode); } 1457 public: 1458 VectorReinterpretNode(Node* in, const TypeVect* src_vt, const TypeVect* dst_vt) 1459 : VectorNode(in, dst_vt), _src_vt(src_vt) { 1460 assert((!dst_vt->isa_vectmask() && !src_vt->isa_vectmask()) || 1461 (type2aelembytes(src_vt->element_basic_type()) >= type2aelembytes(dst_vt->element_basic_type())), 1462 "unsupported mask widening reinterpretation"); 1463 init_class_id(Class_VectorReinterpret); 1464 } 1465 1466 const TypeVect* src_type() { return _src_vt; } 1467 virtual uint hash() const { return VectorNode::hash() + _src_vt->hash(); } 1468 virtual bool cmp( const Node &n ) const { 1469 return VectorNode::cmp(n) && !Type::cmp(_src_vt,((VectorReinterpretNode&)n)._src_vt); 1470 } 1471 virtual Node* Identity(PhaseGVN* phase); 1472 1473 virtual int Opcode() const; 1474 }; 1475 1476 class VectorCastNode : public VectorNode { 1477 public: 1478 VectorCastNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) {} 1479 virtual int Opcode() const; 1480 1481 static VectorCastNode* make(int vopc, Node* n1, BasicType bt, uint vlen); 1482 static int opcode(BasicType bt, bool is_signed = true); 1483 static bool implemented(BasicType bt, uint vlen); 1484 1485 virtual Node* Identity(PhaseGVN* phase); 1486 }; 1487 1488 class VectorCastB2XNode : public VectorCastNode { 1489 public: 1490 VectorCastB2XNode(Node* in, const TypeVect* vt) : VectorCastNode(in, vt) { 1491 assert(in->bottom_type()->is_vect()->element_basic_type() == T_BYTE, "must be byte"); 1492 } 1493 virtual int Opcode() const; 1494 }; 1495 1496 class VectorCastS2XNode : public VectorCastNode { 1497 public: 1498 VectorCastS2XNode(Node* in, const TypeVect* vt) : VectorCastNode(in, vt) { 1499 assert(in->bottom_type()->is_vect()->element_basic_type() == T_SHORT, "must be short"); 1500 } 1501 virtual int Opcode() const; 1502 }; 1503 1504 class VectorCastI2XNode : public VectorCastNode { 1505 public: 1506 VectorCastI2XNode(Node* in, const TypeVect* vt) : VectorCastNode(in, vt) { 1507 assert(in->bottom_type()->is_vect()->element_basic_type() == T_INT, "must be int"); 1508 } 1509 virtual int Opcode() const; 1510 }; 1511 1512 class VectorCastL2XNode : public VectorCastNode { 1513 public: 1514 VectorCastL2XNode(Node* in, const TypeVect* vt) : VectorCastNode(in, vt) { 1515 assert(in->bottom_type()->is_vect()->element_basic_type() == T_LONG, "must be long"); 1516 } 1517 virtual int Opcode() const; 1518 }; 1519 1520 class VectorCastF2XNode : public VectorCastNode { 1521 public: 1522 VectorCastF2XNode(Node* in, const TypeVect* vt) : VectorCastNode(in, vt) { 1523 assert(in->bottom_type()->is_vect()->element_basic_type() == T_FLOAT, "must be float"); 1524 } 1525 virtual int Opcode() const; 1526 }; 1527 1528 class VectorCastD2XNode : public VectorCastNode { 1529 public: 1530 VectorCastD2XNode(Node* in, const TypeVect* vt) : VectorCastNode(in, vt) { 1531 assert(in->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE, "must be double"); 1532 } 1533 virtual int Opcode() const; 1534 }; 1535 1536 class RoundVFNode : public VectorNode { 1537 public: 1538 RoundVFNode(Node* in, const TypeVect* vt) :VectorNode(in, vt) { 1539 assert(in->bottom_type()->is_vect()->element_basic_type() == T_FLOAT, "must be float"); 1540 } 1541 virtual int Opcode() const; 1542 }; 1543 1544 class VectorUCastB2XNode : public VectorCastNode { 1545 public: 1546 VectorUCastB2XNode(Node* in, const TypeVect* vt) : VectorCastNode(in, vt) { 1547 assert(in->bottom_type()->is_vect()->element_basic_type() == T_BYTE, "must be byte"); 1548 } 1549 virtual int Opcode() const; 1550 }; 1551 1552 class RoundVDNode : public VectorNode { 1553 public: 1554 RoundVDNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) { 1555 assert(in->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE, "must be double"); 1556 } 1557 virtual int Opcode() const; 1558 }; 1559 1560 class VectorUCastS2XNode : public VectorCastNode { 1561 public: 1562 VectorUCastS2XNode(Node* in, const TypeVect* vt) : VectorCastNode(in, vt) { 1563 assert(in->bottom_type()->is_vect()->element_basic_type() == T_SHORT, "must be short"); 1564 } 1565 virtual int Opcode() const; 1566 }; 1567 1568 class VectorUCastI2XNode : public VectorCastNode { 1569 public: 1570 VectorUCastI2XNode(Node* in, const TypeVect* vt) : VectorCastNode(in, vt) { 1571 assert(in->bottom_type()->is_vect()->element_basic_type() == T_INT, "must be int"); 1572 } 1573 virtual int Opcode() const; 1574 }; 1575 1576 class VectorInsertNode : public VectorNode { 1577 public: 1578 VectorInsertNode(Node* vsrc, Node* new_val, ConINode* pos, const TypeVect* vt) : VectorNode(vsrc, new_val, (Node*)pos, vt) { 1579 assert(pos->get_int() >= 0, "positive constants"); 1580 assert(pos->get_int() < (int)vt->length(), "index must be less than vector length"); 1581 assert(Type::cmp(vt, vsrc->bottom_type()) == 0, "input and output must be same type"); 1582 } 1583 virtual int Opcode() const; 1584 uint pos() const { return in(3)->get_int(); } 1585 1586 static Node* make(Node* vec, Node* new_val, int position); 1587 }; 1588 1589 class VectorBoxNode : public Node { 1590 private: 1591 const TypeInstPtr* const _box_type; 1592 const TypeVect* const _vec_type; 1593 public: 1594 enum { 1595 Box = 1, 1596 Value = 2 1597 }; 1598 VectorBoxNode(Compile* C, Node* box, Node* val, 1599 const TypeInstPtr* box_type, const TypeVect* vt) 1600 : Node(NULL, box, val), _box_type(box_type), _vec_type(vt) { 1601 init_flags(Flag_is_macro); 1602 C->add_macro_node(this); 1603 } 1604 1605 const TypeInstPtr* box_type() const { assert(_box_type != NULL, ""); return _box_type; }; 1606 const TypeVect* vec_type() const { assert(_vec_type != NULL, ""); return _vec_type; }; 1607 1608 virtual int Opcode() const; 1609 virtual const Type* bottom_type() const { return _box_type; } 1610 virtual uint ideal_reg() const { return box_type()->ideal_reg(); } 1611 virtual uint size_of() const { return sizeof(*this); } 1612 1613 static const TypeFunc* vec_box_type(const TypeInstPtr* box_type); 1614 }; 1615 1616 class VectorBoxAllocateNode : public CallStaticJavaNode { 1617 public: 1618 VectorBoxAllocateNode(Compile* C, const TypeInstPtr* vbox_type) 1619 : CallStaticJavaNode(C, VectorBoxNode::vec_box_type(vbox_type), NULL, NULL) { 1620 init_flags(Flag_is_macro); 1621 C->add_macro_node(this); 1622 } 1623 1624 virtual int Opcode() const; 1625 #ifndef PRODUCT 1626 virtual void dump_spec(outputStream *st) const; 1627 #endif // !PRODUCT 1628 }; 1629 1630 class VectorUnboxNode : public VectorNode { 1631 private: 1632 bool _shuffle_to_vector; 1633 protected: 1634 uint size_of() const { return sizeof(*this); } 1635 public: 1636 VectorUnboxNode(Compile* C, const TypeVect* vec_type, Node* obj, Node* mem, bool shuffle_to_vector) 1637 : VectorNode(mem, obj, vec_type) { 1638 _shuffle_to_vector = shuffle_to_vector; 1639 init_class_id(Class_VectorUnbox); 1640 init_flags(Flag_is_macro); 1641 C->add_macro_node(this); 1642 } 1643 1644 virtual int Opcode() const; 1645 Node* obj() const { return in(2); } 1646 Node* mem() const { return in(1); } 1647 virtual Node* Identity(PhaseGVN* phase); 1648 Node* Ideal(PhaseGVN* phase, bool can_reshape); 1649 bool is_shuffle_to_vector() { return _shuffle_to_vector; } 1650 }; 1651 1652 class RotateRightVNode : public VectorNode { 1653 public: 1654 RotateRightVNode(Node* in1, Node* in2, const TypeVect* vt) 1655 : VectorNode(in1, in2, vt) {} 1656 1657 virtual int Opcode() const; 1658 Node* Ideal(PhaseGVN* phase, bool can_reshape); 1659 }; 1660 1661 class RotateLeftVNode : public VectorNode { 1662 public: 1663 RotateLeftVNode(Node* in1, Node* in2, const TypeVect* vt) 1664 : VectorNode(in1, in2, vt) {} 1665 1666 virtual int Opcode() const; 1667 Node* Ideal(PhaseGVN* phase, bool can_reshape); 1668 }; 1669 #endif // SHARE_OPTO_VECTORNODE_HPP