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 } 557 558 const TypeVect* vect_type() const { return type()->is_vect(); } 559 uint length() const { return vect_type()->length(); } // Vector length 560 561 virtual int Opcode() const; 562 563 virtual uint ideal_reg() const { return Matcher::vector_ideal_reg(memory_size()); } 564 virtual BasicType memory_type() const { return T_VOID; } 565 virtual int memory_size() const { return vect_type()->length_in_bytes(); } 566 567 virtual int store_Opcode() const { return Op_StoreVector; } 568 569 static LoadVectorNode* make(int opc, Node* ctl, Node* mem, 570 Node* adr, const TypePtr* atyp, 571 uint vlen, BasicType bt, 572 ControlDependency control_dependency = LoadNode::DependsOnlyOnTest); 573 uint element_size(void) { return type2aelembytes(vect_type()->element_basic_type()); } 574 }; 575 576 //------------------------------StoreVectorNode-------------------------------- 577 // Store Vector to memory 578 class StoreVectorNode : public StoreNode { 579 public: 580 StoreVectorNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val) 581 : StoreNode(c, mem, adr, at, val, MemNode::unordered) { 582 assert(val->is_Vector() || val->is_LoadVector(), "sanity"); 583 init_class_id(Class_StoreVector); 584 } 585 586 const TypeVect* vect_type() const { return in(MemNode::ValueIn)->bottom_type()->is_vect(); } 587 uint length() const { return vect_type()->length(); } // Vector length 588 589 virtual int Opcode() const; 590 591 virtual uint ideal_reg() const { return Matcher::vector_ideal_reg(memory_size()); } 592 virtual BasicType memory_type() const { return T_VOID; } 593 virtual int memory_size() const { return vect_type()->length_in_bytes(); } 594 595 static StoreVectorNode* make(int opc, Node* ctl, Node* mem, 596 Node* adr, const TypePtr* atyp, Node* val, 597 uint vlen); 598 599 uint element_size(void) { return type2aelembytes(vect_type()->element_basic_type()); } 600 }; 601 602 603 //=========================Promote_Scalar_to_Vector============================ 604 605 //------------------------------ReplicateBNode--------------------------------- 606 // Replicate byte scalar to be vector 607 class ReplicateBNode : public VectorNode { 608 public: 609 ReplicateBNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 610 virtual int Opcode() const; 611 }; 612 613 //------------------------------ReplicateSNode--------------------------------- 614 // Replicate short scalar to be vector 615 class ReplicateSNode : public VectorNode { 616 public: 617 ReplicateSNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 618 virtual int Opcode() const; 619 }; 620 621 //------------------------------ReplicateINode--------------------------------- 622 // Replicate int scalar to be vector 623 class ReplicateINode : public VectorNode { 624 public: 625 ReplicateINode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 626 virtual int Opcode() const; 627 }; 628 629 //------------------------------ReplicateLNode--------------------------------- 630 // Replicate long scalar to be vector 631 class ReplicateLNode : public VectorNode { 632 public: 633 ReplicateLNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 634 virtual int Opcode() const; 635 }; 636 637 //------------------------------ReplicateFNode--------------------------------- 638 // Replicate float scalar to be vector 639 class ReplicateFNode : public VectorNode { 640 public: 641 ReplicateFNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 642 virtual int Opcode() const; 643 }; 644 645 //------------------------------ReplicateDNode--------------------------------- 646 // Replicate double scalar to be vector 647 class ReplicateDNode : public VectorNode { 648 public: 649 ReplicateDNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 650 virtual int Opcode() const; 651 }; 652 653 //========================Pack_Scalars_into_a_Vector=========================== 654 655 //------------------------------PackNode--------------------------------------- 656 // Pack parent class (not for code generation). 657 class PackNode : public VectorNode { 658 public: 659 PackNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 660 PackNode(Node* in1, Node* n2, const TypeVect* vt) : VectorNode(in1, n2, vt) {} 661 virtual int Opcode() const; 662 663 void add_opd(Node* n) { 664 add_req(n); 665 } 666 667 // Create a binary tree form for Packs. [lo, hi) (half-open) range 668 PackNode* binary_tree_pack(int lo, int hi); 669 670 static PackNode* make(Node* s, uint vlen, BasicType bt); 671 }; 672 673 //------------------------------PackBNode-------------------------------------- 674 // Pack byte scalars into vector 675 class PackBNode : public PackNode { 676 public: 677 PackBNode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} 678 virtual int Opcode() const; 679 }; 680 681 //------------------------------PackSNode-------------------------------------- 682 // Pack short scalars into a vector 683 class PackSNode : public PackNode { 684 public: 685 PackSNode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} 686 PackSNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 687 virtual int Opcode() const; 688 }; 689 690 //------------------------------PackINode-------------------------------------- 691 // Pack integer scalars into a vector 692 class PackINode : public PackNode { 693 public: 694 PackINode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} 695 PackINode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 696 virtual int Opcode() const; 697 }; 698 699 //------------------------------PackLNode-------------------------------------- 700 // Pack long scalars into a vector 701 class PackLNode : public PackNode { 702 public: 703 PackLNode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} 704 PackLNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 705 virtual int Opcode() const; 706 }; 707 708 //------------------------------Pack2LNode------------------------------------- 709 // Pack 2 long scalars into a vector 710 class Pack2LNode : public PackNode { 711 public: 712 Pack2LNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 713 virtual int Opcode() const; 714 }; 715 716 //------------------------------PackFNode-------------------------------------- 717 // Pack float scalars into vector 718 class PackFNode : public PackNode { 719 public: 720 PackFNode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} 721 PackFNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 722 virtual int Opcode() const; 723 }; 724 725 //------------------------------PackDNode-------------------------------------- 726 // Pack double scalars into a vector 727 class PackDNode : public PackNode { 728 public: 729 PackDNode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} 730 PackDNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 731 virtual int Opcode() const; 732 }; 733 734 //------------------------------Pack2DNode------------------------------------- 735 // Pack 2 double scalars into a vector 736 class Pack2DNode : public PackNode { 737 public: 738 Pack2DNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 739 virtual int Opcode() const; 740 }; 741 742 743 //========================Extract_Scalar_from_Vector=========================== 744 745 //------------------------------ExtractNode------------------------------------ 746 // Extract a scalar from a vector at position "pos" 747 class ExtractNode : public Node { 748 public: 749 ExtractNode(Node* src, ConINode* pos) : Node(NULL, src, (Node*)pos) { 750 assert(in(2)->get_int() >= 0, "positive constants"); 751 } 752 virtual int Opcode() const; 753 uint pos() const { return in(2)->get_int(); } 754 755 static Node* make(Node* v, uint position, BasicType bt); 756 }; 757 758 //------------------------------ExtractBNode----------------------------------- 759 // Extract a byte from a vector at position "pos" 760 class ExtractBNode : public ExtractNode { 761 public: 762 ExtractBNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 763 virtual int Opcode() const; 764 virtual const Type *bottom_type() const { return TypeInt::INT; } 765 virtual uint ideal_reg() const { return Op_RegI; } 766 }; 767 768 //------------------------------ExtractUBNode---------------------------------- 769 // Extract a boolean from a vector at position "pos" 770 class ExtractUBNode : public ExtractNode { 771 public: 772 ExtractUBNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 773 virtual int Opcode() const; 774 virtual const Type *bottom_type() const { return TypeInt::INT; } 775 virtual uint ideal_reg() const { return Op_RegI; } 776 }; 777 778 //------------------------------ExtractCNode----------------------------------- 779 // Extract a char from a vector at position "pos" 780 class ExtractCNode : public ExtractNode { 781 public: 782 ExtractCNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 783 virtual int Opcode() const; 784 virtual const Type *bottom_type() const { return TypeInt::INT; } 785 virtual uint ideal_reg() const { return Op_RegI; } 786 }; 787 788 //------------------------------ExtractSNode----------------------------------- 789 // Extract a short from a vector at position "pos" 790 class ExtractSNode : public ExtractNode { 791 public: 792 ExtractSNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 793 virtual int Opcode() const; 794 virtual const Type *bottom_type() const { return TypeInt::INT; } 795 virtual uint ideal_reg() const { return Op_RegI; } 796 }; 797 798 //------------------------------ExtractINode----------------------------------- 799 // Extract an int from a vector at position "pos" 800 class ExtractINode : public ExtractNode { 801 public: 802 ExtractINode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 803 virtual int Opcode() const; 804 virtual const Type *bottom_type() const { return TypeInt::INT; } 805 virtual uint ideal_reg() const { return Op_RegI; } 806 }; 807 808 //------------------------------ExtractLNode----------------------------------- 809 // Extract a long from a vector at position "pos" 810 class ExtractLNode : public ExtractNode { 811 public: 812 ExtractLNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 813 virtual int Opcode() const; 814 virtual const Type *bottom_type() const { return TypeLong::LONG; } 815 virtual uint ideal_reg() const { return Op_RegL; } 816 }; 817 818 //------------------------------ExtractFNode----------------------------------- 819 // Extract a float from a vector at position "pos" 820 class ExtractFNode : public ExtractNode { 821 public: 822 ExtractFNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 823 virtual int Opcode() const; 824 virtual const Type *bottom_type() const { return Type::FLOAT; } 825 virtual uint ideal_reg() const { return Op_RegF; } 826 }; 827 828 //------------------------------ExtractDNode----------------------------------- 829 // Extract a double from a vector at position "pos" 830 class ExtractDNode : public ExtractNode { 831 public: 832 ExtractDNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 833 virtual int Opcode() const; 834 virtual const Type *bottom_type() const { return Type::DOUBLE; } 835 virtual uint ideal_reg() const { return Op_RegD; } 836 }; 837 838 //------------------------------SetVectMaskINode------------------------------- 839 // Provide a mask for a vector predicate machine 840 class SetVectMaskINode : public Node { 841 public: 842 SetVectMaskINode(Node *c, Node *in1) : Node(c, in1) {} 843 virtual int Opcode() const; 844 const Type *bottom_type() const { return TypeInt::INT; } 845 virtual uint ideal_reg() const { return Op_RegI; } 846 virtual const Type *Value(PhaseGVN *phase) const { return TypeInt::INT; } 847 }; 848 849 #endif // SHARE_VM_OPTO_VECTORNODE_HPP