161 assert(bt == T_DOUBLE, "must be"); 162 return Op_AbsVD; 163 case Op_NegI: 164 assert(bt == T_INT, "must be"); 165 return Op_NegVI; 166 case Op_NegF: 167 assert(bt == T_FLOAT, "must be"); 168 return Op_NegVF; 169 case Op_NegD: 170 assert(bt == T_DOUBLE, "must be"); 171 return Op_NegVD; 172 case Op_RoundDoubleMode: 173 assert(bt == T_DOUBLE, "must be"); 174 return Op_RoundDoubleModeV; 175 case Op_SqrtF: 176 assert(bt == T_FLOAT, "must be"); 177 return Op_SqrtVF; 178 case Op_SqrtD: 179 assert(bt == T_DOUBLE, "must be"); 180 return Op_SqrtVD; 181 case Op_Not: 182 return Op_NotV; 183 case Op_PopCountI: 184 if (bt == T_INT) { 185 return Op_PopCountVI; 186 } 187 // Unimplemented for subword types since bit count changes 188 // depending on size of lane (and sign bit). 189 return 0; 190 case Op_LShiftI: 191 switch (bt) { 192 case T_BOOLEAN: 193 case T_BYTE: return Op_LShiftVB; 194 case T_CHAR: 195 case T_SHORT: return Op_LShiftVS; 196 case T_INT: return Op_LShiftVI; 197 default: ShouldNotReachHere(); return 0; 198 } 199 case Op_LShiftL: 200 assert(bt == T_LONG, "must be"); 201 return Op_LShiftVL; 202 case Op_RShiftI: 268 } 269 } 270 271 int VectorNode::replicate_opcode(BasicType bt) { 272 switch(bt) { 273 case T_BOOLEAN: 274 case T_BYTE: 275 return Op_ReplicateB; 276 case T_SHORT: 277 case T_CHAR: 278 return Op_ReplicateS; 279 case T_INT: 280 return Op_ReplicateI; 281 case T_LONG: 282 return Op_ReplicateL; 283 case T_FLOAT: 284 return Op_ReplicateF; 285 case T_DOUBLE: 286 return Op_ReplicateD; 287 default: 288 break; 289 } 290 291 return 0; 292 } 293 294 // Also used to check if the code generator 295 // supports the vector operation. 296 bool VectorNode::implemented(int opc, uint vlen, BasicType bt) { 297 if (is_java_primitive(bt) && 298 (vlen > 1) && is_power_of_2(vlen) && 299 Matcher::vector_size_supported(bt, vlen)) { 300 int vopc = VectorNode::opcode(opc, bt); 301 return vopc > 0 && Matcher::match_rule_supported_vector(vopc, vlen, bt); 302 } 303 return false; 304 } 305 306 bool VectorNode::is_type_transition_short_to_int(Node* n) { 307 switch (n->Opcode()) { 308 case Op_MulAddS2I: 309 return true; 310 } 311 return false; 326 if (n->Opcode() == Op_RoundDoubleMode) { 327 return true; 328 } 329 return false; 330 } 331 332 bool VectorNode::is_shift(Node* n) { 333 switch (n->Opcode()) { 334 case Op_LShiftI: 335 case Op_LShiftL: 336 case Op_RShiftI: 337 case Op_RShiftL: 338 case Op_URShiftI: 339 case Op_URShiftL: 340 return true; 341 default: 342 return false; 343 } 344 } 345 346 bool VectorNode::is_vshift(Node* n) { 347 switch (n->Opcode()) { 348 case Op_LShiftVB: 349 case Op_LShiftVS: 350 case Op_LShiftVI: 351 case Op_LShiftVL: 352 353 case Op_RShiftVB: 354 case Op_RShiftVS: 355 case Op_RShiftVI: 356 case Op_RShiftVL: 357 358 case Op_URShiftVB: 359 case Op_URShiftVS: 360 case Op_URShiftVI: 361 case Op_URShiftVL: 362 return true; 363 default: 364 return false; 365 } 366 } 367 368 bool VectorNode::is_vshift_cnt(Node* n) { 369 switch (n->Opcode()) { 370 case Op_LShiftCntV: 371 case Op_RShiftCntV: 372 return true; 373 default: 374 return false; 375 } 376 } 377 378 // Check if input is loop invariant vector. 379 bool VectorNode::is_invariant_vector(Node* n) { 380 // Only Replicate vector nodes are loop invariant for now. 381 switch (n->Opcode()) { 382 case Op_ReplicateB: 383 case Op_ReplicateS: 384 case Op_ReplicateI: 385 case Op_ReplicateL: 386 case Op_ReplicateF: 387 case Op_ReplicateD: 456 case Op_SubVB: return new SubVBNode(n1, n2, vt); 457 case Op_SubVS: return new SubVSNode(n1, n2, vt); 458 case Op_SubVI: return new SubVINode(n1, n2, vt); 459 case Op_SubVL: return new SubVLNode(n1, n2, vt); 460 case Op_SubVF: return new SubVFNode(n1, n2, vt); 461 case Op_SubVD: return new SubVDNode(n1, n2, vt); 462 463 case Op_MulVB: return new MulVBNode(n1, n2, vt); 464 case Op_MulVS: return new MulVSNode(n1, n2, vt); 465 case Op_MulVI: return new MulVINode(n1, n2, vt); 466 case Op_MulVL: return new MulVLNode(n1, n2, vt); 467 case Op_MulVF: return new MulVFNode(n1, n2, vt); 468 case Op_MulVD: return new MulVDNode(n1, n2, vt); 469 470 case Op_DivVF: return new DivVFNode(n1, n2, vt); 471 case Op_DivVD: return new DivVDNode(n1, n2, vt); 472 473 case Op_MinV: return new MinVNode(n1, n2, vt); 474 case Op_MaxV: return new MaxVNode(n1, n2, vt); 475 476 case Op_AbsV: return new AbsVNode(n1, vt); 477 case Op_AbsVF: return new AbsVFNode(n1, vt); 478 case Op_AbsVD: return new AbsVDNode(n1, vt); 479 case Op_AbsVB: return new AbsVBNode(n1, vt); 480 case Op_AbsVS: return new AbsVSNode(n1, vt); 481 case Op_AbsVI: return new AbsVINode(n1, vt); 482 case Op_AbsVL: return new AbsVLNode(n1, vt); 483 484 case Op_NegVI: return new NegVINode(n1, vt); 485 case Op_NegVF: return new NegVFNode(n1, vt); 486 case Op_NegVD: return new NegVDNode(n1, vt); 487 488 case Op_SqrtVF: return new SqrtVFNode(n1, vt); 489 case Op_SqrtVD: return new SqrtVDNode(n1, vt); 490 491 case Op_PopCountVI: return new PopCountVINode(n1, vt); 492 case Op_NotV: return new NotVNode(n1, vt); 493 494 case Op_LShiftVB: return new LShiftVBNode(n1, n2, vt); 495 case Op_LShiftVS: return new LShiftVSNode(n1, n2, vt); 496 case Op_LShiftVI: return new LShiftVINode(n1, n2, vt); 497 case Op_LShiftVL: return new LShiftVLNode(n1, n2, vt); 498 499 case Op_RShiftVB: return new RShiftVBNode(n1, n2, vt); 500 case Op_RShiftVS: return new RShiftVSNode(n1, n2, vt); 501 case Op_RShiftVI: return new RShiftVINode(n1, n2, vt); 502 case Op_RShiftVL: return new RShiftVLNode(n1, n2, vt); 503 504 case Op_URShiftVB: return new URShiftVBNode(n1, n2, vt); 505 case Op_URShiftVS: return new URShiftVSNode(n1, n2, vt); 506 case Op_URShiftVI: return new URShiftVINode(n1, n2, vt); 507 case Op_URShiftVL: return new URShiftVLNode(n1, n2, vt); 508 509 // Variable shift left 510 case Op_VLShiftV: return new VLShiftVNode(n1, n2, vt); 511 case Op_VRShiftV: return new VRShiftVNode(n1, n2, vt); 512 case Op_VURShiftV: return new VURShiftVNode(n1, n2, vt); 513 514 case Op_AndV: return new AndVNode(n1, n2, vt); 515 case Op_OrV: return new OrVNode (n1, n2, vt); 516 case Op_XorV: return new XorVNode(n1, n2, vt); 517 518 case Op_RoundDoubleModeV: return new RoundDoubleModeVNode(n1, n2, vt); 519 520 case Op_MulAddVS2VI: return new MulAddVS2VINode(n1, n2, vt); 521 default: 522 fatal("Missed vector creation for '%s'", NodeClassNames[vopc]); 523 return NULL; 524 } 525 } 526 527 // Return the vector version of a scalar binary operation node. 528 VectorNode* VectorNode::make(int opc, Node* n1, Node* n2, uint vlen, BasicType bt) { 529 const TypeVect* vt = TypeVect::make(bt, vlen); 530 int vopc = VectorNode::opcode(opc, bt); 531 // This method should not be called for unimplemented vectors. 532 guarantee(vopc > 0, "Vector for '%s' is not implemented", NodeClassNames[opc]); 533 return make(vopc, n1, n2, vt); 728 } 729 730 // Return the vector version of a scalar load node. 731 LoadVectorNode* LoadVectorNode::make(int opc, Node* ctl, Node* mem, 732 Node* adr, const TypePtr* atyp, 733 uint vlen, BasicType bt, 734 ControlDependency control_dependency) { 735 const TypeVect* vt = TypeVect::make(bt, vlen); 736 return new LoadVectorNode(ctl, mem, adr, atyp, vt, control_dependency); 737 } 738 739 // Return the vector version of a scalar store node. 740 StoreVectorNode* StoreVectorNode::make(int opc, Node* ctl, Node* mem, 741 Node* adr, const TypePtr* atyp, Node* val, 742 uint vlen) { 743 return new StoreVectorNode(ctl, mem, adr, atyp, val); 744 } 745 746 int ExtractNode::opcode(BasicType bt) { 747 switch (bt) { 748 case T_BOOLEAN: 749 return Op_ExtractUB; 750 case T_BYTE: 751 return Op_ExtractB; 752 case T_CHAR: 753 return Op_ExtractC; 754 case T_SHORT: 755 return Op_ExtractS; 756 case T_INT: 757 return Op_ExtractI; 758 case T_LONG: 759 return Op_ExtractL; 760 case T_FLOAT: 761 return Op_ExtractF; 762 case T_DOUBLE: 763 return Op_ExtractD; 764 default: 765 fatal("Type '%s' is not supported for vectors", type2name(bt)); 766 return 0; 767 } 768 } 769 770 // Extract a scalar element of vector. 771 Node* ExtractNode::make(Node* v, uint position, BasicType bt) { 772 assert((int)position < Matcher::max_vector_size(bt), "pos in range"); 773 ConINode* pos = ConINode::make((int)position); 774 switch (bt) { 775 case T_BOOLEAN: 776 return new ExtractUBNode(v, pos); 777 case T_BYTE: 778 return new ExtractBNode(v, pos); 779 case T_CHAR: 780 return new ExtractCNode(v, pos); 781 case T_SHORT: 782 return new ExtractSNode(v, pos); 783 case T_INT: 784 return new ExtractINode(v, pos); 785 case T_LONG: 786 return new ExtractLNode(v, pos); 787 case T_FLOAT: 788 return new ExtractFNode(v, pos); 789 case T_DOUBLE: 790 return new ExtractDNode(v, pos); 791 default: 792 fatal("Type '%s' is not supported for vectors", type2name(bt)); 793 return NULL; 794 } 795 } 796 797 int ReductionNode::opcode(int opc, BasicType bt) { 798 int vopc = opc; 799 switch (opc) { 800 case Op_AddI: 801 switch (bt) { 802 case T_BOOLEAN: 803 case T_CHAR: return 0; 804 case T_BYTE: 805 case T_SHORT: 806 case T_INT: 807 vopc = Op_AddReductionVI; 808 break; 809 default: ShouldNotReachHere(); return 0; 810 } 811 break; 812 case Op_AddL: 953 int vopc = opcode(opc, bt); 954 955 // This method should not be called for unimplemented vectors. 956 guarantee(vopc != opc, "Vector for '%s' is not implemented", NodeClassNames[opc]); 957 958 switch (vopc) { 959 case Op_AddReductionVI: return new AddReductionVINode(ctrl, n1, n2); 960 case Op_AddReductionVL: return new AddReductionVLNode(ctrl, n1, n2); 961 case Op_AddReductionVF: return new AddReductionVFNode(ctrl, n1, n2); 962 case Op_AddReductionVD: return new AddReductionVDNode(ctrl, n1, n2); 963 case Op_MulReductionVI: return new MulReductionVINode(ctrl, n1, n2); 964 case Op_MulReductionVL: return new MulReductionVLNode(ctrl, n1, n2); 965 case Op_MulReductionVF: return new MulReductionVFNode(ctrl, n1, n2); 966 case Op_MulReductionVD: return new MulReductionVDNode(ctrl, n1, n2); 967 case Op_MinReductionV: return new MinReductionVNode(ctrl, n1, n2); 968 case Op_MaxReductionV: return new MaxReductionVNode(ctrl, n1, n2); 969 case Op_AndReductionV: return new AndReductionVNode(ctrl, n1, n2); 970 case Op_OrReductionV: return new OrReductionVNode(ctrl, n1, n2); 971 case Op_XorReductionV: return new XorReductionVNode(ctrl, n1, n2); 972 default: 973 fatal("Missed vector creation for '%s'", NodeClassNames[vopc]); 974 return NULL; 975 } 976 } 977 978 VectorCastNode* VectorCastNode::make(int vopc, Node* n1, BasicType bt, uint vlen) { 979 const TypeVect* vt = TypeVect::make(bt, vlen); 980 switch (vopc) { 981 case Op_VectorCastB2X: return new VectorCastB2XNode(n1, vt); 982 case Op_VectorCastS2X: return new VectorCastS2XNode(n1, vt); 983 case Op_VectorCastI2X: return new VectorCastI2XNode(n1, vt); 984 case Op_VectorCastL2X: return new VectorCastL2XNode(n1, vt); 985 case Op_VectorCastF2X: return new VectorCastF2XNode(n1, vt); 986 case Op_VectorCastD2X: return new VectorCastD2XNode(n1, vt); 987 default: fatal("unknown node: %s", NodeClassNames[vopc]); 988 } 989 return NULL; 990 } 991 992 int VectorCastNode::opcode(BasicType bt) { 993 switch (bt) { 994 case T_BYTE: return Op_VectorCastB2X; 995 case T_SHORT: return Op_VectorCastS2X; 996 case T_INT: return Op_VectorCastI2X; 997 case T_LONG: return Op_VectorCastL2X; 998 case T_FLOAT: return Op_VectorCastF2X; 999 case T_DOUBLE: return Op_VectorCastD2X; 1000 default: Unimplemented(); 1001 } 1002 return 0; 1003 } 1004 1005 Node* ReductionNode::make_reduction_input(PhaseGVN& gvn, int opc, BasicType bt) { 1006 int vopc = opcode(opc, bt); 1007 guarantee(vopc != opc, "Vector reduction for '%s' is not implemented", NodeClassNames[opc]); 1008 1009 switch (vopc) { 1010 case Op_AndReductionV: 1011 switch (bt) { 1012 case T_BYTE: 1013 case T_SHORT: 1014 case T_INT: 1015 return gvn.makecon(TypeInt::MINUS_1); 1016 case T_LONG: 1017 return gvn.makecon(TypeLong::MINUS_1); 1018 default: 1019 fatal("Missed vector creation for '%s' as the basic type is not correct.", NodeClassNames[vopc]); 1020 return NULL; 1021 } 1022 break; 1064 return gvn.makecon(TypeD::NEG_INF); 1065 default: Unimplemented(); return NULL; 1066 } 1067 break; 1068 default: 1069 fatal("Missed vector creation for '%s'", NodeClassNames[vopc]); 1070 return NULL; 1071 } 1072 } 1073 1074 bool ReductionNode::implemented(int opc, uint vlen, BasicType bt) { 1075 if (is_java_primitive(bt) && 1076 (vlen > 1) && is_power_of_2(vlen) && 1077 Matcher::vector_size_supported(bt, vlen)) { 1078 int vopc = ReductionNode::opcode(opc, bt); 1079 return vopc != opc && Matcher::match_rule_supported(vopc); 1080 } 1081 return false; 1082 } 1083 1084 #ifndef PRODUCT 1085 void VectorMaskCmpNode::dump_spec(outputStream *st) const { 1086 st->print(" %d #", _predicate); _type->dump_on(st); 1087 } 1088 #endif // PRODUCT 1089 1090 Node* VectorReinterpretNode::Identity(PhaseGVN *phase) { 1091 Node* n = in(1); 1092 if (n->Opcode() == Op_VectorReinterpret) { 1093 if (Type::cmp(bottom_type(), n->in(1)->bottom_type()) == 0) { 1094 return n->in(1); 1095 } 1096 } 1097 return this; 1098 } 1099 1100 Node* VectorInsertNode::make(Node* vec, Node* new_val, int position) { 1101 assert(position < (int)vec->bottom_type()->is_vect()->length(), "pos in range"); 1102 ConINode* pos = ConINode::make(position); 1103 return new VectorInsertNode(vec, new_val, pos, vec->bottom_type()->is_vect()); 1112 } 1113 return this; 1114 } 1115 1116 const TypeFunc* VectorBoxNode::vec_box_type(const TypeInstPtr* box_type) { 1117 const Type** fields = TypeTuple::fields(0); 1118 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms, fields); 1119 1120 fields = TypeTuple::fields(1); 1121 fields[TypeFunc::Parms+0] = box_type; 1122 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); 1123 1124 return TypeFunc::make(domain, range); 1125 } 1126 1127 #ifndef PRODUCT 1128 void VectorBoxAllocateNode::dump_spec(outputStream *st) const { 1129 CallStaticJavaNode::dump_spec(st); 1130 } 1131 #endif // !PRODUCT 1132 1133 MacroLogicVNode* MacroLogicVNode::make(PhaseGVN& gvn, Node* in1, Node* in2, Node* in3, 1134 uint truth_table, const TypeVect* vt) { 1135 assert(truth_table <= 0xFF, "invalid"); 1136 assert(in1->bottom_type()->is_vect()->length_in_bytes() == vt->length_in_bytes(), "mismatch"); 1137 assert(in2->bottom_type()->is_vect()->length_in_bytes() == vt->length_in_bytes(), "mismatch"); 1138 assert(in3->bottom_type()->is_vect()->length_in_bytes() == vt->length_in_bytes(), "mismatch"); 1139 Node* fn = gvn.intcon(truth_table); 1140 return new MacroLogicVNode(in1, in2, in3, fn, vt); 1141 } 1142 | 161 assert(bt == T_DOUBLE, "must be"); 162 return Op_AbsVD; 163 case Op_NegI: 164 assert(bt == T_INT, "must be"); 165 return Op_NegVI; 166 case Op_NegF: 167 assert(bt == T_FLOAT, "must be"); 168 return Op_NegVF; 169 case Op_NegD: 170 assert(bt == T_DOUBLE, "must be"); 171 return Op_NegVD; 172 case Op_RoundDoubleMode: 173 assert(bt == T_DOUBLE, "must be"); 174 return Op_RoundDoubleModeV; 175 case Op_SqrtF: 176 assert(bt == T_FLOAT, "must be"); 177 return Op_SqrtVF; 178 case Op_SqrtD: 179 assert(bt == T_DOUBLE, "must be"); 180 return Op_SqrtVD; 181 case Op_PopCountI: 182 if (bt == T_INT) { 183 return Op_PopCountVI; 184 } 185 // Unimplemented for subword types since bit count changes 186 // depending on size of lane (and sign bit). 187 return 0; 188 case Op_LShiftI: 189 switch (bt) { 190 case T_BOOLEAN: 191 case T_BYTE: return Op_LShiftVB; 192 case T_CHAR: 193 case T_SHORT: return Op_LShiftVS; 194 case T_INT: return Op_LShiftVI; 195 default: ShouldNotReachHere(); return 0; 196 } 197 case Op_LShiftL: 198 assert(bt == T_LONG, "must be"); 199 return Op_LShiftVL; 200 case Op_RShiftI: 266 } 267 } 268 269 int VectorNode::replicate_opcode(BasicType bt) { 270 switch(bt) { 271 case T_BOOLEAN: 272 case T_BYTE: 273 return Op_ReplicateB; 274 case T_SHORT: 275 case T_CHAR: 276 return Op_ReplicateS; 277 case T_INT: 278 return Op_ReplicateI; 279 case T_LONG: 280 return Op_ReplicateL; 281 case T_FLOAT: 282 return Op_ReplicateF; 283 case T_DOUBLE: 284 return Op_ReplicateD; 285 default: 286 assert(false, "wrong type: %s", type2name(bt)); 287 return 0; 288 } 289 } 290 291 // Also used to check if the code generator 292 // supports the vector operation. 293 bool VectorNode::implemented(int opc, uint vlen, BasicType bt) { 294 if (is_java_primitive(bt) && 295 (vlen > 1) && is_power_of_2(vlen) && 296 Matcher::vector_size_supported(bt, vlen)) { 297 int vopc = VectorNode::opcode(opc, bt); 298 return vopc > 0 && Matcher::match_rule_supported_vector(vopc, vlen, bt); 299 } 300 return false; 301 } 302 303 bool VectorNode::is_type_transition_short_to_int(Node* n) { 304 switch (n->Opcode()) { 305 case Op_MulAddS2I: 306 return true; 307 } 308 return false; 323 if (n->Opcode() == Op_RoundDoubleMode) { 324 return true; 325 } 326 return false; 327 } 328 329 bool VectorNode::is_shift(Node* n) { 330 switch (n->Opcode()) { 331 case Op_LShiftI: 332 case Op_LShiftL: 333 case Op_RShiftI: 334 case Op_RShiftL: 335 case Op_URShiftI: 336 case Op_URShiftL: 337 return true; 338 default: 339 return false; 340 } 341 } 342 343 bool VectorNode::is_vshift_cnt(Node* n) { 344 switch (n->Opcode()) { 345 case Op_LShiftCntV: 346 case Op_RShiftCntV: 347 return true; 348 default: 349 return false; 350 } 351 } 352 353 // Check if input is loop invariant vector. 354 bool VectorNode::is_invariant_vector(Node* n) { 355 // Only Replicate vector nodes are loop invariant for now. 356 switch (n->Opcode()) { 357 case Op_ReplicateB: 358 case Op_ReplicateS: 359 case Op_ReplicateI: 360 case Op_ReplicateL: 361 case Op_ReplicateF: 362 case Op_ReplicateD: 431 case Op_SubVB: return new SubVBNode(n1, n2, vt); 432 case Op_SubVS: return new SubVSNode(n1, n2, vt); 433 case Op_SubVI: return new SubVINode(n1, n2, vt); 434 case Op_SubVL: return new SubVLNode(n1, n2, vt); 435 case Op_SubVF: return new SubVFNode(n1, n2, vt); 436 case Op_SubVD: return new SubVDNode(n1, n2, vt); 437 438 case Op_MulVB: return new MulVBNode(n1, n2, vt); 439 case Op_MulVS: return new MulVSNode(n1, n2, vt); 440 case Op_MulVI: return new MulVINode(n1, n2, vt); 441 case Op_MulVL: return new MulVLNode(n1, n2, vt); 442 case Op_MulVF: return new MulVFNode(n1, n2, vt); 443 case Op_MulVD: return new MulVDNode(n1, n2, vt); 444 445 case Op_DivVF: return new DivVFNode(n1, n2, vt); 446 case Op_DivVD: return new DivVDNode(n1, n2, vt); 447 448 case Op_MinV: return new MinVNode(n1, n2, vt); 449 case Op_MaxV: return new MaxVNode(n1, n2, vt); 450 451 case Op_AbsVF: return new AbsVFNode(n1, vt); 452 case Op_AbsVD: return new AbsVDNode(n1, vt); 453 case Op_AbsVB: return new AbsVBNode(n1, vt); 454 case Op_AbsVS: return new AbsVSNode(n1, vt); 455 case Op_AbsVI: return new AbsVINode(n1, vt); 456 case Op_AbsVL: return new AbsVLNode(n1, vt); 457 458 case Op_NegVI: return new NegVINode(n1, vt); 459 case Op_NegVF: return new NegVFNode(n1, vt); 460 case Op_NegVD: return new NegVDNode(n1, vt); 461 462 case Op_SqrtVF: return new SqrtVFNode(n1, vt); 463 case Op_SqrtVD: return new SqrtVDNode(n1, vt); 464 465 case Op_PopCountVI: return new PopCountVINode(n1, vt); 466 467 case Op_LShiftVB: return new LShiftVBNode(n1, n2, vt); 468 case Op_LShiftVS: return new LShiftVSNode(n1, n2, vt); 469 case Op_LShiftVI: return new LShiftVINode(n1, n2, vt); 470 case Op_LShiftVL: return new LShiftVLNode(n1, n2, vt); 471 472 case Op_RShiftVB: return new RShiftVBNode(n1, n2, vt); 473 case Op_RShiftVS: return new RShiftVSNode(n1, n2, vt); 474 case Op_RShiftVI: return new RShiftVINode(n1, n2, vt); 475 case Op_RShiftVL: return new RShiftVLNode(n1, n2, vt); 476 477 case Op_URShiftVB: return new URShiftVBNode(n1, n2, vt); 478 case Op_URShiftVS: return new URShiftVSNode(n1, n2, vt); 479 case Op_URShiftVI: return new URShiftVINode(n1, n2, vt); 480 case Op_URShiftVL: return new URShiftVLNode(n1, n2, vt); 481 482 case Op_AndV: return new AndVNode(n1, n2, vt); 483 case Op_OrV: return new OrVNode (n1, n2, vt); 484 case Op_XorV: return new XorVNode(n1, n2, vt); 485 486 case Op_RoundDoubleModeV: return new RoundDoubleModeVNode(n1, n2, vt); 487 488 case Op_MulAddVS2VI: return new MulAddVS2VINode(n1, n2, vt); 489 default: 490 fatal("Missed vector creation for '%s'", NodeClassNames[vopc]); 491 return NULL; 492 } 493 } 494 495 // Return the vector version of a scalar binary operation node. 496 VectorNode* VectorNode::make(int opc, Node* n1, Node* n2, uint vlen, BasicType bt) { 497 const TypeVect* vt = TypeVect::make(bt, vlen); 498 int vopc = VectorNode::opcode(opc, bt); 499 // This method should not be called for unimplemented vectors. 500 guarantee(vopc > 0, "Vector for '%s' is not implemented", NodeClassNames[opc]); 501 return make(vopc, n1, n2, vt); 696 } 697 698 // Return the vector version of a scalar load node. 699 LoadVectorNode* LoadVectorNode::make(int opc, Node* ctl, Node* mem, 700 Node* adr, const TypePtr* atyp, 701 uint vlen, BasicType bt, 702 ControlDependency control_dependency) { 703 const TypeVect* vt = TypeVect::make(bt, vlen); 704 return new LoadVectorNode(ctl, mem, adr, atyp, vt, control_dependency); 705 } 706 707 // Return the vector version of a scalar store node. 708 StoreVectorNode* StoreVectorNode::make(int opc, Node* ctl, Node* mem, 709 Node* adr, const TypePtr* atyp, Node* val, 710 uint vlen) { 711 return new StoreVectorNode(ctl, mem, adr, atyp, val); 712 } 713 714 int ExtractNode::opcode(BasicType bt) { 715 switch (bt) { 716 case T_BOOLEAN: return Op_ExtractUB; 717 case T_BYTE: return Op_ExtractB; 718 case T_CHAR: return Op_ExtractC; 719 case T_SHORT: return Op_ExtractS; 720 case T_INT: return Op_ExtractI; 721 case T_LONG: return Op_ExtractL; 722 case T_FLOAT: return Op_ExtractF; 723 case T_DOUBLE: return Op_ExtractD; 724 default: 725 assert(false, "wrong type: %s", type2name(bt)); 726 return 0; 727 } 728 } 729 730 // Extract a scalar element of vector. 731 Node* ExtractNode::make(Node* v, uint position, BasicType bt) { 732 assert((int)position < Matcher::max_vector_size(bt), "pos in range"); 733 ConINode* pos = ConINode::make((int)position); 734 switch (bt) { 735 case T_BOOLEAN: return new ExtractUBNode(v, pos); 736 case T_BYTE: return new ExtractBNode(v, pos); 737 case T_CHAR: return new ExtractCNode(v, pos); 738 case T_SHORT: return new ExtractSNode(v, pos); 739 case T_INT: return new ExtractINode(v, pos); 740 case T_LONG: return new ExtractLNode(v, pos); 741 case T_FLOAT: return new ExtractFNode(v, pos); 742 case T_DOUBLE: return new ExtractDNode(v, pos); 743 default: 744 assert(false, "wrong type: %s", type2name(bt)); 745 return NULL; 746 } 747 } 748 749 int ReductionNode::opcode(int opc, BasicType bt) { 750 int vopc = opc; 751 switch (opc) { 752 case Op_AddI: 753 switch (bt) { 754 case T_BOOLEAN: 755 case T_CHAR: return 0; 756 case T_BYTE: 757 case T_SHORT: 758 case T_INT: 759 vopc = Op_AddReductionVI; 760 break; 761 default: ShouldNotReachHere(); return 0; 762 } 763 break; 764 case Op_AddL: 905 int vopc = opcode(opc, bt); 906 907 // This method should not be called for unimplemented vectors. 908 guarantee(vopc != opc, "Vector for '%s' is not implemented", NodeClassNames[opc]); 909 910 switch (vopc) { 911 case Op_AddReductionVI: return new AddReductionVINode(ctrl, n1, n2); 912 case Op_AddReductionVL: return new AddReductionVLNode(ctrl, n1, n2); 913 case Op_AddReductionVF: return new AddReductionVFNode(ctrl, n1, n2); 914 case Op_AddReductionVD: return new AddReductionVDNode(ctrl, n1, n2); 915 case Op_MulReductionVI: return new MulReductionVINode(ctrl, n1, n2); 916 case Op_MulReductionVL: return new MulReductionVLNode(ctrl, n1, n2); 917 case Op_MulReductionVF: return new MulReductionVFNode(ctrl, n1, n2); 918 case Op_MulReductionVD: return new MulReductionVDNode(ctrl, n1, n2); 919 case Op_MinReductionV: return new MinReductionVNode(ctrl, n1, n2); 920 case Op_MaxReductionV: return new MaxReductionVNode(ctrl, n1, n2); 921 case Op_AndReductionV: return new AndReductionVNode(ctrl, n1, n2); 922 case Op_OrReductionV: return new OrReductionVNode(ctrl, n1, n2); 923 case Op_XorReductionV: return new XorReductionVNode(ctrl, n1, n2); 924 default: 925 assert(false, "unknown node: %s", NodeClassNames[vopc]); 926 return NULL; 927 } 928 } 929 930 VectorStoreMaskNode* VectorStoreMaskNode::make(PhaseGVN& gvn, Node* in, BasicType in_type, uint num_elem) { 931 assert(in->bottom_type()->isa_vect(), "sanity"); 932 const TypeVect* vt = TypeVect::make(T_BOOLEAN, num_elem); 933 int elem_size = type2aelembytes(in_type); 934 return new VectorStoreMaskNode(in, gvn.intcon(elem_size), vt); 935 } 936 937 VectorCastNode* VectorCastNode::make(int vopc, Node* n1, BasicType bt, uint vlen) { 938 const TypeVect* vt = TypeVect::make(bt, vlen); 939 switch (vopc) { 940 case Op_VectorCastB2X: return new VectorCastB2XNode(n1, vt); 941 case Op_VectorCastS2X: return new VectorCastS2XNode(n1, vt); 942 case Op_VectorCastI2X: return new VectorCastI2XNode(n1, vt); 943 case Op_VectorCastL2X: return new VectorCastL2XNode(n1, vt); 944 case Op_VectorCastF2X: return new VectorCastF2XNode(n1, vt); 945 case Op_VectorCastD2X: return new VectorCastD2XNode(n1, vt); 946 default: 947 assert(false, "unknown node: %s", NodeClassNames[vopc]); 948 return NULL; 949 } 950 } 951 952 int VectorCastNode::opcode(BasicType bt) { 953 switch (bt) { 954 case T_BYTE: return Op_VectorCastB2X; 955 case T_SHORT: return Op_VectorCastS2X; 956 case T_INT: return Op_VectorCastI2X; 957 case T_LONG: return Op_VectorCastL2X; 958 case T_FLOAT: return Op_VectorCastF2X; 959 case T_DOUBLE: return Op_VectorCastD2X; 960 default: 961 assert(false, "unknown type: %s", type2name(bt)); 962 return 0; 963 } 964 } 965 966 Node* ReductionNode::make_reduction_input(PhaseGVN& gvn, int opc, BasicType bt) { 967 int vopc = opcode(opc, bt); 968 guarantee(vopc != opc, "Vector reduction for '%s' is not implemented", NodeClassNames[opc]); 969 970 switch (vopc) { 971 case Op_AndReductionV: 972 switch (bt) { 973 case T_BYTE: 974 case T_SHORT: 975 case T_INT: 976 return gvn.makecon(TypeInt::MINUS_1); 977 case T_LONG: 978 return gvn.makecon(TypeLong::MINUS_1); 979 default: 980 fatal("Missed vector creation for '%s' as the basic type is not correct.", NodeClassNames[vopc]); 981 return NULL; 982 } 983 break; 1025 return gvn.makecon(TypeD::NEG_INF); 1026 default: Unimplemented(); return NULL; 1027 } 1028 break; 1029 default: 1030 fatal("Missed vector creation for '%s'", NodeClassNames[vopc]); 1031 return NULL; 1032 } 1033 } 1034 1035 bool ReductionNode::implemented(int opc, uint vlen, BasicType bt) { 1036 if (is_java_primitive(bt) && 1037 (vlen > 1) && is_power_of_2(vlen) && 1038 Matcher::vector_size_supported(bt, vlen)) { 1039 int vopc = ReductionNode::opcode(opc, bt); 1040 return vopc != opc && Matcher::match_rule_supported(vopc); 1041 } 1042 return false; 1043 } 1044 1045 MacroLogicVNode* MacroLogicVNode::make(PhaseGVN& gvn, Node* in1, Node* in2, Node* in3, 1046 uint truth_table, const TypeVect* vt) { 1047 assert(truth_table <= 0xFF, "invalid"); 1048 assert(in1->bottom_type()->is_vect()->length_in_bytes() == vt->length_in_bytes(), "mismatch"); 1049 assert(in2->bottom_type()->is_vect()->length_in_bytes() == vt->length_in_bytes(), "mismatch"); 1050 assert(in3->bottom_type()->is_vect()->length_in_bytes() == vt->length_in_bytes(), "mismatch"); 1051 Node* fn = gvn.intcon(truth_table); 1052 return new MacroLogicVNode(in1, in2, in3, fn, vt); 1053 } 1054 1055 #ifndef PRODUCT 1056 void VectorMaskCmpNode::dump_spec(outputStream *st) const { 1057 st->print(" %d #", _predicate); _type->dump_on(st); 1058 } 1059 #endif // PRODUCT 1060 1061 Node* VectorReinterpretNode::Identity(PhaseGVN *phase) { 1062 Node* n = in(1); 1063 if (n->Opcode() == Op_VectorReinterpret) { 1064 if (Type::cmp(bottom_type(), n->in(1)->bottom_type()) == 0) { 1065 return n->in(1); 1066 } 1067 } 1068 return this; 1069 } 1070 1071 Node* VectorInsertNode::make(Node* vec, Node* new_val, int position) { 1072 assert(position < (int)vec->bottom_type()->is_vect()->length(), "pos in range"); 1073 ConINode* pos = ConINode::make(position); 1074 return new VectorInsertNode(vec, new_val, pos, vec->bottom_type()->is_vect()); 1083 } 1084 return this; 1085 } 1086 1087 const TypeFunc* VectorBoxNode::vec_box_type(const TypeInstPtr* box_type) { 1088 const Type** fields = TypeTuple::fields(0); 1089 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms, fields); 1090 1091 fields = TypeTuple::fields(1); 1092 fields[TypeFunc::Parms+0] = box_type; 1093 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); 1094 1095 return TypeFunc::make(domain, range); 1096 } 1097 1098 #ifndef PRODUCT 1099 void VectorBoxAllocateNode::dump_spec(outputStream *st) const { 1100 CallStaticJavaNode::dump_spec(st); 1101 } 1102 #endif // !PRODUCT |