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