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/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 VectorNode(Node * n1,const TypeVect * vt)37 VectorNode(Node* n1, const TypeVect* vt) : TypeNode(vt, 2) { 38 init_class_id(Class_Vector); 39 init_req(1, n1); 40 } VectorNode(Node * n1,Node * n2,const TypeVect * vt)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 VectorNode(Node * n1,Node * n2,Node * n3,const TypeVect * vt)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 vect_type() const54 const TypeVect* vect_type() const { return type()->is_vect(); } length() const55 uint length() const { return vect_type()->length(); } // Vector length length_in_bytes() const56 uint length_in_bytes() const { return vect_type()->length_in_bytes(); } 57 58 virtual int Opcode() const; 59 ideal_reg() const60 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_type_transition_short_to_int(Node* n); 71 static bool is_type_transition_to_int(Node* n); 72 static bool is_muladds2i(Node* n); 73 static bool is_roundopD(Node * n); 74 static bool is_invariant_vector(Node* n); 75 // [Start, end) half-open range defining which operands are vectors 76 static void vector_operands(Node* n, uint* start, uint* end); 77 }; 78 79 //===========================Vector=ALU=Operations============================= 80 81 //------------------------------AddVBNode-------------------------------------- 82 // Vector add byte 83 class AddVBNode : public VectorNode { 84 public: AddVBNode(Node * in1,Node * in2,const TypeVect * vt)85 AddVBNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 86 virtual int Opcode() const; 87 }; 88 89 //------------------------------AddVSNode-------------------------------------- 90 // Vector add char/short 91 class AddVSNode : public VectorNode { 92 public: AddVSNode(Node * in1,Node * in2,const TypeVect * vt)93 AddVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 94 virtual int Opcode() const; 95 }; 96 97 //------------------------------AddVINode-------------------------------------- 98 // Vector add int 99 class AddVINode : public VectorNode { 100 public: AddVINode(Node * in1,Node * in2,const TypeVect * vt)101 AddVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 102 virtual int Opcode() const; 103 }; 104 105 //------------------------------AddVLNode-------------------------------------- 106 // Vector add long 107 class AddVLNode : public VectorNode { 108 public: AddVLNode(Node * in1,Node * in2,const TypeVect * vt)109 AddVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 110 virtual int Opcode() const; 111 }; 112 113 //------------------------------AddVFNode-------------------------------------- 114 // Vector add float 115 class AddVFNode : public VectorNode { 116 public: AddVFNode(Node * in1,Node * in2,const TypeVect * vt)117 AddVFNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 118 virtual int Opcode() const; 119 }; 120 121 //------------------------------AddVDNode-------------------------------------- 122 // Vector add double 123 class AddVDNode : public VectorNode { 124 public: AddVDNode(Node * in1,Node * in2,const TypeVect * vt)125 AddVDNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 126 virtual int Opcode() const; 127 }; 128 129 //------------------------------ReductionNode------------------------------------ 130 // Perform reduction of a vector 131 class ReductionNode : public Node { 132 public: ReductionNode(Node * ctrl,Node * in1,Node * in2)133 ReductionNode(Node *ctrl, Node* in1, Node* in2) : Node(ctrl, in1, in2) {} 134 135 static ReductionNode* make(int opc, Node *ctrl, Node* in1, Node* in2, BasicType bt); 136 static int opcode(int opc, BasicType bt); 137 static bool implemented(int opc, uint vlen, BasicType bt); 138 }; 139 140 //------------------------------AddReductionVINode-------------------------------------- 141 // Vector add int as a reduction 142 class AddReductionVINode : public ReductionNode { 143 public: AddReductionVINode(Node * ctrl,Node * in1,Node * in2)144 AddReductionVINode(Node * ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 145 virtual int Opcode() const; bottom_type() const146 virtual const Type* bottom_type() const { return TypeInt::INT; } ideal_reg() const147 virtual uint ideal_reg() const { return Op_RegI; } 148 }; 149 150 //------------------------------AddReductionVLNode-------------------------------------- 151 // Vector add long as a reduction 152 class AddReductionVLNode : public ReductionNode { 153 public: AddReductionVLNode(Node * ctrl,Node * in1,Node * in2)154 AddReductionVLNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 155 virtual int Opcode() const; bottom_type() const156 virtual const Type* bottom_type() const { return TypeLong::LONG; } ideal_reg() const157 virtual uint ideal_reg() const { return Op_RegL; } 158 }; 159 160 //------------------------------AddReductionVFNode-------------------------------------- 161 // Vector add float as a reduction 162 class AddReductionVFNode : public ReductionNode { 163 public: AddReductionVFNode(Node * ctrl,Node * in1,Node * in2)164 AddReductionVFNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 165 virtual int Opcode() const; bottom_type() const166 virtual const Type* bottom_type() const { return Type::FLOAT; } ideal_reg() const167 virtual uint ideal_reg() const { return Op_RegF; } 168 }; 169 170 //------------------------------AddReductionVDNode-------------------------------------- 171 // Vector add double as a reduction 172 class AddReductionVDNode : public ReductionNode { 173 public: AddReductionVDNode(Node * ctrl,Node * in1,Node * in2)174 AddReductionVDNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 175 virtual int Opcode() const; bottom_type() const176 virtual const Type* bottom_type() const { return Type::DOUBLE; } ideal_reg() const177 virtual uint ideal_reg() const { return Op_RegD; } 178 }; 179 180 //------------------------------SubVBNode-------------------------------------- 181 // Vector subtract byte 182 class SubVBNode : public VectorNode { 183 public: SubVBNode(Node * in1,Node * in2,const TypeVect * vt)184 SubVBNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 185 virtual int Opcode() const; 186 }; 187 188 //------------------------------SubVSNode-------------------------------------- 189 // Vector subtract short 190 class SubVSNode : public VectorNode { 191 public: SubVSNode(Node * in1,Node * in2,const TypeVect * vt)192 SubVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 193 virtual int Opcode() const; 194 }; 195 196 //------------------------------SubVINode-------------------------------------- 197 // Vector subtract int 198 class SubVINode : public VectorNode { 199 public: SubVINode(Node * in1,Node * in2,const TypeVect * vt)200 SubVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 201 virtual int Opcode() const; 202 }; 203 204 //------------------------------SubVLNode-------------------------------------- 205 // Vector subtract long 206 class SubVLNode : public VectorNode { 207 public: SubVLNode(Node * in1,Node * in2,const TypeVect * vt)208 SubVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 209 virtual int Opcode() const; 210 }; 211 212 //------------------------------SubVFNode-------------------------------------- 213 // Vector subtract float 214 class SubVFNode : public VectorNode { 215 public: SubVFNode(Node * in1,Node * in2,const TypeVect * vt)216 SubVFNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 217 virtual int Opcode() const; 218 }; 219 220 //------------------------------SubVDNode-------------------------------------- 221 // Vector subtract double 222 class SubVDNode : public VectorNode { 223 public: SubVDNode(Node * in1,Node * in2,const TypeVect * vt)224 SubVDNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 225 virtual int Opcode() const; 226 }; 227 228 //------------------------------MulVBNode-------------------------------------- 229 // Vector multiply byte 230 class MulVBNode : public VectorNode { 231 public: MulVBNode(Node * in1,Node * in2,const TypeVect * vt)232 MulVBNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 233 virtual int Opcode() const; 234 }; 235 236 //------------------------------MulVSNode-------------------------------------- 237 // Vector multiply short 238 class MulVSNode : public VectorNode { 239 public: MulVSNode(Node * in1,Node * in2,const TypeVect * vt)240 MulVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 241 virtual int Opcode() const; 242 }; 243 244 //------------------------------MulVINode-------------------------------------- 245 // Vector multiply int 246 class MulVINode : public VectorNode { 247 public: MulVINode(Node * in1,Node * in2,const TypeVect * vt)248 MulVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 249 virtual int Opcode() const; 250 }; 251 252 //------------------------------MulVLNode-------------------------------------- 253 // Vector multiply long 254 class MulVLNode : public VectorNode { 255 public: MulVLNode(Node * in1,Node * in2,const TypeVect * vt)256 MulVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 257 virtual int Opcode() const; 258 }; 259 260 //------------------------------MulVFNode-------------------------------------- 261 // Vector multiply float 262 class MulVFNode : public VectorNode { 263 public: MulVFNode(Node * in1,Node * in2,const TypeVect * vt)264 MulVFNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 265 virtual int Opcode() const; 266 }; 267 268 //------------------------------MulVDNode-------------------------------------- 269 // Vector multiply double 270 class MulVDNode : public VectorNode { 271 public: MulVDNode(Node * in1,Node * in2,const TypeVect * vt)272 MulVDNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 273 virtual int Opcode() const; 274 }; 275 276 //------------------------------MulAddVS2VINode-------------------------------- 277 // Vector multiply shorts to int and add adjacent ints. 278 class MulAddVS2VINode : public VectorNode { 279 public: MulAddVS2VINode(Node * in1,Node * in2,const TypeVect * vt)280 MulAddVS2VINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 281 virtual int Opcode() const; 282 }; 283 284 //------------------------------FmaVDNode-------------------------------------- 285 // Vector multiply double 286 class FmaVDNode : public VectorNode { 287 public: FmaVDNode(Node * in1,Node * in2,Node * in3,const TypeVect * vt)288 FmaVDNode(Node* in1, Node* in2, Node* in3, const TypeVect* vt) : VectorNode(in1, in2, in3, vt) {} 289 virtual int Opcode() const; 290 }; 291 292 //------------------------------FmaVFNode-------------------------------------- 293 // Vector multiply float 294 class FmaVFNode : public VectorNode { 295 public: FmaVFNode(Node * in1,Node * in2,Node * in3,const TypeVect * vt)296 FmaVFNode(Node* in1, Node* in2, Node* in3, const TypeVect* vt) : VectorNode(in1, in2, in3, vt) {} 297 virtual int Opcode() const; 298 }; 299 300 //------------------------------CMoveVFNode-------------------------------------- 301 // Vector float conditional move 302 class CMoveVFNode : public VectorNode { 303 public: CMoveVFNode(Node * in1,Node * in2,Node * in3,const TypeVect * vt)304 CMoveVFNode(Node* in1, Node* in2, Node* in3, const TypeVect* vt) : VectorNode(in1, in2, in3, vt) {} 305 virtual int Opcode() const; 306 }; 307 308 //------------------------------CMoveVDNode-------------------------------------- 309 // Vector double conditional move 310 class CMoveVDNode : public VectorNode { 311 public: CMoveVDNode(Node * in1,Node * in2,Node * in3,const TypeVect * vt)312 CMoveVDNode(Node* in1, Node* in2, Node* in3, const TypeVect* vt) : VectorNode(in1, in2, in3, vt) {} 313 virtual int Opcode() const; 314 }; 315 316 //------------------------------MulReductionVINode-------------------------------------- 317 // Vector multiply int as a reduction 318 class MulReductionVINode : public ReductionNode { 319 public: MulReductionVINode(Node * ctrl,Node * in1,Node * in2)320 MulReductionVINode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 321 virtual int Opcode() const; bottom_type() const322 virtual const Type* bottom_type() const { return TypeInt::INT; } ideal_reg() const323 virtual uint ideal_reg() const { return Op_RegI; } 324 }; 325 326 //------------------------------MulReductionVLNode-------------------------------------- 327 // Vector multiply int as a reduction 328 class MulReductionVLNode : public ReductionNode { 329 public: MulReductionVLNode(Node * ctrl,Node * in1,Node * in2)330 MulReductionVLNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 331 virtual int Opcode() const; bottom_type() const332 virtual const Type* bottom_type() const { return TypeLong::LONG; } ideal_reg() const333 virtual uint ideal_reg() const { return Op_RegI; } 334 }; 335 336 //------------------------------MulReductionVFNode-------------------------------------- 337 // Vector multiply float as a reduction 338 class MulReductionVFNode : public ReductionNode { 339 public: MulReductionVFNode(Node * ctrl,Node * in1,Node * in2)340 MulReductionVFNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 341 virtual int Opcode() const; bottom_type() const342 virtual const Type* bottom_type() const { return Type::FLOAT; } ideal_reg() const343 virtual uint ideal_reg() const { return Op_RegF; } 344 }; 345 346 //------------------------------MulReductionVDNode-------------------------------------- 347 // Vector multiply double as a reduction 348 class MulReductionVDNode : public ReductionNode { 349 public: MulReductionVDNode(Node * ctrl,Node * in1,Node * in2)350 MulReductionVDNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 351 virtual int Opcode() const; bottom_type() const352 virtual const Type* bottom_type() const { return Type::DOUBLE; } ideal_reg() const353 virtual uint ideal_reg() const { return Op_RegD; } 354 }; 355 356 //------------------------------DivVFNode-------------------------------------- 357 // Vector divide float 358 class DivVFNode : public VectorNode { 359 public: DivVFNode(Node * in1,Node * in2,const TypeVect * vt)360 DivVFNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 361 virtual int Opcode() const; 362 }; 363 364 //------------------------------DivVDNode-------------------------------------- 365 // Vector Divide double 366 class DivVDNode : public VectorNode { 367 public: DivVDNode(Node * in1,Node * in2,const TypeVect * vt)368 DivVDNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 369 virtual int Opcode() const; 370 }; 371 372 //------------------------------AbsVBNode-------------------------------------- 373 // Vector Abs byte 374 class AbsVBNode : public VectorNode { 375 public: AbsVBNode(Node * in,const TypeVect * vt)376 AbsVBNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) {} 377 virtual int Opcode() const; 378 }; 379 380 //------------------------------AbsVSNode-------------------------------------- 381 // Vector Abs short 382 class AbsVSNode : public VectorNode { 383 public: AbsVSNode(Node * in,const TypeVect * vt)384 AbsVSNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) {} 385 virtual int Opcode() const; 386 }; 387 388 //------------------------------AbsVINode-------------------------------------- 389 // Vector Abs int 390 class AbsVINode : public VectorNode { 391 public: AbsVINode(Node * in,const TypeVect * vt)392 AbsVINode(Node* in, const TypeVect* vt) : VectorNode(in, vt) {} 393 virtual int Opcode() const; 394 }; 395 396 //------------------------------AbsVLNode-------------------------------------- 397 // Vector Abs long 398 class AbsVLNode : public VectorNode { 399 public: AbsVLNode(Node * in,const TypeVect * vt)400 AbsVLNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) {} 401 virtual int Opcode() const; 402 }; 403 404 //------------------------------AbsVFNode-------------------------------------- 405 // Vector Abs float 406 class AbsVFNode : public VectorNode { 407 public: AbsVFNode(Node * in,const TypeVect * vt)408 AbsVFNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {} 409 virtual int Opcode() const; 410 }; 411 412 //------------------------------AbsVDNode-------------------------------------- 413 // Vector Abs double 414 class AbsVDNode : public VectorNode { 415 public: AbsVDNode(Node * in,const TypeVect * vt)416 AbsVDNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {} 417 virtual int Opcode() const; 418 }; 419 420 //------------------------------NegVFNode-------------------------------------- 421 // Vector Neg float 422 class NegVFNode : public VectorNode { 423 public: NegVFNode(Node * in,const TypeVect * vt)424 NegVFNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {} 425 virtual int Opcode() const; 426 }; 427 428 //------------------------------NegVDNode-------------------------------------- 429 // Vector Neg double 430 class NegVDNode : public VectorNode { 431 public: NegVDNode(Node * in,const TypeVect * vt)432 NegVDNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {} 433 virtual int Opcode() const; 434 }; 435 436 //------------------------------PopCountVINode--------------------------------- 437 // Vector popcount integer bits 438 class PopCountVINode : public VectorNode { 439 public: PopCountVINode(Node * in,const TypeVect * vt)440 PopCountVINode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {} 441 virtual int Opcode() const; 442 }; 443 444 //------------------------------SqrtVFNode-------------------------------------- 445 // Vector Sqrt float 446 class SqrtVFNode : public VectorNode { 447 public: SqrtVFNode(Node * in,const TypeVect * vt)448 SqrtVFNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {} 449 virtual int Opcode() const; 450 }; 451 //------------------------------RoundDoubleVNode-------------------------------- 452 // Vector round double 453 class RoundDoubleModeVNode : public VectorNode { 454 public: RoundDoubleModeVNode(Node * in1,Node * in2,const TypeVect * vt)455 RoundDoubleModeVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 456 virtual int Opcode() const; 457 }; 458 459 //------------------------------SqrtVDNode-------------------------------------- 460 // Vector Sqrt double 461 class SqrtVDNode : public VectorNode { 462 public: SqrtVDNode(Node * in,const TypeVect * vt)463 SqrtVDNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {} 464 virtual int Opcode() const; 465 }; 466 467 //------------------------------LShiftVBNode----------------------------------- 468 // Vector left shift bytes 469 class LShiftVBNode : public VectorNode { 470 public: LShiftVBNode(Node * in1,Node * in2,const TypeVect * vt)471 LShiftVBNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 472 virtual int Opcode() const; 473 }; 474 475 //------------------------------LShiftVSNode----------------------------------- 476 // Vector left shift shorts 477 class LShiftVSNode : public VectorNode { 478 public: LShiftVSNode(Node * in1,Node * in2,const TypeVect * vt)479 LShiftVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 480 virtual int Opcode() const; 481 }; 482 483 //------------------------------LShiftVINode----------------------------------- 484 // Vector left shift ints 485 class LShiftVINode : public VectorNode { 486 public: LShiftVINode(Node * in1,Node * in2,const TypeVect * vt)487 LShiftVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 488 virtual int Opcode() const; 489 }; 490 491 //------------------------------LShiftVLNode----------------------------------- 492 // Vector left shift longs 493 class LShiftVLNode : public VectorNode { 494 public: LShiftVLNode(Node * in1,Node * in2,const TypeVect * vt)495 LShiftVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 496 virtual int Opcode() const; 497 }; 498 499 //------------------------------RShiftVBNode----------------------------------- 500 // Vector right arithmetic (signed) shift bytes 501 class RShiftVBNode : public VectorNode { 502 public: RShiftVBNode(Node * in1,Node * in2,const TypeVect * vt)503 RShiftVBNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 504 virtual int Opcode() const; 505 }; 506 507 //------------------------------RShiftVSNode----------------------------------- 508 // Vector right arithmetic (signed) shift shorts 509 class RShiftVSNode : public VectorNode { 510 public: RShiftVSNode(Node * in1,Node * in2,const TypeVect * vt)511 RShiftVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 512 virtual int Opcode() const; 513 }; 514 515 //------------------------------RShiftVINode----------------------------------- 516 // Vector right arithmetic (signed) shift ints 517 class RShiftVINode : public VectorNode { 518 public: RShiftVINode(Node * in1,Node * in2,const TypeVect * vt)519 RShiftVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 520 virtual int Opcode() const; 521 }; 522 523 //------------------------------RShiftVLNode----------------------------------- 524 // Vector right arithmetic (signed) shift longs 525 class RShiftVLNode : public VectorNode { 526 public: RShiftVLNode(Node * in1,Node * in2,const TypeVect * vt)527 RShiftVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 528 virtual int Opcode() const; 529 }; 530 531 //------------------------------URShiftVBNode---------------------------------- 532 // Vector right logical (unsigned) shift bytes 533 class URShiftVBNode : public VectorNode { 534 public: URShiftVBNode(Node * in1,Node * in2,const TypeVect * vt)535 URShiftVBNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 536 virtual int Opcode() const; 537 }; 538 539 //------------------------------URShiftVSNode---------------------------------- 540 // Vector right logical (unsigned) shift shorts 541 class URShiftVSNode : public VectorNode { 542 public: URShiftVSNode(Node * in1,Node * in2,const TypeVect * vt)543 URShiftVSNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 544 virtual int Opcode() const; 545 }; 546 547 //------------------------------URShiftVINode---------------------------------- 548 // Vector right logical (unsigned) shift ints 549 class URShiftVINode : public VectorNode { 550 public: URShiftVINode(Node * in1,Node * in2,const TypeVect * vt)551 URShiftVINode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 552 virtual int Opcode() const; 553 }; 554 555 //------------------------------URShiftVLNode---------------------------------- 556 // Vector right logical (unsigned) shift longs 557 class URShiftVLNode : public VectorNode { 558 public: URShiftVLNode(Node * in1,Node * in2,const TypeVect * vt)559 URShiftVLNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 560 virtual int Opcode() const; 561 }; 562 563 //------------------------------LShiftCntVNode--------------------------------- 564 // Vector left shift count 565 class LShiftCntVNode : public VectorNode { 566 public: LShiftCntVNode(Node * cnt,const TypeVect * vt)567 LShiftCntVNode(Node* cnt, const TypeVect* vt) : VectorNode(cnt,vt) {} 568 virtual int Opcode() const; ideal_reg() const569 virtual uint ideal_reg() const { return Matcher::vector_shift_count_ideal_reg(vect_type()->length_in_bytes()); } 570 }; 571 572 //------------------------------RShiftCntVNode--------------------------------- 573 // Vector right shift count 574 class RShiftCntVNode : public VectorNode { 575 public: RShiftCntVNode(Node * cnt,const TypeVect * vt)576 RShiftCntVNode(Node* cnt, const TypeVect* vt) : VectorNode(cnt,vt) {} 577 virtual int Opcode() const; ideal_reg() const578 virtual uint ideal_reg() const { return Matcher::vector_shift_count_ideal_reg(vect_type()->length_in_bytes()); } 579 }; 580 581 582 //------------------------------AndVNode--------------------------------------- 583 // Vector and integer 584 class AndVNode : public VectorNode { 585 public: AndVNode(Node * in1,Node * in2,const TypeVect * vt)586 AndVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 587 virtual int Opcode() const; 588 }; 589 590 //------------------------------OrVNode--------------------------------------- 591 // Vector or integer 592 class OrVNode : public VectorNode { 593 public: OrVNode(Node * in1,Node * in2,const TypeVect * vt)594 OrVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 595 virtual int Opcode() const; 596 }; 597 598 //------------------------------XorVNode--------------------------------------- 599 // Vector xor integer 600 class XorVNode : public VectorNode { 601 public: XorVNode(Node * in1,Node * in2,const TypeVect * vt)602 XorVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1,in2,vt) {} 603 virtual int Opcode() const; 604 }; 605 606 //------------------------------MinVNode-------------------------------------- 607 // Vector min 608 class MinVNode : public VectorNode { 609 public: MinVNode(Node * in1,Node * in2,const TypeVect * vt)610 MinVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 611 virtual int Opcode() const; 612 }; 613 614 //------------------------------MaxVNode-------------------------------------- 615 // Vector max 616 class MaxVNode : public VectorNode { 617 public: MaxVNode(Node * in1,Node * in2,const TypeVect * vt)618 MaxVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) {} 619 virtual int Opcode() const; 620 }; 621 622 //------------------------------MinReductionVNode-------------------------------------- 623 // Vector min as a reduction 624 class MinReductionVNode : public ReductionNode { 625 public: MinReductionVNode(Node * ctrl,Node * in1,Node * in2)626 MinReductionVNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 627 virtual int Opcode() const; bottom_type() const628 virtual const Type* bottom_type() const { 629 BasicType bt = in(1)->bottom_type()->basic_type(); 630 if (bt == T_FLOAT) { 631 return Type::FLOAT; 632 } else if (bt == T_DOUBLE) { 633 return Type::DOUBLE; 634 } 635 assert(false, "unsupported basic type"); 636 return NULL; 637 } ideal_reg() const638 virtual uint ideal_reg() const { 639 BasicType bt = in(1)->bottom_type()->basic_type(); 640 if (bt == T_FLOAT) { 641 return Op_RegF; 642 } else if (bt == T_DOUBLE) { 643 return Op_RegD; 644 } 645 assert(false, "unsupported basic type"); 646 return 0; 647 } 648 }; 649 650 //------------------------------MaxReductionVNode-------------------------------------- 651 // Vector max as a reduction 652 class MaxReductionVNode : public ReductionNode { 653 public: MaxReductionVNode(Node * ctrl,Node * in1,Node * in2)654 MaxReductionVNode(Node *ctrl, Node* in1, Node* in2) : ReductionNode(ctrl, in1, in2) {} 655 virtual int Opcode() const; bottom_type() const656 virtual const Type* bottom_type() const { 657 BasicType bt = in(1)->bottom_type()->basic_type(); 658 if (bt == T_FLOAT) { 659 return Type::FLOAT; 660 } else { 661 return Type::DOUBLE; 662 } 663 assert(false, "unsupported basic type"); 664 return NULL; 665 } ideal_reg() const666 virtual uint ideal_reg() const { 667 BasicType bt = in(1)->bottom_type()->basic_type(); 668 if (bt == T_FLOAT) { 669 return Op_RegF; 670 } else { 671 return Op_RegD; 672 } 673 assert(false, "unsupported basic type"); 674 return 0; 675 } 676 }; 677 678 //================================= M E M O R Y =============================== 679 680 //------------------------------LoadVectorNode--------------------------------- 681 // Load Vector from memory 682 class LoadVectorNode : public LoadNode { 683 public: LoadVectorNode(Node * c,Node * mem,Node * adr,const TypePtr * at,const TypeVect * vt,ControlDependency control_dependency=LoadNode::DependsOnlyOnTest)684 LoadVectorNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeVect* vt, ControlDependency control_dependency = LoadNode::DependsOnlyOnTest) 685 : LoadNode(c, mem, adr, at, vt, MemNode::unordered, control_dependency) { 686 init_class_id(Class_LoadVector); 687 set_mismatched_access(); 688 } 689 vect_type() const690 const TypeVect* vect_type() const { return type()->is_vect(); } length() const691 uint length() const { return vect_type()->length(); } // Vector length 692 693 virtual int Opcode() const; 694 ideal_reg() const695 virtual uint ideal_reg() const { return Matcher::vector_ideal_reg(memory_size()); } memory_type() const696 virtual BasicType memory_type() const { return T_VOID; } memory_size() const697 virtual int memory_size() const { return vect_type()->length_in_bytes(); } 698 store_Opcode() const699 virtual int store_Opcode() const { return Op_StoreVector; } 700 701 static LoadVectorNode* make(int opc, Node* ctl, Node* mem, 702 Node* adr, const TypePtr* atyp, 703 uint vlen, BasicType bt, 704 ControlDependency control_dependency = LoadNode::DependsOnlyOnTest); element_size(void)705 uint element_size(void) { return type2aelembytes(vect_type()->element_basic_type()); } 706 }; 707 708 //------------------------------StoreVectorNode-------------------------------- 709 // Store Vector to memory 710 class StoreVectorNode : public StoreNode { 711 public: StoreVectorNode(Node * c,Node * mem,Node * adr,const TypePtr * at,Node * val)712 StoreVectorNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val) 713 : StoreNode(c, mem, adr, at, val, MemNode::unordered) { 714 assert(val->is_Vector() || val->is_LoadVector(), "sanity"); 715 init_class_id(Class_StoreVector); 716 set_mismatched_access(); 717 } 718 vect_type() const719 const TypeVect* vect_type() const { return in(MemNode::ValueIn)->bottom_type()->is_vect(); } length() const720 uint length() const { return vect_type()->length(); } // Vector length 721 722 virtual int Opcode() const; 723 ideal_reg() const724 virtual uint ideal_reg() const { return Matcher::vector_ideal_reg(memory_size()); } memory_type() const725 virtual BasicType memory_type() const { return T_VOID; } memory_size() const726 virtual int memory_size() const { return vect_type()->length_in_bytes(); } 727 728 static StoreVectorNode* make(int opc, Node* ctl, Node* mem, 729 Node* adr, const TypePtr* atyp, Node* val, 730 uint vlen); 731 element_size(void)732 uint element_size(void) { return type2aelembytes(vect_type()->element_basic_type()); } 733 }; 734 735 736 //=========================Promote_Scalar_to_Vector============================ 737 738 //------------------------------ReplicateBNode--------------------------------- 739 // Replicate byte scalar to be vector 740 class ReplicateBNode : public VectorNode { 741 public: ReplicateBNode(Node * in1,const TypeVect * vt)742 ReplicateBNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 743 virtual int Opcode() const; 744 }; 745 746 //------------------------------ReplicateSNode--------------------------------- 747 // Replicate short scalar to be vector 748 class ReplicateSNode : public VectorNode { 749 public: ReplicateSNode(Node * in1,const TypeVect * vt)750 ReplicateSNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 751 virtual int Opcode() const; 752 }; 753 754 //------------------------------ReplicateINode--------------------------------- 755 // Replicate int scalar to be vector 756 class ReplicateINode : public VectorNode { 757 public: ReplicateINode(Node * in1,const TypeVect * vt)758 ReplicateINode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 759 virtual int Opcode() const; 760 }; 761 762 //------------------------------ReplicateLNode--------------------------------- 763 // Replicate long scalar to be vector 764 class ReplicateLNode : public VectorNode { 765 public: ReplicateLNode(Node * in1,const TypeVect * vt)766 ReplicateLNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 767 virtual int Opcode() const; 768 }; 769 770 //------------------------------ReplicateFNode--------------------------------- 771 // Replicate float scalar to be vector 772 class ReplicateFNode : public VectorNode { 773 public: ReplicateFNode(Node * in1,const TypeVect * vt)774 ReplicateFNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 775 virtual int Opcode() const; 776 }; 777 778 //------------------------------ReplicateDNode--------------------------------- 779 // Replicate double scalar to be vector 780 class ReplicateDNode : public VectorNode { 781 public: ReplicateDNode(Node * in1,const TypeVect * vt)782 ReplicateDNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} 783 virtual int Opcode() const; 784 }; 785 786 //========================Pack_Scalars_into_a_Vector=========================== 787 788 //------------------------------PackNode--------------------------------------- 789 // Pack parent class (not for code generation). 790 class PackNode : public VectorNode { 791 public: PackNode(Node * in1,const TypeVect * vt)792 PackNode(Node* in1, const TypeVect* vt) : VectorNode(in1, vt) {} PackNode(Node * in1,Node * n2,const TypeVect * vt)793 PackNode(Node* in1, Node* n2, const TypeVect* vt) : VectorNode(in1, n2, vt) {} 794 virtual int Opcode() const; 795 add_opd(Node * n)796 void add_opd(Node* n) { 797 add_req(n); 798 } 799 800 // Create a binary tree form for Packs. [lo, hi) (half-open) range 801 PackNode* binary_tree_pack(int lo, int hi); 802 803 static PackNode* make(Node* s, uint vlen, BasicType bt); 804 }; 805 806 //------------------------------PackBNode-------------------------------------- 807 // Pack byte scalars into vector 808 class PackBNode : public PackNode { 809 public: PackBNode(Node * in1,const TypeVect * vt)810 PackBNode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} 811 virtual int Opcode() const; 812 }; 813 814 //------------------------------PackSNode-------------------------------------- 815 // Pack short scalars into a vector 816 class PackSNode : public PackNode { 817 public: PackSNode(Node * in1,const TypeVect * vt)818 PackSNode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} PackSNode(Node * in1,Node * in2,const TypeVect * vt)819 PackSNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 820 virtual int Opcode() const; 821 }; 822 823 //------------------------------PackINode-------------------------------------- 824 // Pack integer scalars into a vector 825 class PackINode : public PackNode { 826 public: PackINode(Node * in1,const TypeVect * vt)827 PackINode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} PackINode(Node * in1,Node * in2,const TypeVect * vt)828 PackINode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 829 virtual int Opcode() const; 830 }; 831 832 //------------------------------PackLNode-------------------------------------- 833 // Pack long scalars into a vector 834 class PackLNode : public PackNode { 835 public: PackLNode(Node * in1,const TypeVect * vt)836 PackLNode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} PackLNode(Node * in1,Node * in2,const TypeVect * vt)837 PackLNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 838 virtual int Opcode() const; 839 }; 840 841 //------------------------------Pack2LNode------------------------------------- 842 // Pack 2 long scalars into a vector 843 class Pack2LNode : public PackNode { 844 public: Pack2LNode(Node * in1,Node * in2,const TypeVect * vt)845 Pack2LNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 846 virtual int Opcode() const; 847 }; 848 849 //------------------------------PackFNode-------------------------------------- 850 // Pack float scalars into vector 851 class PackFNode : public PackNode { 852 public: PackFNode(Node * in1,const TypeVect * vt)853 PackFNode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} PackFNode(Node * in1,Node * in2,const TypeVect * vt)854 PackFNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 855 virtual int Opcode() const; 856 }; 857 858 //------------------------------PackDNode-------------------------------------- 859 // Pack double scalars into a vector 860 class PackDNode : public PackNode { 861 public: PackDNode(Node * in1,const TypeVect * vt)862 PackDNode(Node* in1, const TypeVect* vt) : PackNode(in1, vt) {} PackDNode(Node * in1,Node * in2,const TypeVect * vt)863 PackDNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 864 virtual int Opcode() const; 865 }; 866 867 //------------------------------Pack2DNode------------------------------------- 868 // Pack 2 double scalars into a vector 869 class Pack2DNode : public PackNode { 870 public: Pack2DNode(Node * in1,Node * in2,const TypeVect * vt)871 Pack2DNode(Node* in1, Node* in2, const TypeVect* vt) : PackNode(in1, in2, vt) {} 872 virtual int Opcode() const; 873 }; 874 875 876 //========================Extract_Scalar_from_Vector=========================== 877 878 //------------------------------ExtractNode------------------------------------ 879 // Extract a scalar from a vector at position "pos" 880 class ExtractNode : public Node { 881 public: ExtractNode(Node * src,ConINode * pos)882 ExtractNode(Node* src, ConINode* pos) : Node(NULL, src, (Node*)pos) { 883 assert(in(2)->get_int() >= 0, "positive constants"); 884 } 885 virtual int Opcode() const; pos() const886 uint pos() const { return in(2)->get_int(); } 887 888 static Node* make(Node* v, uint position, BasicType bt); 889 }; 890 891 //------------------------------ExtractBNode----------------------------------- 892 // Extract a byte from a vector at position "pos" 893 class ExtractBNode : public ExtractNode { 894 public: ExtractBNode(Node * src,ConINode * pos)895 ExtractBNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 896 virtual int Opcode() const; bottom_type() const897 virtual const Type *bottom_type() const { return TypeInt::INT; } ideal_reg() const898 virtual uint ideal_reg() const { return Op_RegI; } 899 }; 900 901 //------------------------------ExtractUBNode---------------------------------- 902 // Extract a boolean from a vector at position "pos" 903 class ExtractUBNode : public ExtractNode { 904 public: ExtractUBNode(Node * src,ConINode * pos)905 ExtractUBNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 906 virtual int Opcode() const; bottom_type() const907 virtual const Type *bottom_type() const { return TypeInt::INT; } ideal_reg() const908 virtual uint ideal_reg() const { return Op_RegI; } 909 }; 910 911 //------------------------------ExtractCNode----------------------------------- 912 // Extract a char from a vector at position "pos" 913 class ExtractCNode : public ExtractNode { 914 public: ExtractCNode(Node * src,ConINode * pos)915 ExtractCNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 916 virtual int Opcode() const; bottom_type() const917 virtual const Type *bottom_type() const { return TypeInt::INT; } ideal_reg() const918 virtual uint ideal_reg() const { return Op_RegI; } 919 }; 920 921 //------------------------------ExtractSNode----------------------------------- 922 // Extract a short from a vector at position "pos" 923 class ExtractSNode : public ExtractNode { 924 public: ExtractSNode(Node * src,ConINode * pos)925 ExtractSNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 926 virtual int Opcode() const; bottom_type() const927 virtual const Type *bottom_type() const { return TypeInt::INT; } ideal_reg() const928 virtual uint ideal_reg() const { return Op_RegI; } 929 }; 930 931 //------------------------------ExtractINode----------------------------------- 932 // Extract an int from a vector at position "pos" 933 class ExtractINode : public ExtractNode { 934 public: ExtractINode(Node * src,ConINode * pos)935 ExtractINode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 936 virtual int Opcode() const; bottom_type() const937 virtual const Type *bottom_type() const { return TypeInt::INT; } ideal_reg() const938 virtual uint ideal_reg() const { return Op_RegI; } 939 }; 940 941 //------------------------------ExtractLNode----------------------------------- 942 // Extract a long from a vector at position "pos" 943 class ExtractLNode : public ExtractNode { 944 public: ExtractLNode(Node * src,ConINode * pos)945 ExtractLNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 946 virtual int Opcode() const; bottom_type() const947 virtual const Type *bottom_type() const { return TypeLong::LONG; } ideal_reg() const948 virtual uint ideal_reg() const { return Op_RegL; } 949 }; 950 951 //------------------------------ExtractFNode----------------------------------- 952 // Extract a float from a vector at position "pos" 953 class ExtractFNode : public ExtractNode { 954 public: ExtractFNode(Node * src,ConINode * pos)955 ExtractFNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 956 virtual int Opcode() const; bottom_type() const957 virtual const Type *bottom_type() const { return Type::FLOAT; } ideal_reg() const958 virtual uint ideal_reg() const { return Op_RegF; } 959 }; 960 961 //------------------------------ExtractDNode----------------------------------- 962 // Extract a double from a vector at position "pos" 963 class ExtractDNode : public ExtractNode { 964 public: ExtractDNode(Node * src,ConINode * pos)965 ExtractDNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 966 virtual int Opcode() const; bottom_type() const967 virtual const Type *bottom_type() const { return Type::DOUBLE; } ideal_reg() const968 virtual uint ideal_reg() const { return Op_RegD; } 969 }; 970 971 //------------------------------SetVectMaskINode------------------------------- 972 // Provide a mask for a vector predicate machine 973 class SetVectMaskINode : public Node { 974 public: SetVectMaskINode(Node * c,Node * in1)975 SetVectMaskINode(Node *c, Node *in1) : Node(c, in1) {} 976 virtual int Opcode() const; bottom_type() const977 const Type *bottom_type() const { return TypeInt::INT; } ideal_reg() const978 virtual uint ideal_reg() const { return Op_RegI; } Value(PhaseGVN * phase) const979 virtual const Type *Value(PhaseGVN *phase) const { return TypeInt::INT; } 980 }; 981 982 #endif // SHARE_OPTO_VECTORNODE_HPP 983