1 /*
   2  * Copyright (c) 2007, 2014, 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_VM_OPTO_VECTORNODE_HPP
  25 #define SHARE_VM_OPTO_VECTORNODE_HPP
  26 
  27 #include "opto/matcher.hpp"
  28 #include "opto/memnode.hpp"
  29 #include "opto/node.hpp"
  30 #include "opto/opcodes.hpp"
  31 
  32 //------------------------------VectorNode-------------------------------------
  33 // Vector Operation
  34 class VectorNode : public TypeNode {
  35  public:
  36 
  37   VectorNode(Node* n1, const TypeVect* vt) : TypeNode(vt, 2) {
  38     init_class_id(Class_Vector);
  39     init_req(1, n1);
  40   }
  41   VectorNode(Node* n1, Node* n2, const TypeVect* vt) : TypeNode(vt, 3) {
  42     init_class_id(Class_Vector);
  43     init_req(1, n1);
  44     init_req(2, n2);
  45   }
  46 
  47   VectorNode(Node* n1, Node* n2, Node* n3, const TypeVect* vt) : TypeNode(vt, 4) {
  48     init_class_id(Class_Vector);
  49     init_req(1, n1);
  50     init_req(2, n2);
  51     init_req(3, n3);
  52   }
  53 
  54   const TypeVect* vect_type() const { return type()->is_vect(); }
  55   uint length() const { return vect_type()->length(); } // Vector length
  56   uint length_in_bytes() const { return vect_type()->length_in_bytes(); }
  57 
  58   virtual int Opcode() const;
  59 
  60   virtual uint ideal_reg() const { return Matcher::vector_ideal_reg(vect_type()->length_in_bytes()); }
  61 
  62   static VectorNode* scalar2vector(Node* s, uint vlen, const Type* opd_t);
  63   static VectorNode* shift_count(Node* shift, Node* cnt, uint vlen, BasicType bt);
  64   static VectorNode* make(int opc, Node* n1, Node* n2, uint vlen, BasicType bt);
  65   static VectorNode* make(int opc, Node* n1, Node* n2, Node* n3, uint vlen, BasicType bt);
  66 
  67   static int  opcode(int opc, BasicType bt);
  68   static bool implemented(int opc, uint vlen, BasicType bt);
  69   static bool is_shift(Node* n);
  70   static bool is_invariant_vector(Node* n);
  71   // [Start, end) half-open range defining which operands are vectors
  72   static void vector_operands(Node* n, uint* start, uint* end);
  73 };
  74 
  75 //===========================Vector=ALU=Operations=============================
  76 
  77 //------------------------------AddVBNode--------------------------------------
  78 // Vector add byte
  79 class AddVBNode : public VectorNode {
  80  public:
  81   AddVBNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
  82   virtual int Opcode() const;
  83 };
  84 
  85 //------------------------------AddVSNode--------------------------------------
  86 // Vector add char/short
  87 class AddVSNode : public VectorNode {
  88  public:
  89   AddVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
  90   virtual int Opcode() const;
  91 };
  92 
  93 //------------------------------AddVINode--------------------------------------
  94 // Vector add int
  95 class AddVINode : public VectorNode {
  96  public:
  97   AddVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
  98   virtual int Opcode() const;
  99 };
 100 
 101 //------------------------------AddVLNode--------------------------------------
 102 // Vector add long
 103 class AddVLNode : public VectorNode {
 104 public:
 105   AddVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {}
 106   virtual int Opcode() const;
 107 };
 108 
 109 //------------------------------AddVFNode--------------------------------------
 110 // Vector add float
 111 class AddVFNode : public VectorNode {
 112 public:
 113   AddVFNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {}
 114   virtual int Opcode() const;
 115 };
 116 
 117 //------------------------------AddVDNode--------------------------------------
 118 // Vector add double
 119 class AddVDNode : public VectorNode {
 120 public:
 121   AddVDNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {}
 122   virtual int Opcode() const;
 123 };
 124 
 125 //------------------------------ReductionNode------------------------------------
 126 // Perform reduction of a vector
 127 class ReductionNode : public Node {
 128  public:
 129   ReductionNode(Node *ctrl, Node* in1, Node* in2) : Node(ctrl, in1, in2) {}
 130 
 131   static ReductionNode* make(int opc, Node *ctrl, Node* in1, Node* in2, BasicType bt);
 132   static int  opcode(int opc, BasicType bt);
 133   static bool implemented(int opc, uint vlen, BasicType bt);
 134 };
 135 
 136 //------------------------------AddReductionVINode--------------------------------------
 137 // Vector add int as a reduction
 138 class AddReductionVINode : public ReductionNode {
 139 public:
 140   AddReductionVINode(Node * ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {}
 141   virtual int Opcode() const;
 142   virtual const Type* bottom_type() const { return TypeInt::INT; }
 143   virtual uint ideal_reg() const { return Op_RegI; }
 144 };
 145 
 146 //------------------------------AddReductionVLNode--------------------------------------
 147 // Vector add long as a reduction
 148 class AddReductionVLNode : public ReductionNode {
 149 public:
 150   AddReductionVLNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {}
 151   virtual int Opcode() const;
 152   virtual const Type* bottom_type() const { return TypeLong::LONG; }
 153   virtual uint ideal_reg() const { return Op_RegL; }
 154 };
 155 
 156 //------------------------------AddReductionVFNode--------------------------------------
 157 // Vector add float as a reduction
 158 class AddReductionVFNode : public ReductionNode {
 159 public:
 160   AddReductionVFNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {}
 161   virtual int Opcode() const;
 162   virtual const Type* bottom_type() const { return Type::FLOAT; }
 163   virtual uint ideal_reg() const { return Op_RegF; }
 164 };
 165 
 166 //------------------------------AddReductionVDNode--------------------------------------
 167 // Vector add double as a reduction
 168 class AddReductionVDNode : public ReductionNode {
 169 public:
 170   AddReductionVDNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {}
 171   virtual int Opcode() const;
 172   virtual const Type* bottom_type() const { return Type::DOUBLE; }
 173   virtual uint ideal_reg() const { return Op_RegD; }
 174 };
 175 
 176 //------------------------------SubVBNode--------------------------------------
 177 // Vector subtract byte
 178 class SubVBNode : public VectorNode {
 179  public:
 180   SubVBNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 181   virtual int Opcode() const;
 182 };
 183 
 184 //------------------------------SubVSNode--------------------------------------
 185 // Vector subtract short
 186 class SubVSNode : public VectorNode {
 187  public:
 188   SubVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 189   virtual int Opcode() const;
 190 };
 191 
 192 //------------------------------SubVINode--------------------------------------
 193 // Vector subtract int
 194 class SubVINode : public VectorNode {
 195  public:
 196   SubVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 197   virtual int Opcode() const;
 198 };
 199 
 200 //------------------------------SubVLNode--------------------------------------
 201 // Vector subtract long
 202 class SubVLNode : public VectorNode {
 203  public:
 204   SubVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 205   virtual int Opcode() const;
 206 };
 207 
 208 //------------------------------SubVFNode--------------------------------------
 209 // Vector subtract float
 210 class SubVFNode : public VectorNode {
 211  public:
 212   SubVFNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 213   virtual int Opcode() const;
 214 };
 215 
 216 //------------------------------SubVDNode--------------------------------------
 217 // Vector subtract double
 218 class SubVDNode : public VectorNode {
 219  public:
 220   SubVDNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 221   virtual int Opcode() const;
 222 };
 223 
 224 //------------------------------MulVSNode--------------------------------------
 225 // Vector multiply short
 226 class MulVSNode : public VectorNode {
 227  public:
 228   MulVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 229   virtual int Opcode() const;
 230 };
 231 
 232 //------------------------------MulVINode--------------------------------------
 233 // Vector multiply int
 234 class MulVINode : public VectorNode {
 235  public:
 236   MulVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 237   virtual int Opcode() const;
 238 };
 239 
 240 //------------------------------MulVLNode--------------------------------------
 241 // Vector multiply long
 242 class MulVLNode : public VectorNode {
 243 public:
 244   MulVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {}
 245   virtual int Opcode() const;
 246 };
 247 
 248 //------------------------------MulVFNode--------------------------------------
 249 // Vector multiply float
 250 class MulVFNode : public VectorNode {
 251 public:
 252   MulVFNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {}
 253   virtual int Opcode() const;
 254 };
 255 
 256 //------------------------------MulVDNode--------------------------------------
 257 // Vector multiply double
 258 class MulVDNode : public VectorNode {
 259 public:
 260   MulVDNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {}
 261   virtual int Opcode() const;
 262 };
 263 
 264 //------------------------------FmaVDNode--------------------------------------
 265 // Vector multiply double
 266 class FmaVDNode : public VectorNode {
 267 public:
 268   FmaVDNode(Node* in1, Node* in2, Node* in3, const TypeVect* vt) : VectorNode(in1, in2, in3, vt) {}
 269   virtual int Opcode() const;
 270 };
 271 
 272 //------------------------------FmaVFNode--------------------------------------
 273 // Vector multiply float
 274 class FmaVFNode : public VectorNode {
 275 public:
 276   FmaVFNode(Node* in1, Node* in2, Node* in3, const TypeVect* vt) : VectorNode(in1, in2, in3, vt) {}
 277   virtual int Opcode() const;
 278 };
 279 
 280 //------------------------------CMoveVFNode--------------------------------------
 281 // Vector float conditional move
 282 class CMoveVFNode : public VectorNode {
 283 public:
 284   CMoveVFNode(Node* in1, Node* in2, Node* in3, const TypeVect* vt) : VectorNode(in1, in2, in3, vt) {}
 285   virtual int Opcode() const;
 286 };
 287 
 288 //------------------------------CMoveVDNode--------------------------------------
 289 // Vector double conditional move
 290 class CMoveVDNode : public VectorNode {
 291 public:
 292   CMoveVDNode(Node* in1, Node* in2, Node* in3, const TypeVect* vt) : VectorNode(in1, in2, in3, vt) {}
 293   virtual int Opcode() const;
 294 };
 295 
 296 //------------------------------MulReductionVINode--------------------------------------
 297 // Vector multiply int as a reduction
 298 class MulReductionVINode : public ReductionNode {
 299 public:
 300   MulReductionVINode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {}
 301   virtual int Opcode() const;
 302   virtual const Type* bottom_type() const { return TypeInt::INT; }
 303   virtual uint ideal_reg() const { return Op_RegI; }
 304 };
 305 
 306 //------------------------------MulReductionVLNode--------------------------------------
 307 // Vector multiply int as a reduction
 308 class MulReductionVLNode : public ReductionNode {
 309 public:
 310   MulReductionVLNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {}
 311   virtual int Opcode() const;
 312   virtual const Type* bottom_type() const { return TypeLong::LONG; }
 313   virtual uint ideal_reg() const { return Op_RegI; }
 314 };
 315 
 316 //------------------------------MulReductionVFNode--------------------------------------
 317 // Vector multiply float as a reduction
 318 class MulReductionVFNode : public ReductionNode {
 319 public:
 320   MulReductionVFNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {}
 321   virtual int Opcode() const;
 322   virtual const Type* bottom_type() const { return Type::FLOAT; }
 323   virtual uint ideal_reg() const { return Op_RegF; }
 324 };
 325 
 326 //------------------------------MulReductionVDNode--------------------------------------
 327 // Vector multiply double as a reduction
 328 class MulReductionVDNode : public ReductionNode {
 329 public:
 330   MulReductionVDNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {}
 331   virtual int Opcode() const;
 332   virtual const Type* bottom_type() const { return Type::DOUBLE; }
 333   virtual uint ideal_reg() const { return Op_RegD; }
 334 };
 335 
 336 //------------------------------DivVFNode--------------------------------------
 337 // Vector divide float
 338 class DivVFNode : public VectorNode {
 339  public:
 340   DivVFNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 341   virtual int Opcode() const;
 342 };
 343 
 344 //------------------------------DivVDNode--------------------------------------
 345 // Vector Divide double
 346 class DivVDNode : public VectorNode {
 347  public:
 348   DivVDNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 349   virtual int Opcode() const;
 350 };
 351 
 352 //------------------------------AbsVFNode--------------------------------------
 353 // Vector Abs float
 354 class AbsVFNode : public VectorNode {
 355  public:
 356   AbsVFNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {}
 357   virtual int Opcode() const;
 358 };
 359 
 360 //------------------------------AbsVDNode--------------------------------------
 361 // Vector Abs double
 362 class AbsVDNode : public VectorNode {
 363  public:
 364   AbsVDNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {}
 365   virtual int Opcode() const;
 366 };
 367 
 368 //------------------------------NegVFNode--------------------------------------
 369 // Vector Neg float
 370 class NegVFNode : public VectorNode {
 371  public:
 372   NegVFNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {}
 373   virtual int Opcode() const;
 374 };
 375 
 376 //------------------------------NegVDNode--------------------------------------
 377 // Vector Neg double
 378 class NegVDNode : public VectorNode {
 379  public:
 380   NegVDNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {}
 381   virtual int Opcode() const;
 382 };
 383 
 384 //------------------------------PopCountVINode---------------------------------
 385 // Vector popcount integer bits
 386 class PopCountVINode : public VectorNode {
 387  public:
 388   PopCountVINode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {}
 389   virtual int Opcode() const;
 390 };
 391 
 392 //------------------------------SqrtVFNode--------------------------------------
 393 // Vector Sqrt float
 394 class SqrtVFNode : public VectorNode {
 395  public:
 396   SqrtVFNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {}
 397   virtual int Opcode() const;
 398 };
 399 
 400 //------------------------------SqrtVDNode--------------------------------------
 401 // Vector Sqrt double
 402 class SqrtVDNode : public VectorNode {
 403  public:
 404   SqrtVDNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {}
 405   virtual int Opcode() const;
 406 };
 407 
 408 //------------------------------LShiftVBNode-----------------------------------
 409 // Vector left shift bytes
 410 class LShiftVBNode : public VectorNode {
 411  public:
 412   LShiftVBNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 413   virtual int Opcode() const;
 414 };
 415 
 416 //------------------------------LShiftVSNode-----------------------------------
 417 // Vector left shift shorts
 418 class LShiftVSNode : public VectorNode {
 419  public:
 420   LShiftVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 421   virtual int Opcode() const;
 422 };
 423 
 424 //------------------------------LShiftVINode-----------------------------------
 425 // Vector left shift ints
 426 class LShiftVINode : public VectorNode {
 427  public:
 428   LShiftVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 429   virtual int Opcode() const;
 430 };
 431 
 432 //------------------------------LShiftVLNode-----------------------------------
 433 // Vector left shift longs
 434 class LShiftVLNode : public VectorNode {
 435  public:
 436   LShiftVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 437   virtual int Opcode() const;
 438 };
 439 
 440 //------------------------------RShiftVBNode-----------------------------------
 441 // Vector right arithmetic (signed) shift bytes
 442 class RShiftVBNode : public VectorNode {
 443  public:
 444   RShiftVBNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 445   virtual int Opcode() const;
 446 };
 447 
 448 //------------------------------RShiftVSNode-----------------------------------
 449 // Vector right arithmetic (signed) shift shorts
 450 class RShiftVSNode : public VectorNode {
 451  public:
 452   RShiftVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 453   virtual int Opcode() const;
 454 };
 455 
 456 //------------------------------RShiftVINode-----------------------------------
 457 // Vector right arithmetic (signed) shift ints
 458 class RShiftVINode : public VectorNode {
 459  public:
 460   RShiftVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 461   virtual int Opcode() const;
 462 };
 463 
 464 //------------------------------RShiftVLNode-----------------------------------
 465 // Vector right arithmetic (signed) shift longs
 466 class RShiftVLNode : public VectorNode {
 467  public:
 468   RShiftVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 469   virtual int Opcode() const;
 470 };
 471 
 472 //------------------------------URShiftVBNode----------------------------------
 473 // Vector right logical (unsigned) shift bytes
 474 class URShiftVBNode : public VectorNode {
 475  public:
 476   URShiftVBNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 477   virtual int Opcode() const;
 478 };
 479 
 480 //------------------------------URShiftVSNode----------------------------------
 481 // Vector right logical (unsigned) shift shorts
 482 class URShiftVSNode : public VectorNode {
 483  public:
 484   URShiftVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 485   virtual int Opcode() const;
 486 };
 487 
 488 //------------------------------URShiftVINode----------------------------------
 489 // Vector right logical (unsigned) shift ints
 490 class URShiftVINode : public VectorNode {
 491  public:
 492   URShiftVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 493   virtual int Opcode() const;
 494 };
 495 
 496 //------------------------------URShiftVLNode----------------------------------
 497 // Vector right logical (unsigned) shift longs
 498 class URShiftVLNode : public VectorNode {
 499  public:
 500   URShiftVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 501   virtual int Opcode() const;
 502 };
 503 
 504 //------------------------------LShiftCntVNode---------------------------------
 505 // Vector left shift count
 506 class LShiftCntVNode : public VectorNode {
 507  public:
 508   LShiftCntVNode(Node* cnt, const TypeVect* vt) : VectorNode(cnt,vt) {}
 509   virtual int Opcode() const;
 510   virtual uint ideal_reg() const { return Matcher::vector_shift_count_ideal_reg(vect_type()->length_in_bytes()); }
 511 };
 512 
 513 //------------------------------RShiftCntVNode---------------------------------
 514 // Vector right shift count
 515 class RShiftCntVNode : public VectorNode {
 516  public:
 517   RShiftCntVNode(Node* cnt, const TypeVect* vt) : VectorNode(cnt,vt) {}
 518   virtual int Opcode() const;
 519   virtual uint ideal_reg() const { return Matcher::vector_shift_count_ideal_reg(vect_type()->length_in_bytes()); }
 520 };
 521 
 522 
 523 //------------------------------AndVNode---------------------------------------
 524 // Vector and integer
 525 class AndVNode : public VectorNode {
 526  public:
 527   AndVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 528   virtual int Opcode() const;
 529 };
 530 
 531 //------------------------------OrVNode---------------------------------------
 532 // Vector or integer
 533 class OrVNode : public VectorNode {
 534  public:
 535   OrVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 536   virtual int Opcode() const;
 537 };
 538 
 539 //------------------------------XorVNode---------------------------------------
 540 // Vector xor integer
 541 class XorVNode : public VectorNode {
 542  public:
 543   XorVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 544   virtual int Opcode() const;
 545 };
 546 
 547 //================================= M E M O R Y ===============================
 548 
 549 //------------------------------LoadVectorNode---------------------------------
 550 // Load Vector from memory
 551 class LoadVectorNode : public LoadNode {
 552  public:
 553   LoadVectorNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeVect* vt, ControlDependency control_dependency = LoadNode::DependsOnlyOnTest)
 554     : LoadNode(c, mem, adr, at, vt, MemNode::unordered, control_dependency) {
 555     init_class_id(Class_LoadVector);
 556     set_mismatched_access();
 557   }
 558 
 559   const TypeVect* vect_type() const { return type()->is_vect(); }
 560   uint length() const { return vect_type()->length(); } // Vector length
 561 
 562   virtual int Opcode() const;
 563 
 564   virtual uint ideal_reg() const  { return Matcher::vector_ideal_reg(memory_size()); }
 565   virtual BasicType memory_type() const { return T_VOID; }
 566   virtual int memory_size() const { return vect_type()->length_in_bytes(); }
 567 
 568   virtual int store_Opcode() const { return Op_StoreVector; }
 569 
 570   static LoadVectorNode* make(int opc, Node* ctl, Node* mem,
 571                               Node* adr, const TypePtr* atyp,
 572                               uint vlen, BasicType bt,
 573                               ControlDependency control_dependency = LoadNode::DependsOnlyOnTest);
 574   uint element_size(void) { return type2aelembytes(vect_type()->element_basic_type()); }
 575 };
 576 
 577 //------------------------------StoreVectorNode--------------------------------
 578 // Store Vector to memory
 579 class StoreVectorNode : public StoreNode {
 580  public:
 581   StoreVectorNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val)
 582     : StoreNode(c, mem, adr, at, val, MemNode::unordered) {
 583     assert(val->is_Vector() || val->is_LoadVector(), "sanity");
 584     init_class_id(Class_StoreVector);
 585     set_mismatched_access();
 586   }
 587 
 588   const TypeVect* vect_type() const { return in(MemNode::ValueIn)->bottom_type()->is_vect(); }
 589   uint length() const { return vect_type()->length(); } // Vector length
 590 
 591   virtual int Opcode() const;
 592 
 593   virtual uint ideal_reg() const  { return Matcher::vector_ideal_reg(memory_size()); }
 594   virtual BasicType memory_type() const { return T_VOID; }
 595   virtual int memory_size() const { return vect_type()->length_in_bytes(); }
 596 
 597   static StoreVectorNode* make(int opc, Node* ctl, Node* mem,
 598                                Node* adr, const TypePtr* atyp, Node* val,
 599                                uint vlen);
 600 
 601   uint element_size(void) { return type2aelembytes(vect_type()->element_basic_type()); }
 602 };
 603 
 604 
 605 //=========================Promote_Scalar_to_Vector============================
 606 
 607 //------------------------------ReplicateBNode---------------------------------
 608 // Replicate byte scalar to be vector
 609 class ReplicateBNode : public VectorNode {
 610  public:
 611   ReplicateBNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {}
 612   virtual int Opcode() const;
 613 };
 614 
 615 //------------------------------ReplicateSNode---------------------------------
 616 // Replicate short scalar to be vector
 617 class ReplicateSNode : public VectorNode {
 618  public:
 619   ReplicateSNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {}
 620   virtual int Opcode() const;
 621 };
 622 
 623 //------------------------------ReplicateINode---------------------------------
 624 // Replicate int scalar to be vector
 625 class ReplicateINode : public VectorNode {
 626  public:
 627   ReplicateINode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {}
 628   virtual int Opcode() const;
 629 };
 630 
 631 //------------------------------ReplicateLNode---------------------------------
 632 // Replicate long scalar to be vector
 633 class ReplicateLNode : public VectorNode {
 634  public:
 635   ReplicateLNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {}
 636   virtual int Opcode() const;
 637 };
 638 
 639 //------------------------------ReplicateFNode---------------------------------
 640 // Replicate float scalar to be vector
 641 class ReplicateFNode : public VectorNode {
 642  public:
 643   ReplicateFNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {}
 644   virtual int Opcode() const;
 645 };
 646 
 647 //------------------------------ReplicateDNode---------------------------------
 648 // Replicate double scalar to be vector
 649 class ReplicateDNode : public VectorNode {
 650  public:
 651   ReplicateDNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {}
 652   virtual int Opcode() const;
 653 };
 654 
 655 //========================Pack_Scalars_into_a_Vector===========================
 656 
 657 //------------------------------PackNode---------------------------------------
 658 // Pack parent class (not for code generation).
 659 class PackNode : public VectorNode {
 660  public:
 661   PackNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {}
 662   PackNode(Node* in1, Node* n2, const TypeVect* vt) : VectorNode(in1, n2, vt) {}
 663   virtual int Opcode() const;
 664 
 665   void add_opd(Node* n) {
 666     add_req(n);
 667   }
 668 
 669   // Create a binary tree form for Packs. [lo, hi) (half-open) range
 670   PackNode* binary_tree_pack(int lo, int hi);
 671 
 672   static PackNode* make(Node* s, uint vlen, BasicType bt);
 673 };
 674 
 675 //------------------------------PackBNode--------------------------------------
 676 // Pack byte scalars into vector
 677 class PackBNode : public PackNode {
 678  public:
 679   PackBNode(Node* in1, const TypeVect* vt)  : PackNode(in1, vt) {}
 680   virtual int Opcode() const;
 681 };
 682 
 683 //------------------------------PackSNode--------------------------------------
 684 // Pack short scalars into a vector
 685 class PackSNode : public PackNode {
 686  public:
 687   PackSNode(Node* in1, const TypeVect* vt)  : PackNode(in1, vt) {}
 688   PackSNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {}
 689   virtual int Opcode() const;
 690 };
 691 
 692 //------------------------------PackINode--------------------------------------
 693 // Pack integer scalars into a vector
 694 class PackINode : public PackNode {
 695  public:
 696   PackINode(Node* in1, const TypeVect* vt)  : PackNode(in1, vt) {}
 697   PackINode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {}
 698   virtual int Opcode() const;
 699 };
 700 
 701 //------------------------------PackLNode--------------------------------------
 702 // Pack long scalars into a vector
 703 class PackLNode : public PackNode {
 704  public:
 705   PackLNode(Node* in1, const TypeVect* vt)  : PackNode(in1, vt) {}
 706   PackLNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {}
 707   virtual int Opcode() const;
 708 };
 709 
 710 //------------------------------Pack2LNode-------------------------------------
 711 // Pack 2 long scalars into a vector
 712 class Pack2LNode : public PackNode {
 713  public:
 714   Pack2LNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {}
 715   virtual int Opcode() const;
 716 };
 717 
 718 //------------------------------PackFNode--------------------------------------
 719 // Pack float scalars into vector
 720 class PackFNode : public PackNode {
 721  public:
 722   PackFNode(Node* in1, const TypeVect* vt)  : PackNode(in1, vt) {}
 723   PackFNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {}
 724   virtual int Opcode() const;
 725 };
 726 
 727 //------------------------------PackDNode--------------------------------------
 728 // Pack double scalars into a vector
 729 class PackDNode : public PackNode {
 730  public:
 731   PackDNode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {}
 732   PackDNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {}
 733   virtual int Opcode() const;
 734 };
 735 
 736 //------------------------------Pack2DNode-------------------------------------
 737 // Pack 2 double scalars into a vector
 738 class Pack2DNode : public PackNode {
 739  public:
 740   Pack2DNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {}
 741   virtual int Opcode() const;
 742 };
 743 
 744 
 745 //========================Extract_Scalar_from_Vector===========================
 746 
 747 //------------------------------ExtractNode------------------------------------
 748 // Extract a scalar from a vector at position "pos"
 749 class ExtractNode : public Node {
 750  public:
 751   ExtractNode(Node* src, ConINode* pos) : Node(NULL, src, (Node*)pos) {
 752     assert(in(2)->get_int() >= 0, "positive constants");
 753   }
 754   virtual int Opcode() const;
 755   uint  pos() const { return in(2)->get_int(); }
 756 
 757   static Node* make(Node* v, uint position, BasicType bt);
 758 };
 759 
 760 //------------------------------ExtractBNode-----------------------------------
 761 // Extract a byte from a vector at position "pos"
 762 class ExtractBNode : public ExtractNode {
 763  public:
 764   ExtractBNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
 765   virtual int Opcode() const;
 766   virtual const Type *bottom_type() const { return TypeInt::INT; }
 767   virtual uint ideal_reg() const { return Op_RegI; }
 768 };
 769 
 770 //------------------------------ExtractUBNode----------------------------------
 771 // Extract a boolean from a vector at position "pos"
 772 class ExtractUBNode : public ExtractNode {
 773  public:
 774   ExtractUBNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
 775   virtual int Opcode() const;
 776   virtual const Type *bottom_type() const { return TypeInt::INT; }
 777   virtual uint ideal_reg() const { return Op_RegI; }
 778 };
 779 
 780 //------------------------------ExtractCNode-----------------------------------
 781 // Extract a char from a vector at position "pos"
 782 class ExtractCNode : public ExtractNode {
 783  public:
 784   ExtractCNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
 785   virtual int Opcode() const;
 786   virtual const Type *bottom_type() const { return TypeInt::INT; }
 787   virtual uint ideal_reg() const { return Op_RegI; }
 788 };
 789 
 790 //------------------------------ExtractSNode-----------------------------------
 791 // Extract a short from a vector at position "pos"
 792 class ExtractSNode : public ExtractNode {
 793  public:
 794   ExtractSNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
 795   virtual int Opcode() const;
 796   virtual const Type *bottom_type() const { return TypeInt::INT; }
 797   virtual uint ideal_reg() const { return Op_RegI; }
 798 };
 799 
 800 //------------------------------ExtractINode-----------------------------------
 801 // Extract an int from a vector at position "pos"
 802 class ExtractINode : public ExtractNode {
 803  public:
 804   ExtractINode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
 805   virtual int Opcode() const;
 806   virtual const Type *bottom_type() const { return TypeInt::INT; }
 807   virtual uint ideal_reg() const { return Op_RegI; }
 808 };
 809 
 810 //------------------------------ExtractLNode-----------------------------------
 811 // Extract a long from a vector at position "pos"
 812 class ExtractLNode : public ExtractNode {
 813  public:
 814   ExtractLNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
 815   virtual int Opcode() const;
 816   virtual const Type *bottom_type() const { return TypeLong::LONG; }
 817   virtual uint ideal_reg() const { return Op_RegL; }
 818 };
 819 
 820 //------------------------------ExtractFNode-----------------------------------
 821 // Extract a float from a vector at position "pos"
 822 class ExtractFNode : public ExtractNode {
 823  public:
 824   ExtractFNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
 825   virtual int Opcode() const;
 826   virtual const Type *bottom_type() const { return Type::FLOAT; }
 827   virtual uint ideal_reg() const { return Op_RegF; }
 828 };
 829 
 830 //------------------------------ExtractDNode-----------------------------------
 831 // Extract a double from a vector at position "pos"
 832 class ExtractDNode : public ExtractNode {
 833  public:
 834   ExtractDNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
 835   virtual int Opcode() const;
 836   virtual const Type *bottom_type() const { return Type::DOUBLE; }
 837   virtual uint ideal_reg() const { return Op_RegD; }
 838 };
 839 
 840 //------------------------------SetVectMaskINode-------------------------------
 841 // Provide a mask for a vector predicate machine
 842 class SetVectMaskINode : public Node {
 843 public:
 844   SetVectMaskINode(Node *c, Node *in1) : Node(c, in1) {}
 845   virtual int Opcode() const;
 846   const Type *bottom_type() const { return TypeInt::INT; }
 847   virtual uint ideal_reg() const { return Op_RegI; }
 848   virtual const Type *Value(PhaseGVN *phase) const { return TypeInt::INT; }
 849 };
 850 
 851 #endif // SHARE_VM_OPTO_VECTORNODE_HPP