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