< prev index next >

src/cpu/ppc/vm/ppc.ad

Print this page
rev 9944 : 8145336: PPC64: fix string intrinsics after CompactStrings change


 939 
 940 static int cc_to_boint(int cc) {
 941   return Assembler::bcondCRbiIs0 | (cc & 8);
 942 }
 943 
 944 static int cc_to_inverse_boint(int cc) {
 945   return Assembler::bcondCRbiIs0 | (8-(cc & 8));
 946 }
 947 
 948 static int cc_to_biint(int cc, int flags_reg) {
 949   return (flags_reg << 2) | (cc & 3);
 950 }
 951 
 952 //=============================================================================
 953 
 954 // Compute padding required for nodes which need alignment. The padding
 955 // is the number of bytes (not instructions) which will be inserted before
 956 // the instruction. The padding must match the size of a NOP instruction.
 957 
 958 int string_indexOf_imm1_charNode::compute_padding(int current_offset) const {
 959   return (3*4-current_offset)&31;
 960 }
 961 
 962 int string_indexOf_imm1Node::compute_padding(int current_offset) const {
 963   return (2*4-current_offset)&31;
 964 }
 965 




 966 int string_indexOf_immNode::compute_padding(int current_offset) const {
 967   return (3*4-current_offset)&31;
 968 }
 969 
 970 int string_indexOfNode::compute_padding(int current_offset) const {
 971   return (1*4-current_offset)&31;
 972 }
 973 
 974 int string_compareNode::compute_padding(int current_offset) const {
 975   return (4*4-current_offset)&31;
 976 }
 977 
 978 int string_equals_immNode::compute_padding(int current_offset) const {
 979   if (opnd_array(3)->constant() < 16) return 0; // Don't insert nops for short version (loop completely unrolled).
 980   return (2*4-current_offset)&31;
 981 }
 982 
 983 int string_equalsNode::compute_padding(int current_offset) const {
 984   return (7*4-current_offset)&31;
 985 }
 986 
 987 int inlineCallClearArrayNode::compute_padding(int current_offset) const {
 988   return (2*4-current_offset)&31;
 989 }
 990 
 991 //=============================================================================
 992 
 993 // Indicate if the safepoint node needs the polling page as an input.
 994 bool SafePointNode::needs_polling_address_input() {
 995   // The address is loaded from thread by a seperate node.


2008   case Op_SqrtD:
2009     return VM_Version::has_fsqrt();
2010   case Op_CountLeadingZerosI:
2011   case Op_CountLeadingZerosL:
2012   case Op_CountTrailingZerosI:
2013   case Op_CountTrailingZerosL:
2014     if (!UseCountLeadingZerosInstructionsPPC64)
2015       return false;
2016     break;
2017 
2018   case Op_PopCountI:
2019   case Op_PopCountL:
2020     return (UsePopCountInstruction && VM_Version::has_popcntw());
2021 
2022   case Op_StrComp:
2023     return SpecialStringCompareTo && !CompactStrings;
2024   case Op_StrEquals:
2025     return SpecialStringEquals && !CompactStrings;
2026   case Op_StrIndexOf:
2027     return SpecialStringIndexOf && !CompactStrings;


2028   }
2029 
2030   return true;  // Per default match rules are supported.
2031 }
2032 
2033 const bool Matcher::match_rule_supported_vector(int opcode, int vlen) {
2034 
2035   // TODO
2036   // identify extra cases that we might want to provide match rules for
2037   // e.g. Op_ vector nodes and other intrinsics while guarding with vlen
2038   bool ret_value = match_rule_supported(opcode);
2039   // Add rules here.
2040 
2041   return ret_value;  // Per default match rules are supported.
2042 }
2043 
2044 const int Matcher::float_pressure(int default_pressure_threshold) {
2045   return default_pressure_threshold;
2046 }
2047 


