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