1 /* 2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 #ifndef SHARE_VM_OPTO_VECTORNODE_HPP 25 #define SHARE_VM_OPTO_VECTORNODE_HPP 26 27 #include "opto/matcher.hpp" 28 #include "opto/memnode.hpp" 29 #include "opto/node.hpp" 30 #include "opto/opcodes.hpp" 31 32 //------------------------------VectorNode-------------------------------------- 33 // Vector Operation 34 class VectorNode : public Node { 35 protected: 36 uint _length; // vector length 37 virtual BasicType elt_basic_type() const = 0; // Vector element basic type 38 39 static const Type* vect_type(BasicType elt_bt, uint len); 40 static const Type* vect_type(const Type* elt_type, uint len) { 41 return vect_type(elt_type->array_element_basic_type(), len); 42 } 43 44 public: 45 friend class VectorLoadNode; // For vect_type 46 friend class VectorStoreNode; // ditto. 47 48 VectorNode(Node* n1, uint vlen) : Node(NULL, n1), _length(vlen) { 49 init_flags(Flag_is_Vector); 50 } 51 VectorNode(Node* n1, Node* n2, uint vlen) : Node(NULL, n1, n2), _length(vlen) { 52 init_flags(Flag_is_Vector); 53 } 54 virtual int Opcode() const; 55 56 uint length() const { return _length; } // Vector length 57 58 static uint max_vlen(BasicType bt) { // max vector length 59 return (uint)(Matcher::vector_width_in_bytes() / type2aelembytes(bt)); 60 } 61 62 // Element and vector type 63 const Type* elt_type() const { return Type::get_const_basic_type(elt_basic_type()); } 64 const Type* vect_type() const { return vect_type(elt_basic_type(), length()); } 65 66 virtual const Type *bottom_type() const { return vect_type(); } 67 virtual uint ideal_reg() const { return Matcher::vector_ideal_reg(); } 68 69 // Vector opcode from scalar opcode 70 static int opcode(int sopc, uint vlen, const Type* opd_t); 71 72 static VectorNode* scalar2vector(Compile* C, Node* s, uint vlen, const Type* opd_t); 73 74 static VectorNode* make(Compile* C, int sopc, Node* n1, Node* n2, uint vlen, const Type* elt_t); 75 76 }; 77 78 //===========================Vector=ALU=Operations==================================== 79 80 //------------------------------AddVBNode--------------------------------------- 81 // Vector add byte 82 class AddVBNode : public VectorNode { 83 protected: 84 virtual BasicType elt_basic_type() const { return T_BYTE; } 85 public: 86 AddVBNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 87 virtual int Opcode() const; 88 }; 89 90 //------------------------------AddVCNode--------------------------------------- 91 // Vector add char 92 class AddVCNode : public VectorNode { 93 protected: 94 virtual BasicType elt_basic_type() const { return T_CHAR; } 95 public: 96 AddVCNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 97 virtual int Opcode() const; 98 }; 99 100 //------------------------------AddVSNode--------------------------------------- 101 // Vector add short 102 class AddVSNode : public VectorNode { 103 protected: 104 virtual BasicType elt_basic_type() const { return T_SHORT; } 105 public: 106 AddVSNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 107 virtual int Opcode() const; 108 }; 109 110 //------------------------------AddVINode--------------------------------------- 111 // Vector add int 112 class AddVINode : public VectorNode { 113 protected: 114 virtual BasicType elt_basic_type() const { return T_INT; } 115 public: 116 AddVINode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 117 virtual int Opcode() const; 118 }; 119 120 //------------------------------AddVLNode--------------------------------------- 121 // Vector add long 122 class AddVLNode : public VectorNode { 123 protected: 124 virtual BasicType elt_basic_type() const { return T_LONG; } 125 public: 126 AddVLNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 127 virtual int Opcode() const; 128 }; 129 130 //------------------------------AddVFNode--------------------------------------- 131 // Vector add float 132 class AddVFNode : public VectorNode { 133 protected: 134 virtual BasicType elt_basic_type() const { return T_FLOAT; } 135 public: 136 AddVFNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 137 virtual int Opcode() const; 138 }; 139 140 //------------------------------AddVDNode--------------------------------------- 141 // Vector add double 142 class AddVDNode : public VectorNode { 143 protected: 144 virtual BasicType elt_basic_type() const { return T_DOUBLE; } 145 public: 146 AddVDNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 147 virtual int Opcode() const; 148 }; 149 150 //------------------------------SubVBNode--------------------------------------- 151 // Vector subtract byte 152 class SubVBNode : public VectorNode { 153 protected: 154 virtual BasicType elt_basic_type() const { return T_BYTE; } 155 public: 156 SubVBNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 157 virtual int Opcode() const; 158 }; 159 160 //------------------------------SubVCNode--------------------------------------- 161 // Vector subtract char 162 class SubVCNode : public VectorNode { 163 protected: 164 virtual BasicType elt_basic_type() const { return T_CHAR; } 165 public: 166 SubVCNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 167 virtual int Opcode() const; 168 }; 169 170 //------------------------------SubVSNode--------------------------------------- 171 // Vector subtract short 172 class SubVSNode : public VectorNode { 173 protected: 174 virtual BasicType elt_basic_type() const { return T_SHORT; } 175 public: 176 SubVSNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 177 virtual int Opcode() const; 178 }; 179 180 //------------------------------SubVINode--------------------------------------- 181 // Vector subtract int 182 class SubVINode : public VectorNode { 183 protected: 184 virtual BasicType elt_basic_type() const { return T_INT; } 185 public: 186 SubVINode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 187 virtual int Opcode() const; 188 }; 189 190 //------------------------------SubVLNode--------------------------------------- 191 // Vector subtract long 192 class SubVLNode : public VectorNode { 193 protected: 194 virtual BasicType elt_basic_type() const { return T_LONG; } 195 public: 196 SubVLNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 197 virtual int Opcode() const; 198 }; 199 200 //------------------------------SubVFNode--------------------------------------- 201 // Vector subtract float 202 class SubVFNode : public VectorNode { 203 protected: 204 virtual BasicType elt_basic_type() const { return T_FLOAT; } 205 public: 206 SubVFNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 207 virtual int Opcode() const; 208 }; 209 210 //------------------------------SubVDNode--------------------------------------- 211 // Vector subtract double 212 class SubVDNode : public VectorNode { 213 protected: 214 virtual BasicType elt_basic_type() const { return T_DOUBLE; } 215 public: 216 SubVDNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 217 virtual int Opcode() const; 218 }; 219 220 //------------------------------MulVFNode--------------------------------------- 221 // Vector multiply float 222 class MulVFNode : public VectorNode { 223 protected: 224 virtual BasicType elt_basic_type() const { return T_FLOAT; } 225 public: 226 MulVFNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 227 virtual int Opcode() const; 228 }; 229 230 //------------------------------MulVDNode--------------------------------------- 231 // Vector multiply double 232 class MulVDNode : public VectorNode { 233 protected: 234 virtual BasicType elt_basic_type() const { return T_DOUBLE; } 235 public: 236 MulVDNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 237 virtual int Opcode() const; 238 }; 239 240 //------------------------------DivVFNode--------------------------------------- 241 // Vector divide float 242 class DivVFNode : public VectorNode { 243 protected: 244 virtual BasicType elt_basic_type() const { return T_FLOAT; } 245 public: 246 DivVFNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 247 virtual int Opcode() const; 248 }; 249 250 //------------------------------DivVDNode--------------------------------------- 251 // Vector Divide double 252 class DivVDNode : public VectorNode { 253 protected: 254 virtual BasicType elt_basic_type() const { return T_DOUBLE; } 255 public: 256 DivVDNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 257 virtual int Opcode() const; 258 }; 259 260 //------------------------------LShiftVBNode--------------------------------------- 261 // Vector lshift byte 262 class LShiftVBNode : public VectorNode { 263 protected: 264 virtual BasicType elt_basic_type() const { return T_BYTE; } 265 public: 266 LShiftVBNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 267 virtual int Opcode() const; 268 }; 269 270 //------------------------------LShiftVCNode--------------------------------------- 271 // Vector lshift chars 272 class LShiftVCNode : public VectorNode { 273 protected: 274 virtual BasicType elt_basic_type() const { return T_CHAR; } 275 public: 276 LShiftVCNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 277 virtual int Opcode() const; 278 }; 279 280 //------------------------------LShiftVSNode--------------------------------------- 281 // Vector lshift shorts 282 class LShiftVSNode : public VectorNode { 283 protected: 284 virtual BasicType elt_basic_type() const { return T_SHORT; } 285 public: 286 LShiftVSNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 287 virtual int Opcode() const; 288 }; 289 290 //------------------------------LShiftVINode--------------------------------------- 291 // Vector lshift ints 292 class LShiftVINode : public VectorNode { 293 protected: 294 virtual BasicType elt_basic_type() const { return T_INT; } 295 public: 296 LShiftVINode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 297 virtual int Opcode() const; 298 }; 299 300 //------------------------------URShiftVBNode--------------------------------------- 301 // Vector urshift bytes 302 class URShiftVBNode : public VectorNode { 303 protected: 304 virtual BasicType elt_basic_type() const { return T_BYTE; } 305 public: 306 URShiftVBNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 307 virtual int Opcode() const; 308 }; 309 310 //------------------------------URShiftVCNode--------------------------------------- 311 // Vector urshift char 312 class URShiftVCNode : public VectorNode { 313 protected: 314 virtual BasicType elt_basic_type() const { return T_SHORT; } 315 public: 316 URShiftVCNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 317 virtual int Opcode() const; 318 }; 319 320 //------------------------------URShiftVSNode--------------------------------------- 321 // Vector urshift shorts 322 class URShiftVSNode : public VectorNode { 323 protected: 324 virtual BasicType elt_basic_type() const { return T_SHORT; } 325 public: 326 URShiftVSNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 327 virtual int Opcode() const; 328 }; 329 330 //------------------------------URShiftVINode--------------------------------------- 331 // Vector urshift ints 332 class URShiftVINode : public VectorNode { 333 protected: 334 virtual BasicType elt_basic_type() const { return T_INT; } 335 public: 336 URShiftVINode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {} 337 virtual int Opcode() const; 338 }; 339 340 //------------------------------AndVNode--------------------------------------- 341 // Vector and 342 class AndVNode : public VectorNode { 343 protected: 344 BasicType _bt; 345 virtual BasicType elt_basic_type() const { return _bt; } 346 public: 347 AndVNode(Node* in1, Node* in2, uint vlen, BasicType bt) : VectorNode(in1,in2,vlen), _bt(bt) {} 348 virtual int Opcode() const; 349 }; 350 351 //------------------------------OrVNode--------------------------------------- 352 // Vector or 353 class OrVNode : public VectorNode { 354 protected: 355 BasicType _bt; 356 virtual BasicType elt_basic_type() const { return _bt; } 357 public: 358 OrVNode(Node* in1, Node* in2, uint vlen, BasicType bt) : VectorNode(in1,in2,vlen), _bt(bt) {} 359 virtual int Opcode() const; 360 }; 361 362 //------------------------------XorVNode--------------------------------------- 363 // Vector xor 364 class XorVNode : public VectorNode { 365 protected: 366 BasicType _bt; 367 virtual BasicType elt_basic_type() const { return _bt; } 368 public: 369 XorVNode(Node* in1, Node* in2, uint vlen, BasicType bt) : VectorNode(in1,in2,vlen), _bt(bt) {} 370 virtual int Opcode() const; 371 }; 372 373 //================================= M E M O R Y ================================== 374 375 376 //------------------------------VectorLoadNode-------------------------------------- 377 // Vector Load from memory 378 class VectorLoadNode : public LoadNode { 379 virtual uint size_of() const { return sizeof(*this); } 380 381 protected: 382 virtual BasicType elt_basic_type() const = 0; // Vector element basic type 383 // For use in constructor 384 static const Type* vect_type(const Type* elt_type, uint len) { 385 return VectorNode::vect_type(elt_type, len); 386 } 387 388 public: 389 VectorLoadNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const Type *rt) 390 : LoadNode(c,mem,adr,at,rt) { 391 init_flags(Flag_is_Vector); 392 } 393 virtual int Opcode() const; 394 395 virtual uint length() const = 0; // Vector length 396 397 // Element and vector type 398 const Type* elt_type() const { return Type::get_const_basic_type(elt_basic_type()); } 399 const Type* vect_type() const { return VectorNode::vect_type(elt_basic_type(), length()); } 400 401 virtual uint ideal_reg() const { return Matcher::vector_ideal_reg(); } 402 virtual BasicType memory_type() const { return T_VOID; } 403 virtual int memory_size() const { return length()*type2aelembytes(elt_basic_type()); } 404 405 // Vector opcode from scalar opcode 406 static int opcode(int sopc, uint vlen); 407 408 static VectorLoadNode* make(Compile* C, int opc, Node* ctl, Node* mem, 409 Node* adr, const TypePtr* atyp, uint vlen); 410 }; 411 412 //------------------------------Load16BNode-------------------------------------- 413 // Vector load of 16 bytes (8bits signed) from memory 414 class Load16BNode : public VectorLoadNode { 415 protected: 416 virtual BasicType elt_basic_type() const { return T_BYTE; } 417 public: 418 Load16BNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::BYTE) 419 : VectorLoadNode(c,mem,adr,at,vect_type(ti,16)) {} 420 virtual int Opcode() const; 421 virtual int store_Opcode() const { return Op_Store16B; } 422 virtual uint length() const { return 16; } 423 }; 424 425 //------------------------------Load8BNode-------------------------------------- 426 // Vector load of 8 bytes (8bits signed) from memory 427 class Load8BNode : public VectorLoadNode { 428 protected: 429 virtual BasicType elt_basic_type() const { return T_BYTE; } 430 public: 431 Load8BNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::BYTE) 432 : VectorLoadNode(c,mem,adr,at,vect_type(ti,8)) {} 433 virtual int Opcode() const; 434 virtual int store_Opcode() const { return Op_Store8B; } 435 virtual uint length() const { return 8; } 436 }; 437 438 //------------------------------Load4BNode-------------------------------------- 439 // Vector load of 4 bytes (8bits signed) from memory 440 class Load4BNode : public VectorLoadNode { 441 protected: 442 virtual BasicType elt_basic_type() const { return T_BYTE; } 443 public: 444 Load4BNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::BYTE) 445 : VectorLoadNode(c,mem,adr,at,vect_type(ti,4)) {} 446 virtual int Opcode() const; 447 virtual int store_Opcode() const { return Op_Store4B; } 448 virtual uint length() const { return 4; } 449 }; 450 451 //------------------------------Load8CNode-------------------------------------- 452 // Vector load of 8 chars (16bits unsigned) from memory 453 class Load8CNode : public VectorLoadNode { 454 protected: 455 virtual BasicType elt_basic_type() const { return T_CHAR; } 456 public: 457 Load8CNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::CHAR) 458 : VectorLoadNode(c,mem,adr,at,vect_type(ti,8)) {} 459 virtual int Opcode() const; 460 virtual int store_Opcode() const { return Op_Store8C; } 461 virtual uint length() const { return 8; } 462 }; 463 464 //------------------------------Load4CNode-------------------------------------- 465 // Vector load of 4 chars (16bits unsigned) from memory 466 class Load4CNode : public VectorLoadNode { 467 protected: 468 virtual BasicType elt_basic_type() const { return T_CHAR; } 469 public: 470 Load4CNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::CHAR) 471 : VectorLoadNode(c,mem,adr,at,vect_type(ti,4)) {} 472 virtual int Opcode() const; 473 virtual int store_Opcode() const { return Op_Store4C; } 474 virtual uint length() const { return 4; } 475 }; 476 477 //------------------------------Load2CNode-------------------------------------- 478 // Vector load of 2 chars (16bits unsigned) from memory 479 class Load2CNode : public VectorLoadNode { 480 protected: 481 virtual BasicType elt_basic_type() const { return T_CHAR; } 482 public: 483 Load2CNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::CHAR) 484 : VectorLoadNode(c,mem,adr,at,vect_type(ti,2)) {} 485 virtual int Opcode() const; 486 virtual int store_Opcode() const { return Op_Store2C; } 487 virtual uint length() const { return 2; } 488 }; 489 490 //------------------------------Load8SNode-------------------------------------- 491 // Vector load of 8 shorts (16bits signed) from memory 492 class Load8SNode : public VectorLoadNode { 493 protected: 494 virtual BasicType elt_basic_type() const { return T_SHORT; } 495 public: 496 Load8SNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::SHORT) 497 : VectorLoadNode(c,mem,adr,at,vect_type(ti,8)) {} 498 virtual int Opcode() const; 499 virtual int store_Opcode() const { return Op_Store8C; } 500 virtual uint length() const { return 8; } 501 }; 502 503 //------------------------------Load4SNode-------------------------------------- 504 // Vector load of 4 shorts (16bits signed) from memory 505 class Load4SNode : public VectorLoadNode { 506 protected: 507 virtual BasicType elt_basic_type() const { return T_SHORT; } 508 public: 509 Load4SNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::SHORT) 510 : VectorLoadNode(c,mem,adr,at,vect_type(ti,4)) {} 511 virtual int Opcode() const; 512 virtual int store_Opcode() const { return Op_Store4C; } 513 virtual uint length() const { return 4; } 514 }; 515 516 //------------------------------Load2SNode-------------------------------------- 517 // Vector load of 2 shorts (16bits signed) from memory 518 class Load2SNode : public VectorLoadNode { 519 protected: 520 virtual BasicType elt_basic_type() const { return T_SHORT; } 521 public: 522 Load2SNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::SHORT) 523 : VectorLoadNode(c,mem,adr,at,vect_type(ti,2)) {} 524 virtual int Opcode() const; 525 virtual int store_Opcode() const { return Op_Store2C; } 526 virtual uint length() const { return 2; } 527 }; 528 529 //------------------------------Load4INode-------------------------------------- 530 // Vector load of 4 integers (32bits signed) from memory 531 class Load4INode : public VectorLoadNode { 532 protected: 533 virtual BasicType elt_basic_type() const { return T_INT; } 534 public: 535 Load4INode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::INT) 536 : VectorLoadNode(c,mem,adr,at,vect_type(ti,4)) {} 537 virtual int Opcode() const; 538 virtual int store_Opcode() const { return Op_Store4I; } 539 virtual uint length() const { return 4; } 540 }; 541 542 //------------------------------Load2INode-------------------------------------- 543 // Vector load of 2 integers (32bits signed) from memory 544 class Load2INode : public VectorLoadNode { 545 protected: 546 virtual BasicType elt_basic_type() const { return T_INT; } 547 public: 548 Load2INode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::INT) 549 : VectorLoadNode(c,mem,adr,at,vect_type(ti,2)) {} 550 virtual int Opcode() const; 551 virtual int store_Opcode() const { return Op_Store2I; } 552 virtual uint length() const { return 2; } 553 }; 554 555 //------------------------------Load2LNode-------------------------------------- 556 // Vector load of 2 longs (64bits signed) from memory 557 class Load2LNode : public VectorLoadNode { 558 protected: 559 virtual BasicType elt_basic_type() const { return T_LONG; } 560 public: 561 Load2LNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeLong *tl = TypeLong::LONG) 562 : VectorLoadNode(c,mem,adr,at,vect_type(tl,2)) {} 563 virtual int Opcode() const; 564 virtual int store_Opcode() const { return Op_Store2L; } 565 virtual uint length() const { return 2; } 566 }; 567 568 //------------------------------Load4FNode-------------------------------------- 569 // Vector load of 4 floats (32bits) from memory 570 class Load4FNode : public VectorLoadNode { 571 protected: 572 virtual BasicType elt_basic_type() const { return T_FLOAT; } 573 public: 574 Load4FNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const Type *t = Type::FLOAT) 575 : VectorLoadNode(c,mem,adr,at,vect_type(t,4)) {} 576 virtual int Opcode() const; 577 virtual int store_Opcode() const { return Op_Store4F; } 578 virtual uint length() const { return 4; } 579 }; 580 581 //------------------------------Load2FNode-------------------------------------- 582 // Vector load of 2 floats (32bits) from memory 583 class Load2FNode : public VectorLoadNode { 584 protected: 585 virtual BasicType elt_basic_type() const { return T_FLOAT; } 586 public: 587 Load2FNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const Type *t = Type::FLOAT) 588 : VectorLoadNode(c,mem,adr,at,vect_type(t,2)) {} 589 virtual int Opcode() const; 590 virtual int store_Opcode() const { return Op_Store2F; } 591 virtual uint length() const { return 2; } 592 }; 593 594 //------------------------------Load2DNode-------------------------------------- 595 // Vector load of 2 doubles (64bits) from memory 596 class Load2DNode : public VectorLoadNode { 597 protected: 598 virtual BasicType elt_basic_type() const { return T_DOUBLE; } 599 public: 600 Load2DNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const Type *t = Type::DOUBLE) 601 : VectorLoadNode(c,mem,adr,at,vect_type(t,2)) {} 602 virtual int Opcode() const; 603 virtual int store_Opcode() const { return Op_Store2D; } 604 virtual uint length() const { return 2; } 605 }; 606 607 608 //------------------------------VectorStoreNode-------------------------------------- 609 // Vector Store to memory 610 class VectorStoreNode : public StoreNode { 611 virtual uint size_of() const { return sizeof(*this); } 612 613 protected: 614 virtual BasicType elt_basic_type() const = 0; // Vector element basic type 615 616 public: 617 VectorStoreNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val) 618 : StoreNode(c,mem,adr,at,val) { 619 init_flags(Flag_is_Vector); 620 } 621 virtual int Opcode() const; 622 623 virtual uint length() const = 0; // Vector length 624 625 // Element and vector type 626 const Type* elt_type() const { return Type::get_const_basic_type(elt_basic_type()); } 627 const Type* vect_type() const { return VectorNode::vect_type(elt_basic_type(), length()); } 628 629 virtual uint ideal_reg() const { return Matcher::vector_ideal_reg(); } 630 virtual BasicType memory_type() const { return T_VOID; } 631 virtual int memory_size() const { return length()*type2aelembytes(elt_basic_type()); } 632 633 // Vector opcode from scalar opcode 634 static int opcode(int sopc, uint vlen); 635 636 static VectorStoreNode* make(Compile* C, int opc, Node* ctl, Node* mem, 637 Node* adr, const TypePtr* atyp, VectorNode* val, 638 uint vlen); 639 }; 640 641 //------------------------------Store16BNode-------------------------------------- 642 // Vector store of 16 bytes (8bits signed) to memory 643 class Store16BNode : public VectorStoreNode { 644 protected: 645 virtual BasicType elt_basic_type() const { return T_BYTE; } 646 public: 647 Store16BNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val) 648 : VectorStoreNode(c,mem,adr,at,val) {} 649 virtual int Opcode() const; 650 virtual uint length() const { return 16; } 651 }; 652 653 //------------------------------Store8BNode-------------------------------------- 654 // Vector store of 8 bytes (8bits signed) to memory 655 class Store8BNode : public VectorStoreNode { 656 protected: 657 virtual BasicType elt_basic_type() const { return T_BYTE; } 658 public: 659 Store8BNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val) 660 : VectorStoreNode(c,mem,adr,at,val) {} 661 virtual int Opcode() const; 662 virtual uint length() const { return 8; } 663 }; 664 665 //------------------------------Store4BNode-------------------------------------- 666 // Vector store of 4 bytes (8bits signed) to memory 667 class Store4BNode : public VectorStoreNode { 668 protected: 669 virtual BasicType elt_basic_type() const { return T_BYTE; } 670 public: 671 Store4BNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val) 672 : VectorStoreNode(c,mem,adr,at,val) {} 673 virtual int Opcode() const; 674 virtual uint length() const { return 4; } 675 }; 676 677 //------------------------------Store8CNode-------------------------------------- 678 // Vector store of 8 chars (16bits signed/unsigned) to memory 679 class Store8CNode : public VectorStoreNode { 680 protected: 681 virtual BasicType elt_basic_type() const { return T_CHAR; } 682 public: 683 Store8CNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val) 684 : VectorStoreNode(c,mem,adr,at,val) {} 685 virtual int Opcode() const; 686 virtual uint length() const { return 8; } 687 }; 688 689 //------------------------------Store4CNode-------------------------------------- 690 // Vector store of 4 chars (16bits signed/unsigned) to memory 691 class Store4CNode : public VectorStoreNode { 692 protected: 693 virtual BasicType elt_basic_type() const { return T_CHAR; } 694 public: 695 Store4CNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val) 696 : VectorStoreNode(c,mem,adr,at,val) {} 697 virtual int Opcode() const; 698 virtual uint length() const { return 4; } 699 }; 700 701 //------------------------------Store2CNode-------------------------------------- 702 // Vector store of 2 chars (16bits signed/unsigned) to memory 703 class Store2CNode : public VectorStoreNode { 704 protected: 705 virtual BasicType elt_basic_type() const { return T_CHAR; } 706 public: 707 Store2CNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val) 708 : VectorStoreNode(c,mem,adr,at,val) {} 709 virtual int Opcode() const; 710 virtual uint length() const { return 2; } 711 }; 712 713 //------------------------------Store4INode-------------------------------------- 714 // Vector store of 4 integers (32bits signed) to memory 715 class Store4INode : public VectorStoreNode { 716 protected: 717 virtual BasicType elt_basic_type() const { return T_INT; } 718 public: 719 Store4INode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val) 720 : VectorStoreNode(c,mem,adr,at,val) {} 721 virtual int Opcode() const; 722 virtual uint length() const { return 4; } 723 }; 724 725 //------------------------------Store2INode-------------------------------------- 726 // Vector store of 2 integers (32bits signed) to memory 727 class Store2INode : public VectorStoreNode { 728 protected: 729 virtual BasicType elt_basic_type() const { return T_INT; } 730 public: 731 Store2INode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val) 732 : VectorStoreNode(c,mem,adr,at,val) {} 733 virtual int Opcode() const; 734 virtual uint length() const { return 2; } 735 }; 736 737 //------------------------------Store2LNode-------------------------------------- 738 // Vector store of 2 longs (64bits signed) to memory 739 class Store2LNode : public VectorStoreNode { 740 protected: 741 virtual BasicType elt_basic_type() const { return T_LONG; } 742 public: 743 Store2LNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val) 744 : VectorStoreNode(c,mem,adr,at,val) {} 745 virtual int Opcode() const; 746 virtual uint length() const { return 2; } 747 }; 748 749 //------------------------------Store4FNode-------------------------------------- 750 // Vector store of 4 floats (32bits) to memory 751 class Store4FNode : public VectorStoreNode { 752 protected: 753 virtual BasicType elt_basic_type() const { return T_FLOAT; } 754 public: 755 Store4FNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val) 756 : VectorStoreNode(c,mem,adr,at,val) {} 757 virtual int Opcode() const; 758 virtual uint length() const { return 4; } 759 }; 760 761 //------------------------------Store2FNode-------------------------------------- 762 // Vector store of 2 floats (32bits) to memory 763 class Store2FNode : public VectorStoreNode { 764 protected: 765 virtual BasicType elt_basic_type() const { return T_FLOAT; } 766 public: 767 Store2FNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val) 768 : VectorStoreNode(c,mem,adr,at,val) {} 769 virtual int Opcode() const; 770 virtual uint length() const { return 2; } 771 }; 772 773 //------------------------------Store2DNode-------------------------------------- 774 // Vector store of 2 doubles (64bits) to memory 775 class Store2DNode : public VectorStoreNode { 776 protected: 777 virtual BasicType elt_basic_type() const { return T_DOUBLE; } 778 public: 779 Store2DNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val) 780 : VectorStoreNode(c,mem,adr,at,val) {} 781 virtual int Opcode() const; 782 virtual uint length() const { return 2; } 783 }; 784 785 //=========================Promote_Scalar_to_Vector==================================== 786 787 //------------------------------Replicate16BNode--------------------------------------- 788 // Replicate byte scalar to be vector of 16 bytes 789 class Replicate16BNode : public VectorNode { 790 protected: 791 virtual BasicType elt_basic_type() const { return T_BYTE; } 792 public: 793 Replicate16BNode(Node* in1) : VectorNode(in1, 16) {} 794 virtual int Opcode() const; 795 }; 796 797 //------------------------------Replicate8BNode--------------------------------------- 798 // Replicate byte scalar to be vector of 8 bytes 799 class Replicate8BNode : public VectorNode { 800 protected: 801 virtual BasicType elt_basic_type() const { return T_BYTE; } 802 public: 803 Replicate8BNode(Node* in1) : VectorNode(in1, 8) {} 804 virtual int Opcode() const; 805 }; 806 807 //------------------------------Replicate4BNode--------------------------------------- 808 // Replicate byte scalar to be vector of 4 bytes 809 class Replicate4BNode : public VectorNode { 810 protected: 811 virtual BasicType elt_basic_type() const { return T_BYTE; } 812 public: 813 Replicate4BNode(Node* in1) : VectorNode(in1, 4) {} 814 virtual int Opcode() const; 815 }; 816 817 //------------------------------Replicate8CNode--------------------------------------- 818 // Replicate char scalar to be vector of 8 chars 819 class Replicate8CNode : public VectorNode { 820 protected: 821 virtual BasicType elt_basic_type() const { return T_CHAR; } 822 public: 823 Replicate8CNode(Node* in1) : VectorNode(in1, 8) {} 824 virtual int Opcode() const; 825 }; 826 827 //------------------------------Replicate4CNode--------------------------------------- 828 // Replicate char scalar to be vector of 4 chars 829 class Replicate4CNode : public VectorNode { 830 protected: 831 virtual BasicType elt_basic_type() const { return T_CHAR; } 832 public: 833 Replicate4CNode(Node* in1) : VectorNode(in1, 4) {} 834 virtual int Opcode() const; 835 }; 836 837 //------------------------------Replicate2CNode--------------------------------------- 838 // Replicate char scalar to be vector of 2 chars 839 class Replicate2CNode : public VectorNode { 840 protected: 841 virtual BasicType elt_basic_type() const { return T_CHAR; } 842 public: 843 Replicate2CNode(Node* in1) : VectorNode(in1, 2) {} 844 virtual int Opcode() const; 845 }; 846 847 //------------------------------Replicate8SNode--------------------------------------- 848 // Replicate short scalar to be vector of 8 shorts 849 class Replicate8SNode : public VectorNode { 850 protected: 851 virtual BasicType elt_basic_type() const { return T_SHORT; } 852 public: 853 Replicate8SNode(Node* in1) : VectorNode(in1, 8) {} 854 virtual int Opcode() const; 855 }; 856 857 //------------------------------Replicate4SNode--------------------------------------- 858 // Replicate short scalar to be vector of 4 shorts 859 class Replicate4SNode : public VectorNode { 860 protected: 861 virtual BasicType elt_basic_type() const { return T_SHORT; } 862 public: 863 Replicate4SNode(Node* in1) : VectorNode(in1, 4) {} 864 virtual int Opcode() const; 865 }; 866 867 //------------------------------Replicate2SNode--------------------------------------- 868 // Replicate short scalar to be vector of 2 shorts 869 class Replicate2SNode : public VectorNode { 870 protected: 871 virtual BasicType elt_basic_type() const { return T_SHORT; } 872 public: 873 Replicate2SNode(Node* in1) : VectorNode(in1, 2) {} 874 virtual int Opcode() const; 875 }; 876 877 //------------------------------Replicate4INode--------------------------------------- 878 // Replicate int scalar to be vector of 4 ints 879 class Replicate4INode : public VectorNode { 880 protected: 881 virtual BasicType elt_basic_type() const { return T_INT; } 882 public: 883 Replicate4INode(Node* in1) : VectorNode(in1, 4) {} 884 virtual int Opcode() const; 885 }; 886 887 //------------------------------Replicate2INode--------------------------------------- 888 // Replicate int scalar to be vector of 2 ints 889 class Replicate2INode : public VectorNode { 890 protected: 891 virtual BasicType elt_basic_type() const { return T_INT; } 892 public: 893 Replicate2INode(Node* in1) : VectorNode(in1, 2) {} 894 virtual int Opcode() const; 895 }; 896 897 //------------------------------Replicate2LNode--------------------------------------- 898 // Replicate long scalar to be vector of 2 longs 899 class Replicate2LNode : public VectorNode { 900 protected: 901 virtual BasicType elt_basic_type() const { return T_LONG; } 902 public: 903 Replicate2LNode(Node* in1) : VectorNode(in1, 2) {} 904 virtual int Opcode() const; 905 }; 906 907 //------------------------------Replicate4FNode--------------------------------------- 908 // Replicate float scalar to be vector of 4 floats 909 class Replicate4FNode : public VectorNode { 910 protected: 911 virtual BasicType elt_basic_type() const { return T_FLOAT; } 912 public: 913 Replicate4FNode(Node* in1) : VectorNode(in1, 4) {} 914 virtual int Opcode() const; 915 }; 916 917 //------------------------------Replicate2FNode--------------------------------------- 918 // Replicate float scalar to be vector of 2 floats 919 class Replicate2FNode : public VectorNode { 920 protected: 921 virtual BasicType elt_basic_type() const { return T_FLOAT; } 922 public: 923 Replicate2FNode(Node* in1) : VectorNode(in1, 2) {} 924 virtual int Opcode() const; 925 }; 926 927 //------------------------------Replicate2DNode--------------------------------------- 928 // Replicate double scalar to be vector of 2 doubles 929 class Replicate2DNode : public VectorNode { 930 protected: 931 virtual BasicType elt_basic_type() const { return T_DOUBLE; } 932 public: 933 Replicate2DNode(Node* in1) : VectorNode(in1, 2) {} 934 virtual int Opcode() const; 935 }; 936 937 //========================Pack_Scalars_into_a_Vector============================== 938 939 //------------------------------PackNode--------------------------------------- 940 // Pack parent class (not for code generation). 941 class PackNode : public VectorNode { 942 public: 943 PackNode(Node* in1) : VectorNode(in1, 1) {} 944 PackNode(Node* in1, Node* n2) : VectorNode(in1, n2, 2) {} 945 virtual int Opcode() const; 946 947 void add_opd(Node* n) { 948 add_req(n); 949 _length++; 950 assert(_length == req() - 1, "vector length matches edge count"); 951 } 952 953 // Create a binary tree form for Packs. [lo, hi) (half-open) range 954 Node* binaryTreePack(Compile* C, int lo, int hi); 955 956 static PackNode* make(Compile* C, Node* s, const Type* elt_t); 957 }; 958 959 //------------------------------PackBNode--------------------------------------- 960 // Pack byte scalars into vector 961 class PackBNode : public PackNode { 962 protected: 963 virtual BasicType elt_basic_type() const { return T_BYTE; } 964 public: 965 PackBNode(Node* in1) : PackNode(in1) {} 966 virtual int Opcode() const; 967 }; 968 969 //------------------------------PackCNode--------------------------------------- 970 // Pack char scalars into vector 971 class PackCNode : public PackNode { 972 protected: 973 virtual BasicType elt_basic_type() const { return T_CHAR; } 974 public: 975 PackCNode(Node* in1) : PackNode(in1) {} 976 virtual int Opcode() const; 977 }; 978 979 //------------------------------PackSNode--------------------------------------- 980 // Pack short scalars into a vector 981 class PackSNode : public PackNode { 982 protected: 983 virtual BasicType elt_basic_type() const { return T_SHORT; } 984 public: 985 PackSNode(Node* in1) : PackNode(in1) {} 986 virtual int Opcode() const; 987 }; 988 989 //------------------------------PackINode--------------------------------------- 990 // Pack integer scalars into a vector 991 class PackINode : public PackNode { 992 protected: 993 virtual BasicType elt_basic_type() const { return T_INT; } 994 public: 995 PackINode(Node* in1) : PackNode(in1) {} 996 PackINode(Node* in1, Node* in2) : PackNode(in1, in2) {} 997 virtual int Opcode() const; 998 }; 999 1000 //------------------------------PackLNode--------------------------------------- 1001 // Pack long scalars into a vector 1002 class PackLNode : public PackNode { 1003 protected: 1004 virtual BasicType elt_basic_type() const { return T_LONG; } 1005 public: 1006 PackLNode(Node* in1) : PackNode(in1) {} 1007 PackLNode(Node* in1, Node* in2) : PackNode(in1, in2) {} 1008 virtual int Opcode() const; 1009 }; 1010 1011 //------------------------------PackFNode--------------------------------------- 1012 // Pack float scalars into vector 1013 class PackFNode : public PackNode { 1014 protected: 1015 virtual BasicType elt_basic_type() const { return T_FLOAT; } 1016 public: 1017 PackFNode(Node* in1) : PackNode(in1) {} 1018 PackFNode(Node* in1, Node* in2) : PackNode(in1, in2) {} 1019 virtual int Opcode() const; 1020 }; 1021 1022 //------------------------------PackDNode--------------------------------------- 1023 // Pack double scalars into a vector 1024 class PackDNode : public PackNode { 1025 protected: 1026 virtual BasicType elt_basic_type() const { return T_DOUBLE; } 1027 public: 1028 PackDNode(Node* in1) : PackNode(in1) {} 1029 PackDNode(Node* in1, Node* in2) : PackNode(in1, in2) {} 1030 virtual int Opcode() const; 1031 }; 1032 1033 // The Pack2xN nodes assist code generation. They are created from 1034 // Pack4C, etc. nodes in final_graph_reshape in the form of a 1035 // balanced, binary tree. 1036 1037 //------------------------------Pack2x1BNode----------------------------------------- 1038 // Pack 2 1-byte integers into vector of 2 bytes 1039 class Pack2x1BNode : public PackNode { 1040 protected: 1041 virtual BasicType elt_basic_type() const { return T_BYTE; } 1042 public: 1043 Pack2x1BNode(Node *in1, Node* in2) : PackNode(in1, in2) {} 1044 virtual int Opcode() const; 1045 virtual uint ideal_reg() const { return Op_RegI; } 1046 }; 1047 1048 //------------------------------Pack2x2BNode--------------------------------------- 1049 // Pack 2 2-byte integers into vector of 4 bytes 1050 class Pack2x2BNode : public PackNode { 1051 protected: 1052 virtual BasicType elt_basic_type() const { return T_CHAR; } 1053 public: 1054 Pack2x2BNode(Node *in1, Node* in2) : PackNode(in1, in2) {} 1055 virtual int Opcode() const; 1056 virtual uint ideal_reg() const { return Op_RegI; } 1057 }; 1058 1059 //========================Extract_Scalar_from_Vector=============================== 1060 1061 //------------------------------ExtractNode--------------------------------------- 1062 // Extract a scalar from a vector at position "pos" 1063 class ExtractNode : public Node { 1064 public: 1065 ExtractNode(Node* src, ConINode* pos) : Node(NULL, src, (Node*)pos) { 1066 assert(in(2)->get_int() >= 0, "positive constants"); 1067 } 1068 virtual int Opcode() const; 1069 uint pos() const { return in(2)->get_int(); } 1070 1071 static Node* make(Compile* C, Node* v, uint position, const Type* opd_t); 1072 }; 1073 1074 //------------------------------ExtractBNode--------------------------------------- 1075 // Extract a byte from a vector at position "pos" 1076 class ExtractBNode : public ExtractNode { 1077 public: 1078 ExtractBNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 1079 virtual int Opcode() const; 1080 virtual const Type *bottom_type() const { return TypeInt::INT; } 1081 virtual uint ideal_reg() const { return Op_RegI; } 1082 }; 1083 1084 //------------------------------ExtractCNode--------------------------------------- 1085 // Extract a char from a vector at position "pos" 1086 class ExtractCNode : public ExtractNode { 1087 public: 1088 ExtractCNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 1089 virtual int Opcode() const; 1090 virtual const Type *bottom_type() const { return TypeInt::INT; } 1091 virtual uint ideal_reg() const { return Op_RegI; } 1092 }; 1093 1094 //------------------------------ExtractSNode--------------------------------------- 1095 // Extract a short from a vector at position "pos" 1096 class ExtractSNode : public ExtractNode { 1097 public: 1098 ExtractSNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 1099 virtual int Opcode() const; 1100 virtual const Type *bottom_type() const { return TypeInt::INT; } 1101 virtual uint ideal_reg() const { return Op_RegI; } 1102 }; 1103 1104 //------------------------------ExtractINode--------------------------------------- 1105 // Extract an int from a vector at position "pos" 1106 class ExtractINode : public ExtractNode { 1107 public: 1108 ExtractINode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 1109 virtual int Opcode() const; 1110 virtual const Type *bottom_type() const { return TypeInt::INT; } 1111 virtual uint ideal_reg() const { return Op_RegI; } 1112 }; 1113 1114 //------------------------------ExtractLNode--------------------------------------- 1115 // Extract a long from a vector at position "pos" 1116 class ExtractLNode : public ExtractNode { 1117 public: 1118 ExtractLNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 1119 virtual int Opcode() const; 1120 virtual const Type *bottom_type() const { return TypeLong::LONG; } 1121 virtual uint ideal_reg() const { return Op_RegL; } 1122 }; 1123 1124 //------------------------------ExtractFNode--------------------------------------- 1125 // Extract a float from a vector at position "pos" 1126 class ExtractFNode : public ExtractNode { 1127 public: 1128 ExtractFNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 1129 virtual int Opcode() const; 1130 virtual const Type *bottom_type() const { return Type::FLOAT; } 1131 virtual uint ideal_reg() const { return Op_RegF; } 1132 }; 1133 1134 //------------------------------ExtractDNode--------------------------------------- 1135 // Extract a double from a vector at position "pos" 1136 class ExtractDNode : public ExtractNode { 1137 public: 1138 ExtractDNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {} 1139 virtual int Opcode() const; 1140 virtual const Type *bottom_type() const { return Type::DOUBLE; } 1141 virtual uint ideal_reg() const { return Op_RegD; } 1142 }; 1143 1144 #endif // SHARE_VM_OPTO_VECTORNODE_HPP