11033 // by several nodes, even several StrIndexOf nodes, breaking the match tree.
11034 instruct string_indexOf_imm1_char(iRegIdst result, iRegPsrc haystack, iRegIsrc haycnt,
11035                                   immP needleImm, immL offsetImm, immI_1 needlecntImm,
11036                                   iRegIdst tmp1, iRegIdst tmp2,
11037                                   flagsRegCR0 cr0, flagsRegCR1 cr1) %{
11038   predicate(SpecialStringIndexOf && !CompactStrings);  // type check implicit by parameter type, See Matcher::match_rule_supported
11039   match(Set result (StrIndexOf (Binary haystack haycnt) (Binary (AddP needleImm offsetImm) needlecntImm)));
11040 
11041   effect(TEMP_DEF result, TEMP tmp1, TEMP tmp2, KILL cr0, KILL cr1);
11042 
11043   ins_cost(150);
11044   format %{ "String IndexOf CSCL1 $haystack[0..$haycnt], $needleImm+$offsetImm[0..$needlecntImm]"
11045             "-> $result \t// KILL $haycnt, $tmp1, $tmp2, $cr0, $cr1" %}
11046 
11047   ins_alignment(8); // 'compute_padding()' gets called, up to this number-1 nops will get inserted
11048   ins_encode %{
11049     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
11050     immPOper *needleOper = (immPOper *)$needleImm;
11051     const TypeOopPtr *t = needleOper->type()->isa_oopptr();
11052     ciTypeArray* needle_values = t->const_oop()->as_type_array();  // Pointer to live char *
11053 








11054     __ string_indexof_1($result$$Register,
11055                         $haystack$$Register, $haycnt$$Register,
11056                         R0, needle_values->char_at(0),
11057                         $tmp1$$Register, $tmp2$$Register);
11058   %}
11059   ins_pipe(pipe_class_compare);
11060 %}
11061 
11062 // String_IndexOf for needle of length 1.
11063 //
11064 // Special case requires less registers and emits less instructions.
11065 //
11066 // Assumes register result differs from all input registers.
11067 //
11068 // Preserves registers haystack, haycnt
11069 // Kills     registers tmp1, tmp2, needle
11070 // Defines   registers result
11071 //
11072 // Use dst register classes if register gets killed, as it is the case for tmp registers!
11073 instruct string_indexOf_imm1(iRegIdst result, iRegPsrc haystack, iRegIsrc haycnt,
11074                              rscratch2RegP needle, immI_1 needlecntImm,
11075                              iRegIdst tmp1, iRegIdst tmp2,
11076                              flagsRegCR0 cr0, flagsRegCR1 cr1) %{
11077   match(Set result (StrIndexOf (Binary haystack haycnt) (Binary needle needlecntImm)));
11078   effect(USE_KILL needle, /* TDEF needle, */ TEMP_DEF result,
11079          TEMP tmp1, TEMP tmp2);
11080   // Required for EA: check if it is still a type_array.
11081   predicate(SpecialStringIndexOf && !CompactStrings && n->in(3)->in(1)->bottom_type()->is_aryptr()->const_oop() &&

11082             n->in(3)->in(1)->bottom_type()->is_aryptr()->const_oop()->is_type_array());
11083   ins_cost(180);
11084 
11085   ins_alignment(8); // 'compute_padding()' gets called, up to this number-1 nops will get inserted.
11086 
11087   format %{ "String IndexOf SCL1 $haystack[0..$haycnt], $needle[0..$needlecntImm]"
11088             " -> $result \t// KILL $haycnt, $needle, $tmp1, $tmp2, $cr0, $cr1" %}
11089   ins_encode %{
11090     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
11091     Node *ndl = in(operand_index($needle));  // The node that defines needle.
11092     ciTypeArray* needle_values = ndl->bottom_type()->is_aryptr()->const_oop()->as_type_array();
11093     guarantee(needle_values, "sanity");
11094     if (needle_values != NULL) {








11095       __ string_indexof_1($result$$Register,
11096                           $haystack$$Register, $haycnt$$Register,
11097                           R0, needle_values->char_at(0),
11098                           $tmp1$$Register, $tmp2$$Register);
11099     } else {

























11100       __ string_indexof_1($result$$Register,
11101                           $haystack$$Register, $haycnt$$Register,
11102                           $needle$$Register, 0,
11103                           $tmp1$$Register, $tmp2$$Register);
11104     }
11105   %}
11106   ins_pipe(pipe_class_compare);
11107 %}
11108 
11109 // String_IndexOf.
11110 //
11111 // Length of needle as immediate. This saves instruction loading constant needle
11112 // length.
11113 // @@@ TODO Specify rules for length < 8 or so, and roll out comparison of needle
11114 // completely or do it in vector instruction. This should save registers for
11115 // needlecnt and needle.
11116 //
11117 // Assumes register result differs from all input registers.
11118 // Overwrites haycnt, needlecnt.
11119 // Use dst register classes if register gets killed, as it is the case for tmp registers!
11120 instruct string_indexOf_imm(iRegIdst result, iRegPsrc haystack, rscratch1RegI haycnt,
11121                             iRegPsrc needle, uimmI15 needlecntImm,
11122                             iRegIdst tmp1, iRegIdst tmp2, iRegIdst tmp3, iRegIdst tmp4, iRegIdst tmp5,
11123                             flagsRegCR0 cr0, flagsRegCR1 cr1, flagsRegCR6 cr6) %{
11124   match(Set result (StrIndexOf (Binary haystack haycnt) (Binary needle needlecntImm)));




 939 
 940 static int cc_to_boint(int cc) {
 941   return Assembler::bcondCRbiIs0 | (cc & 8);
 942 }
 943 
 944 static int cc_to_inverse_boint(int cc) {
 945   return Assembler::bcondCRbiIs0 | (8-(cc & 8));
 946 }
 947 
 948 static int cc_to_biint(int cc, int flags_reg) {
 949   return (flags_reg << 2) | (cc & 3);
 950 }
 951 
 952 //=============================================================================
 953 
 954 // Compute padding required for nodes which need alignment. The padding
 955 // is the number of bytes (not instructions) which will be inserted before
 956 // the instruction. The padding must match the size of a NOP instruction.
 957 
 958 int string_indexOf_imm1_charNode::compute_padding(int current_offset) const {
 959   return (2*4-current_offset)&31;
 960 }
 961 
 962 int string_indexOf_imm1Node::compute_padding(int current_offset) const {
 963   return (2*4-current_offset)&31;
 964 }
 965 
 966 int string_indexOfCharNode::compute_padding(int current_offset) const {
 967   return (2*4-current_offset)&31;
 968 }
 969 
 970 int string_indexOf_immNode::compute_padding(int current_offset) const {
 971   return (3*4-current_offset)&31;
 972 }
 973 
 974 int string_indexOfNode::compute_padding(int current_offset) const {
 975   return (1*4-current_offset)&31;
 976 }
 977 
 978 int string_compareNode::compute_padding(int current_offset) const {
 979   return (6*4-current_offset)&31;
 980 }
 981 
 982 int string_equals_immNode::compute_padding(int current_offset) const {
 983   if (opnd_array(3)->constant() < 16) return 0; // Don't insert nops for short version (loop completely unrolled).
 984   return (2*4-current_offset)&31;
 985 }
 986 
 987 int string_equalsNode::compute_padding(int current_offset) const {
 988   return (7*4-current_offset)&31;
 989 }
 990 
 991 int inlineCallClearArrayNode::compute_padding(int current_offset) const {
 992   return (2*4-current_offset)&31;
 993 }
 994 
 995 //=============================================================================
 996 
 997 // Indicate if the safepoint node needs the polling page as an input.
 998 bool SafePointNode::needs_polling_address_input() {
 999   // The address is loaded from thread by a seperate node.


2012   case Op_SqrtD:
2013     return VM_Version::has_fsqrt();
2014   case Op_CountLeadingZerosI:
2015   case Op_CountLeadingZerosL:
2016   case Op_CountTrailingZerosI:
2017   case Op_CountTrailingZerosL:
2018     if (!UseCountLeadingZerosInstructionsPPC64)
2019       return false;
2020     break;
2021 
2022   case Op_PopCountI:
2023   case Op_PopCountL:
2024     return (UsePopCountInstruction && VM_Version::has_popcntw());
2025 
2026   case Op_StrComp:
2027     return SpecialStringCompareTo && !CompactStrings;
2028   case Op_StrEquals:
2029     return SpecialStringEquals && !CompactStrings;
2030   case Op_StrIndexOf:
2031     return SpecialStringIndexOf && !CompactStrings;
2032   case Op_StrIndexOfChar:
2033     return SpecialStringIndexOf && !CompactStrings;
2034   }
2035 
2036   return true;  // Per default match rules are supported.
2037 }
2038 
2039 const bool Matcher::match_rule_supported_vector(int opcode, int vlen) {
2040 
2041   // TODO
2042   // identify extra cases that we might want to provide match rules for
2043   // e.g. Op_ vector nodes and other intrinsics while guarding with vlen
2044   bool ret_value = match_rule_supported(opcode);
2045   // Add rules here.
2046 
2047   return ret_value;  // Per default match rules are supported.
2048 }
2049 
2050 const int Matcher::float_pressure(int default_pressure_threshold) {
2051   return default_pressure_threshold;
2052 }
2053 


