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 //------------------------------CMoveVDNode--------------------------------------
 281 // Vector multiply double
 282 class CMoveVDNode : public VectorNode {
 283 public:
 284   CMoveVDNode(Node* in1, Node* in2, Node* in3, const TypeVect* vt) : VectorNode(in1, in2, in3, vt) {}
 285   virtual int Opcode() const;
 286 };
 287 
 288 //------------------------------MulReductionVINode--------------------------------------
 289 // Vector multiply int as a reduction
 290 class MulReductionVINode : public ReductionNode {
 291 public:
 292   MulReductionVINode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {}
 293   virtual int Opcode() const;
 294   virtual const Type* bottom_type() const { return TypeInt::INT; }
 295   virtual uint ideal_reg() const { return Op_RegI; }
 296 };
 297 
 298 //------------------------------MulReductionVLNode--------------------------------------
 299 // Vector multiply int as a reduction
 300 class MulReductionVLNode : public ReductionNode {
 301 public:
 302   MulReductionVLNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {}
 303   virtual int Opcode() const;
 304   virtual const Type* bottom_type() const { return TypeLong::LONG; }
 305   virtual uint ideal_reg() const { return Op_RegI; }
 306 };
 307 
 308 //------------------------------MulReductionVFNode--------------------------------------
 309 // Vector multiply float as a reduction
 310 class MulReductionVFNode : public ReductionNode {
 311 public:
 312   MulReductionVFNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {}
 313   virtual int Opcode() const;
 314   virtual const Type* bottom_type() const { return Type::FLOAT; }
 315   virtual uint ideal_reg() const { return Op_RegF; }
 316 };
 317 
 318 //------------------------------MulReductionVDNode--------------------------------------
 319 // Vector multiply double as a reduction
 320 class MulReductionVDNode : public ReductionNode {
 321 public:
 322   MulReductionVDNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {}
 323   virtual int Opcode() const;
 324   virtual const Type* bottom_type() const { return Type::DOUBLE; }
 325   virtual uint ideal_reg() const { return Op_RegD; }
 326 };
 327 
 328 //------------------------------DivVFNode--------------------------------------
 329 // Vector divide float
 330 class DivVFNode : public VectorNode {
 331  public:
 332   DivVFNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 333   virtual int Opcode() const;
 334 };
 335 
 336 //------------------------------DivVDNode--------------------------------------
 337 // Vector Divide double
 338 class DivVDNode : public VectorNode {
 339  public:
 340   DivVDNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 341   virtual int Opcode() const;
 342 };
 343 
 344 //------------------------------AbsVFNode--------------------------------------
 345 // Vector Abs float
 346 class AbsVFNode : public VectorNode {
 347  public:
 348   AbsVFNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {}
 349   virtual int Opcode() const;
 350 };
 351 
 352 //------------------------------AbsVDNode--------------------------------------
 353 // Vector Abs double
 354 class AbsVDNode : public VectorNode {
 355  public:
 356   AbsVDNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {}
 357   virtual int Opcode() const;
 358 };
 359 
 360 //------------------------------NegVFNode--------------------------------------
 361 // Vector Neg float
 362 class NegVFNode : public VectorNode {
 363  public:
 364   NegVFNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {}
 365   virtual int Opcode() const;
 366 };
 367 
 368 //------------------------------NegVDNode--------------------------------------
 369 // Vector Neg double
 370 class NegVDNode : public VectorNode {
 371  public:
 372   NegVDNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {}
 373   virtual int Opcode() const;
 374 };
 375 
 376 //------------------------------SqrtVFNode--------------------------------------
 377 // Vector Sqrt float
 378 class SqrtVFNode : public VectorNode {
 379  public:
 380   SqrtVFNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {}
 381   virtual int Opcode() const;
 382 };
 383 
 384 //------------------------------SqrtVDNode--------------------------------------
 385 // Vector Sqrt double
 386 class SqrtVDNode : public VectorNode {
 387  public:
 388   SqrtVDNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {}
 389   virtual int Opcode() const;
 390 };
 391 
 392 //------------------------------LShiftVBNode-----------------------------------
 393 // Vector left shift bytes
 394 class LShiftVBNode : public VectorNode {
 395  public:
 396   LShiftVBNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 397   virtual int Opcode() const;
 398 };
 399 
 400 //------------------------------LShiftVSNode-----------------------------------
 401 // Vector left shift shorts
 402 class LShiftVSNode : public VectorNode {
 403  public:
 404   LShiftVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 405   virtual int Opcode() const;
 406 };
 407 
 408 //------------------------------LShiftVINode-----------------------------------
 409 // Vector left shift ints
 410 class LShiftVINode : public VectorNode {
 411  public:
 412   LShiftVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 413   virtual int Opcode() const;
 414 };
 415 
 416 //------------------------------LShiftVLNode-----------------------------------
 417 // Vector left shift longs
 418 class LShiftVLNode : public VectorNode {
 419  public:
 420   LShiftVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 421   virtual int Opcode() const;
 422 };
 423 
 424 //------------------------------RShiftVBNode-----------------------------------
 425 // Vector right arithmetic (signed) shift bytes
 426 class RShiftVBNode : public VectorNode {
 427  public:
 428   RShiftVBNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 429   virtual int Opcode() const;
 430 };
 431 
 432 //------------------------------RShiftVSNode-----------------------------------
 433 // Vector right arithmetic (signed) shift shorts
 434 class RShiftVSNode : public VectorNode {
 435  public:
 436   RShiftVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 437   virtual int Opcode() const;
 438 };
 439 
 440 //------------------------------RShiftVINode-----------------------------------
 441 // Vector right arithmetic (signed) shift ints
 442 class RShiftVINode : public VectorNode {
 443  public:
 444   RShiftVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 445   virtual int Opcode() const;
 446 };
 447 
 448 //------------------------------RShiftVLNode-----------------------------------
 449 // Vector right arithmetic (signed) shift longs
 450 class RShiftVLNode : public VectorNode {
 451  public:
 452   RShiftVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 453   virtual int Opcode() const;
 454 };
 455 
 456 //------------------------------URShiftVBNode----------------------------------
 457 // Vector right logical (unsigned) shift bytes
 458 class URShiftVBNode : public VectorNode {
 459  public:
 460   URShiftVBNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 461   virtual int Opcode() const;
 462 };
 463 
 464 //------------------------------URShiftVSNode----------------------------------
 465 // Vector right logical (unsigned) shift shorts
 466 class URShiftVSNode : public VectorNode {
 467  public:
 468   URShiftVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 469   virtual int Opcode() const;
 470 };
 471 
 472 //------------------------------URShiftVINode----------------------------------
 473 // Vector right logical (unsigned) shift ints
 474 class URShiftVINode : public VectorNode {
 475  public:
 476   URShiftVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 477   virtual int Opcode() const;
 478 };
 479 
 480 //------------------------------URShiftVLNode----------------------------------
 481 // Vector right logical (unsigned) shift longs
 482 class URShiftVLNode : public VectorNode {
 483  public:
 484   URShiftVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 485   virtual int Opcode() const;
 486 };
 487 
 488 //------------------------------LShiftCntVNode---------------------------------
 489 // Vector left shift count
 490 class LShiftCntVNode : public VectorNode {
 491  public:
 492   LShiftCntVNode(Node* cnt, const TypeVect* vt) : VectorNode(cnt,vt) {}
 493   virtual int Opcode() const;
 494   virtual uint ideal_reg() const { return Matcher::vector_shift_count_ideal_reg(vect_type()->length_in_bytes()); }
 495 };
 496 
 497 //------------------------------RShiftCntVNode---------------------------------
 498 // Vector right shift count
 499 class RShiftCntVNode : public VectorNode {
 500  public:
 501   RShiftCntVNode(Node* cnt, const TypeVect* vt) : VectorNode(cnt,vt) {}
 502   virtual int Opcode() const;
 503   virtual uint ideal_reg() const { return Matcher::vector_shift_count_ideal_reg(vect_type()->length_in_bytes()); }
 504 };
 505 
 506 
 507 //------------------------------AndVNode---------------------------------------
 508 // Vector and integer
 509 class AndVNode : public VectorNode {
 510  public:
 511   AndVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 512   virtual int Opcode() const;
 513 };
 514 
 515 //------------------------------OrVNode---------------------------------------
 516 // Vector or integer
 517 class OrVNode : public VectorNode {
 518  public:
 519   OrVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 520   virtual int Opcode() const;
 521 };
 522 
 523 //------------------------------XorVNode---------------------------------------
 524 // Vector xor integer
 525 class XorVNode : public VectorNode {
 526  public:
 527   XorVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {}
 528   virtual int Opcode() const;
 529 };
 530 
 531 //================================= M E M O R Y ===============================
 532 
 533 //------------------------------LoadVectorNode---------------------------------
 534 // Load Vector from memory
 535 class LoadVectorNode : public LoadNode {
 536  public:
 537   LoadVectorNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeVect* vt, ControlDependency control_dependency = LoadNode::DependsOnlyOnTest)
 538     : LoadNode(c, mem, adr, at, vt, MemNode::unordered, control_dependency) {
 539     init_class_id(Class_LoadVector);
 540   }
 541 
 542   const TypeVect* vect_type() const { return type()->is_vect(); }
 543   uint length() const { return vect_type()->length(); } // Vector length
 544 
 545   virtual int Opcode() const;
 546 
 547   virtual uint ideal_reg() const  { return Matcher::vector_ideal_reg(memory_size()); }
 548   virtual BasicType memory_type() const { return T_VOID; }
 549   virtual int memory_size() const { return vect_type()->length_in_bytes(); }
 550 
 551   virtual int store_Opcode() const { return Op_StoreVector; }
 552 
 553   static LoadVectorNode* make(int opc, Node* ctl, Node* mem,
 554                               Node* adr, const TypePtr* atyp,
 555                               uint vlen, BasicType bt,
 556                               ControlDependency control_dependency = LoadNode::DependsOnlyOnTest);
 557   uint element_size(void) { return type2aelembytes(vect_type()->element_basic_type()); }
 558 };
 559 
 560 //------------------------------StoreVectorNode--------------------------------
 561 // Store Vector to memory
 562 class StoreVectorNode : public StoreNode {
 563  public:
 564   StoreVectorNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val)
 565     : StoreNode(c, mem, adr, at, val, MemNode::unordered) {
 566     assert(val->is_Vector() || val->is_LoadVector(), "sanity");
 567     init_class_id(Class_StoreVector);
 568   }
 569 
 570   const TypeVect* vect_type() const { return in(MemNode::ValueIn)->bottom_type()->is_vect(); }
 571   uint length() const { return vect_type()->length(); } // Vector length
 572 
 573   virtual int Opcode() const;
 574 
 575   virtual uint ideal_reg() const  { return Matcher::vector_ideal_reg(memory_size()); }
 576   virtual BasicType memory_type() const { return T_VOID; }
 577   virtual int memory_size() const { return vect_type()->length_in_bytes(); }
 578 
 579   static StoreVectorNode* make(int opc, Node* ctl, Node* mem,
 580                                Node* adr, const TypePtr* atyp, Node* val,
 581                                uint vlen);
 582 
 583   uint element_size(void) { return type2aelembytes(vect_type()->element_basic_type()); }
 584 };
 585 
 586 
 587 //=========================Promote_Scalar_to_Vector============================
 588 
 589 //------------------------------ReplicateBNode---------------------------------
 590 // Replicate byte scalar to be vector
 591 class ReplicateBNode : public VectorNode {
 592  public:
 593   ReplicateBNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {}
 594   virtual int Opcode() const;
 595 };
 596 
 597 //------------------------------ReplicateSNode---------------------------------
 598 // Replicate short scalar to be vector
 599 class ReplicateSNode : public VectorNode {
 600  public:
 601   ReplicateSNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {}
 602   virtual int Opcode() const;
 603 };
 604 
 605 //------------------------------ReplicateINode---------------------------------
 606 // Replicate int scalar to be vector
 607 class ReplicateINode : public VectorNode {
 608  public:
 609   ReplicateINode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {}
 610   virtual int Opcode() const;
 611 };
 612 
 613 //------------------------------ReplicateLNode---------------------------------
 614 // Replicate long scalar to be vector
 615 class ReplicateLNode : public VectorNode {
 616  public:
 617   ReplicateLNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {}
 618   virtual int Opcode() const;
 619 };
 620 
 621 //------------------------------ReplicateFNode---------------------------------
 622 // Replicate float scalar to be vector
 623 class ReplicateFNode : public VectorNode {
 624  public:
 625   ReplicateFNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {}
 626   virtual int Opcode() const;
 627 };
 628 
 629 //------------------------------ReplicateDNode---------------------------------
 630 // Replicate double scalar to be vector
 631 class ReplicateDNode : public VectorNode {
 632  public:
 633   ReplicateDNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {}
 634   virtual int Opcode() const;
 635 };
 636 
 637 //========================Pack_Scalars_into_a_Vector===========================
 638 
 639 //------------------------------PackNode---------------------------------------
 640 // Pack parent class (not for code generation).
 641 class PackNode : public VectorNode {
 642  public:
 643   PackNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {}
 644   PackNode(Node* in1, Node* n2, const TypeVect* vt) : VectorNode(in1, n2, vt) {}
 645   virtual int Opcode() const;
 646 
 647   void add_opd(Node* n) {
 648     add_req(n);
 649   }
 650 
 651   // Create a binary tree form for Packs. [lo, hi) (half-open) range
 652   PackNode* binary_tree_pack(int lo, int hi);
 653 
 654   static PackNode* make(Node* s, uint vlen, BasicType bt);
 655 };
 656 
 657 //------------------------------PackBNode--------------------------------------
 658 // Pack byte scalars into vector
 659 class PackBNode : public PackNode {
 660  public:
 661   PackBNode(Node* in1, const TypeVect* vt)  : PackNode(in1, vt) {}
 662   virtual int Opcode() const;
 663 };
 664 
 665 //------------------------------PackSNode--------------------------------------
 666 // Pack short scalars into a vector
 667 class PackSNode : public PackNode {
 668  public:
 669   PackSNode(Node* in1, const TypeVect* vt)  : PackNode(in1, vt) {}
 670   PackSNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {}
 671   virtual int Opcode() const;
 672 };
 673 
 674 //------------------------------PackINode--------------------------------------
 675 // Pack integer scalars into a vector
 676 class PackINode : public PackNode {
 677  public:
 678   PackINode(Node* in1, const TypeVect* vt)  : PackNode(in1, vt) {}
 679   PackINode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {}
 680   virtual int Opcode() const;
 681 };
 682 
 683 //------------------------------PackLNode--------------------------------------
 684 // Pack long scalars into a vector
 685 class PackLNode : public PackNode {
 686  public:
 687   PackLNode(Node* in1, const TypeVect* vt)  : PackNode(in1, vt) {}
 688   PackLNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {}
 689   virtual int Opcode() const;
 690 };
 691 
 692 //------------------------------Pack2LNode-------------------------------------
 693 // Pack 2 long scalars into a vector
 694 class Pack2LNode : public PackNode {
 695  public:
 696   Pack2LNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {}
 697   virtual int Opcode() const;
 698 };
 699 
 700 //------------------------------PackFNode--------------------------------------
 701 // Pack float scalars into vector
 702 class PackFNode : public PackNode {
 703  public:
 704   PackFNode(Node* in1, const TypeVect* vt)  : PackNode(in1, vt) {}
 705   PackFNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {}
 706   virtual int Opcode() const;
 707 };
 708 
 709 //------------------------------PackDNode--------------------------------------
 710 // Pack double scalars into a vector
 711 class PackDNode : public PackNode {
 712  public:
 713   PackDNode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {}
 714   PackDNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {}
 715   virtual int Opcode() const;
 716 };
 717 
 718 //------------------------------Pack2DNode-------------------------------------
 719 // Pack 2 double scalars into a vector
 720 class Pack2DNode : public PackNode {
 721  public:
 722   Pack2DNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {}
 723   virtual int Opcode() const;
 724 };
 725 
 726 
 727 //========================Extract_Scalar_from_Vector===========================
 728 
 729 //------------------------------ExtractNode------------------------------------
 730 // Extract a scalar from a vector at position "pos"
 731 class ExtractNode : public Node {
 732  public:
 733   ExtractNode(Node* src, ConINode* pos) : Node(NULL, src, (Node*)pos) {
 734     assert(in(2)->get_int() >= 0, "positive constants");
 735   }
 736   virtual int Opcode() const;
 737   uint  pos() const { return in(2)->get_int(); }
 738 
 739   static Node* make(Node* v, uint position, BasicType bt);
 740 };
 741 
 742 //------------------------------ExtractBNode-----------------------------------
 743 // Extract a byte from a vector at position "pos"
 744 class ExtractBNode : public ExtractNode {
 745  public:
 746   ExtractBNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
 747   virtual int Opcode() const;
 748   virtual const Type *bottom_type() const { return TypeInt::INT; }
 749   virtual uint ideal_reg() const { return Op_RegI; }
 750 };
 751 
 752 //------------------------------ExtractUBNode----------------------------------
 753 // Extract a boolean from a vector at position "pos"
 754 class ExtractUBNode : public ExtractNode {
 755  public:
 756   ExtractUBNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
 757   virtual int Opcode() const;
 758   virtual const Type *bottom_type() const { return TypeInt::INT; }
 759   virtual uint ideal_reg() const { return Op_RegI; }
 760 };
 761 
 762 //------------------------------ExtractCNode-----------------------------------
 763 // Extract a char from a vector at position "pos"
 764 class ExtractCNode : public ExtractNode {
 765  public:
 766   ExtractCNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
 767   virtual int Opcode() const;
 768   virtual const Type *bottom_type() const { return TypeInt::INT; }
 769   virtual uint ideal_reg() const { return Op_RegI; }
 770 };
 771 
 772 //------------------------------ExtractSNode-----------------------------------
 773 // Extract a short from a vector at position "pos"
 774 class ExtractSNode : public ExtractNode {
 775  public:
 776   ExtractSNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
 777   virtual int Opcode() const;
 778   virtual const Type *bottom_type() const { return TypeInt::INT; }
 779   virtual uint ideal_reg() const { return Op_RegI; }
 780 };
 781 
 782 //------------------------------ExtractINode-----------------------------------
 783 // Extract an int from a vector at position "pos"
 784 class ExtractINode : public ExtractNode {
 785  public:
 786   ExtractINode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
 787   virtual int Opcode() const;
 788   virtual const Type *bottom_type() const { return TypeInt::INT; }
 789   virtual uint ideal_reg() const { return Op_RegI; }
 790 };
 791 
 792 //------------------------------ExtractLNode-----------------------------------
 793 // Extract a long from a vector at position "pos"
 794 class ExtractLNode : public ExtractNode {
 795  public:
 796   ExtractLNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
 797   virtual int Opcode() const;
 798   virtual const Type *bottom_type() const { return TypeLong::LONG; }
 799   virtual uint ideal_reg() const { return Op_RegL; }
 800 };
 801 
 802 //------------------------------ExtractFNode-----------------------------------
 803 // Extract a float from a vector at position "pos"
 804 class ExtractFNode : public ExtractNode {
 805  public:
 806   ExtractFNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
 807   virtual int Opcode() const;
 808   virtual const Type *bottom_type() const { return Type::FLOAT; }
 809   virtual uint ideal_reg() const { return Op_RegF; }
 810 };
 811 
 812 //------------------------------ExtractDNode-----------------------------------
 813 // Extract a double from a vector at position "pos"
 814 class ExtractDNode : public ExtractNode {
 815  public:
 816   ExtractDNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
 817   virtual int Opcode() const;
 818   virtual const Type *bottom_type() const { return Type::DOUBLE; }
 819   virtual uint ideal_reg() const { return Op_RegD; }
 820 };
 821 
 822 //------------------------------SetVectMaskINode-------------------------------
 823 // Provide a mask for a vector predicate machine
 824 class SetVectMaskINode : public Node {
 825 public:
 826   SetVectMaskINode(Node *c, Node *in1) : Node(c, in1) {}
 827   virtual int Opcode() const;
 828   const Type *bottom_type() const { return TypeInt::INT; }
 829   virtual uint ideal_reg() const { return Op_RegI; }
 830   virtual const Type *Value(PhaseGVN *phase) const { return TypeInt::INT; }
 831 };
 832 
 833 #endif // SHARE_VM_OPTO_VECTORNODE_HPP