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