11039 // by several nodes, even several StrIndexOf nodes, breaking the match tree.
11040 instruct string_indexOf_imm1_char(iRegIdst result, iRegPsrc haystack, iRegIsrc haycnt,
11041                                   immP needleImm, immL offsetImm, immI_1 needlecntImm,
11042                                   iRegIdst tmp1, iRegIdst tmp2,
11043                                   flagsRegCR0 cr0, flagsRegCR1 cr1) %{
11044   predicate(SpecialStringIndexOf && !CompactStrings);  // type check implicit by parameter type, See Matcher::match_rule_supported
11045   match(Set result (StrIndexOf (Binary haystack haycnt) (Binary (AddP needleImm offsetImm) needlecntImm)));
11046 
11047   effect(TEMP_DEF result, TEMP tmp1, TEMP tmp2, KILL cr0, KILL cr1);
11048 
11049   ins_cost(150);
11050   format %{ "String IndexOf CSCL1 $haystack[0..$haycnt], $needleImm+$offsetImm[0..$needlecntImm]"
11051             "-> $result \t// KILL $haycnt, $tmp1, $tmp2, $cr0, $cr1" %}
11052 
11053   ins_alignment(8); // 'compute_padding()' gets called, up to this number-1 nops will get inserted
11054   ins_encode %{
11055     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
11056     immPOper *needleOper = (immPOper *)$needleImm;
11057     const TypeOopPtr *t = needleOper->type()->isa_oopptr();
11058     ciTypeArray* needle_values = t->const_oop()->as_type_array();  // Pointer to live char *
11059     jchar chr;
11060     if (java_lang_String::has_coder_field()) {
11061       // New compact strings byte array strings
11062       chr = (((jchar)needle_values->element_value(0).as_byte()) << 8) |
11063               (jchar)needle_values->element_value(1).as_byte();
11064     } else {
11065       // Old char array strings
11066       chr = needle_values->char_at(0);
11067     }
11068     __ string_indexof_1($result$$Register,
11069                         $haystack$$Register, $haycnt$$Register,
11070                         R0, chr,
11071                         $tmp1$$Register, $tmp2$$Register);
11072   %}
11073   ins_pipe(pipe_class_compare);
11074 %}
11075 
11076 // String_IndexOf for needle of length 1.
11077 //
11078 // Special case requires less registers and emits less instructions.
11079 //
11080 // Assumes register result differs from all input registers.
11081 //
11082 // Preserves registers haystack, haycnt
11083 // Kills     registers tmp1, tmp2, needle
11084 // Defines   registers result
11085 //
11086 // Use dst register classes if register gets killed, as it is the case for tmp registers!
11087 instruct string_indexOf_imm1(iRegIdst result, iRegPsrc haystack, iRegIsrc haycnt,
11088                              rscratch2RegP needle, immI_1 needlecntImm,
11089                              iRegIdst tmp1, iRegIdst tmp2,
11090                              flagsRegCR0 cr0, flagsRegCR1 cr1) %{
11091   match(Set result (StrIndexOf (Binary haystack haycnt) (Binary needle needlecntImm)));
11092   effect(USE_KILL needle, /* TDEF needle, */ TEMP_DEF result,
11093          TEMP tmp1, TEMP tmp2);
11094   // Required for EA: check if it is still a type_array.
11095   predicate(SpecialStringIndexOf && !CompactStrings &&
11096             n->in(3)->in(1)->bottom_type()->is_aryptr()->const_oop() &&
11097             n->in(3)->in(1)->bottom_type()->is_aryptr()->const_oop()->is_type_array());
11098   ins_cost(180);
11099 
11100   ins_alignment(8); // 'compute_padding()' gets called, up to this number-1 nops will get inserted.
11101 
11102   format %{ "String IndexOf SCL1 $haystack[0..$haycnt], $needle[0..$needlecntImm]"
11103             " -> $result \t// KILL $haycnt, $needle, $tmp1, $tmp2, $cr0, $cr1" %}
11104   ins_encode %{
11105     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
11106     Node *ndl = in(operand_index($needle));  // The node that defines needle.
11107     ciTypeArray* needle_values = ndl->bottom_type()->is_aryptr()->const_oop()->as_type_array();
11108     guarantee(needle_values, "sanity");
11109     jchar chr;
11110     if (java_lang_String::has_coder_field()) {
11111       // New compact strings byte array strings
11112       chr = (((jchar)needle_values->element_value(0).as_byte()) << 8) |
11113               (jchar)needle_values->element_value(1).as_byte();
11114     } else {
11115       // Old char array strings
11116       chr = needle_values->char_at(0);
11117     }
11118     __ string_indexof_1($result$$Register,
11119                         $haystack$$Register, $haycnt$$Register,
11120                         R0, chr,
11121                         $tmp1$$Register, $tmp2$$Register);
11122   %}
11123   ins_pipe(pipe_class_compare);
11124 %}
11125 
11126 // String_IndexOfChar
11127 //
11128 // Assumes register result differs from all input registers.
11129 //
11130 // Preserves registers haystack, haycnt
11131 // Kills     registers tmp1, tmp2, needle
11132 // Defines   registers result
11133 //
11134 // Use dst register classes if register gets killed, as it is the case for tmp registers!
11135 instruct string_indexOfChar(iRegIdst result, iRegPsrc haystack, iRegIsrc haycnt,
11136                             iRegIsrc ch, iRegIdst tmp1, iRegIdst tmp2,
11137                             flagsRegCR0 cr0, flagsRegCR1 cr1) %{
11138   match(Set result (StrIndexOfChar (Binary haystack haycnt) ch));
11139   effect(TEMP_DEF result, TEMP tmp1, TEMP tmp2);
11140   predicate(SpecialStringIndexOf && !CompactStrings);
11141   ins_cost(180);
11142 
11143   ins_alignment(8); // 'compute_padding()' gets called, up to this number-1 nops will get inserted.
11144 
11145   format %{ "String IndexOfChar $haystack[0..$haycnt], $ch"
11146             " -> $result \t// KILL $haycnt, $tmp1, $tmp2, $cr0, $cr1" %}
11147   ins_encode %{
11148     __ string_indexof_1($result$$Register,
11149                         $haystack$$Register, $haycnt$$Register,
11150                         $ch$$Register, 0 /* this is not used if the character is already in a register */,
11151                         $tmp1$$Register, $tmp2$$Register);

11152   %}
11153   ins_pipe(pipe_class_compare);
11154 %}
11155 
11156 // String_IndexOf.
11157 //
11158 // Length of needle as immediate. This saves instruction loading constant needle
11159 // length.
11160 // @@@ TODO Specify rules for length < 8 or so, and roll out comparison of needle
11161 // completely or do it in vector instruction. This should save registers for
11162 // needlecnt and needle.
11163 //
11164 // Assumes register result differs from all input registers.
11165 // Overwrites haycnt, needlecnt.
11166 // Use dst register classes if register gets killed, as it is the case for tmp registers!
11167 instruct string_indexOf_imm(iRegIdst result, iRegPsrc haystack, rscratch1RegI haycnt,
11168                             iRegPsrc needle, uimmI15 needlecntImm,
11169                             iRegIdst tmp1, iRegIdst tmp2, iRegIdst tmp3, iRegIdst tmp4, iRegIdst tmp5,
11170                             flagsRegCR0 cr0, flagsRegCR1 cr1, flagsRegCR6 cr6) %{
11171   match(Set result (StrIndexOf (Binary haystack haycnt) (Binary needle needlecntImm)));


< prev index next >