1 /*
  2  * Copyright (c) 2020, 2024, 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 
 25 #ifndef CPU_X86_C2_MACROASSEMBLER_X86_HPP
 26 #define CPU_X86_C2_MACROASSEMBLER_X86_HPP
 27 
 28 // C2_MacroAssembler contains high-level macros for C2
 29 
 30 public:
 31   // C2 compiled method's prolog code.
 32   void verified_entry(Compile* C, int sp_inc = 0);
 33 
 34   void entry_barrier();
 35   Assembler::AvxVectorLen vector_length_encoding(int vlen_in_bytes);
 36 
 37   // Code used by cmpFastLock and cmpFastUnlock mach instructions in .ad file.
 38   // See full description in macroAssembler_x86.cpp.
 39   void fast_lock(Register obj, Register box, Register tmp,
 40                  Register scr, Register cx1, Register cx2, Register thread,
 41                  RTMLockingCounters* rtm_counters,
 42                  RTMLockingCounters* stack_rtm_counters,
 43                  Metadata* method_data,
 44                  bool use_rtm, bool profile_rtm);
 45   void fast_unlock(Register obj, Register box, Register tmp, bool use_rtm);
 46 
 47   void fast_lock_lightweight(Register obj, Register box, Register rax_reg,
 48                              Register t, Register thread);
 49   void fast_unlock_lightweight(Register obj, Register reg_rax, Register t, Register thread);
 50 
 51 #if INCLUDE_RTM_OPT
 52   void rtm_counters_update(Register abort_status, Register rtm_counters);
 53   void branch_on_random_using_rdtsc(Register tmp, Register scr, int count, Label& brLabel);
 54   void rtm_abort_ratio_calculation(Register tmp, Register rtm_counters_reg,
 55                                    RTMLockingCounters* rtm_counters,
 56                                    Metadata* method_data);
 57   void rtm_profiling(Register abort_status_Reg, Register rtm_counters_Reg,
 58                      RTMLockingCounters* rtm_counters, Metadata* method_data, bool profile_rtm);
 59   void rtm_retry_lock_on_abort(Register retry_count, Register abort_status, Label& retryLabel);
 60   void rtm_retry_lock_on_busy(Register retry_count, Register box, Register tmp, Register scr, Label& retryLabel);
 61   void rtm_stack_locking(Register obj, Register tmp, Register scr,
 62                          Register retry_on_abort_count,
 63                          RTMLockingCounters* stack_rtm_counters,
 64                          Metadata* method_data, bool profile_rtm,
 65                          Label& DONE_LABEL, Label& IsInflated);
 66   void rtm_inflated_locking(Register obj, Register box, Register tmp,
 67                             Register scr, Register retry_on_busy_count,
 68                             Register retry_on_abort_count,
 69                             RTMLockingCounters* rtm_counters,
 70                             Metadata* method_data, bool profile_rtm,
 71                             Label& DONE_LABEL);
 72 #endif
 73 
 74   // Generic instructions support for use in .ad files C2 code generation
 75   void vabsnegd(int opcode, XMMRegister dst, XMMRegister src);
 76   void vabsnegd(int opcode, XMMRegister dst, XMMRegister src, int vector_len);
 77   void vabsnegf(int opcode, XMMRegister dst, XMMRegister src);
 78   void vabsnegf(int opcode, XMMRegister dst, XMMRegister src, int vector_len);
 79 
 80   void pminmax(int opcode, BasicType elem_bt, XMMRegister dst, XMMRegister src,
 81                XMMRegister tmp = xnoreg);
 82   void vpminmax(int opcode, BasicType elem_bt,
 83                 XMMRegister dst, XMMRegister src1, XMMRegister src2,
 84                 int vlen_enc);
 85 
 86   void vminmax_fp(int opcode, BasicType elem_bt,
 87                   XMMRegister dst, XMMRegister a, XMMRegister b,
 88                   XMMRegister tmp, XMMRegister atmp, XMMRegister btmp,
 89                   int vlen_enc);
 90   void evminmax_fp(int opcode, BasicType elem_bt,
 91                    XMMRegister dst, XMMRegister a, XMMRegister b,
 92                    KRegister ktmp, XMMRegister atmp, XMMRegister btmp,
 93                    int vlen_enc);
 94 
 95   void signum_fp(int opcode, XMMRegister dst, XMMRegister zero, XMMRegister one);
 96 
 97   void vector_compress_expand(int opcode, XMMRegister dst, XMMRegister src, KRegister mask,
 98                               bool merge, BasicType bt, int vec_enc);
 99 
100   void vector_mask_compress(KRegister dst, KRegister src, Register rtmp1, Register rtmp2, int mask_len);
101 
102   void vextendbw(bool sign, XMMRegister dst, XMMRegister src, int vector_len);
103   void vextendbw(bool sign, XMMRegister dst, XMMRegister src);
104   void vextendbd(bool sign, XMMRegister dst, XMMRegister src, int vector_len);
105   void vextendwd(bool sign, XMMRegister dst, XMMRegister src, int vector_len);
106 
107   void vshiftd(int opcode, XMMRegister dst, XMMRegister shift);
108   void vshiftd_imm(int opcode, XMMRegister dst, int shift);
109   void vshiftd(int opcode, XMMRegister dst, XMMRegister src, XMMRegister shift, int vlen_enc);
110   void vshiftd_imm(int opcode, XMMRegister dst, XMMRegister nds, int shift, int vector_len);
111   void vshiftw(int opcode, XMMRegister dst, XMMRegister shift);
112   void vshiftw(int opcode, XMMRegister dst, XMMRegister src, XMMRegister shift, int vlen_enc);
113   void vshiftq(int opcode, XMMRegister dst, XMMRegister shift);
114   void vshiftq_imm(int opcode, XMMRegister dst, int shift);
115   void vshiftq(int opcode, XMMRegister dst, XMMRegister src, XMMRegister shift, int vlen_enc);
116   void vshiftq_imm(int opcode, XMMRegister dst, XMMRegister nds, int shift, int vector_len);
117 
118   void vprotate_imm(int opcode, BasicType etype, XMMRegister dst, XMMRegister src, int shift, int vector_len);
119   void vprotate_var(int opcode, BasicType etype, XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len);
120 
121   void varshiftd(int opcode, XMMRegister dst, XMMRegister src, XMMRegister shift, int vlen_enc);
122   void varshiftw(int opcode, XMMRegister dst, XMMRegister src, XMMRegister shift, int vlen_enc);
123   void varshiftq(int opcode, XMMRegister dst, XMMRegister src, XMMRegister shift, int vlen_enc, XMMRegister vtmp = xnoreg);
124   void varshiftbw(int opcode, XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len, XMMRegister vtmp);
125   void evarshiftb(int opcode, XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len, XMMRegister vtmp);
126 
127   void insert(BasicType typ, XMMRegister dst, Register val, int idx);
128   void vinsert(BasicType typ, XMMRegister dst, XMMRegister src, Register val, int idx);
129   void vgather(BasicType typ, XMMRegister dst, Register base, XMMRegister idx, XMMRegister mask, int vector_len);
130   void evgather(BasicType typ, XMMRegister dst, KRegister mask, Register base, XMMRegister idx, int vector_len);
131   void evscatter(BasicType typ, Register base, XMMRegister idx, KRegister mask, XMMRegister src, int vector_len);
132 
133   void evmovdqu(BasicType type, KRegister kmask, XMMRegister dst, Address src, bool merge, int vector_len);
134   void evmovdqu(BasicType type, KRegister kmask, Address dst, XMMRegister src, bool merge, int vector_len);
135 
136   // extract
137   void extract(BasicType typ, Register dst, XMMRegister src, int idx);
138   XMMRegister get_lane(BasicType typ, XMMRegister dst, XMMRegister src, int elemindex);
139   void get_elem(BasicType typ, Register dst, XMMRegister src, int elemindex);
140   void get_elem(BasicType typ, XMMRegister dst, XMMRegister src, int elemindex, XMMRegister vtmp = xnoreg);
141   void movsxl(BasicType typ, Register dst);
142 
143   // vector test
144   void vectortest(BasicType bt, XMMRegister src1, XMMRegister src2, XMMRegister vtmp, int vlen_in_bytes);
145 
146  // Covert B2X
147  void vconvert_b2x(BasicType to_elem_bt, XMMRegister dst, XMMRegister src, int vlen_enc);
148 #ifdef _LP64
149  void vpbroadcast(BasicType elem_bt, XMMRegister dst, Register src, int vlen_enc);
150 #endif
151 
152   // blend
153   void evpcmp(BasicType typ, KRegister kdmask, KRegister ksmask, XMMRegister src1, XMMRegister    src2, int comparison, int vector_len);
154   void evpcmp(BasicType typ, KRegister kdmask, KRegister ksmask, XMMRegister src1, AddressLiteral src2, int comparison, int vector_len, Register rscratch = noreg);
155   void evpblend(BasicType typ, XMMRegister dst, KRegister kmask, XMMRegister src1, XMMRegister src2, bool merge, int vector_len);
156 
157   void load_vector(XMMRegister dst, Address        src, int vlen_in_bytes);
158   void load_vector(XMMRegister dst, AddressLiteral src, int vlen_in_bytes, Register rscratch = noreg);
159 
160   void load_vector_mask(XMMRegister dst, XMMRegister src, int vlen_in_bytes, BasicType elem_bt, bool is_legacy);
161   void load_vector_mask(KRegister   dst, XMMRegister src, XMMRegister xtmp, bool novlbwdq, int vlen_enc);
162 
163   void load_constant_vector(BasicType bt, XMMRegister dst, InternalAddress src, int vlen);
164   void load_iota_indices(XMMRegister dst, int vlen_in_bytes, BasicType bt);
165 
166   // Reductions for vectors of bytes, shorts, ints, longs, floats, and doubles.
167 
168   // dst = src1  reduce(op, src2) using vtmp as temps
169   void reduceI(int opcode, int vlen, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
170 #ifdef _LP64
171   void reduceL(int opcode, int vlen, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
172   void genmask(KRegister dst, Register len, Register temp);
173 #endif // _LP64
174 
175   // dst = reduce(op, src2) using vtmp as temps
176   void reduce_fp(int opcode, int vlen,
177                  XMMRegister dst, XMMRegister src,
178                  XMMRegister vtmp1, XMMRegister vtmp2 = xnoreg);
179   void reduceB(int opcode, int vlen, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
180   void mulreduceB(int opcode, int vlen, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
181   void reduceS(int opcode, int vlen, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
182   void reduceFloatMinMax(int opcode, int vlen, bool is_dst_valid,
183                          XMMRegister dst, XMMRegister src,
184                          XMMRegister tmp, XMMRegister atmp, XMMRegister btmp, XMMRegister xmm_0, XMMRegister xmm_1 = xnoreg);
185   void reduceDoubleMinMax(int opcode, int vlen, bool is_dst_valid,
186                           XMMRegister dst, XMMRegister src,
187                           XMMRegister tmp, XMMRegister atmp, XMMRegister btmp, XMMRegister xmm_0, XMMRegister xmm_1 = xnoreg);
188  private:
189   void reduceF(int opcode, int vlen, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2);
190   void reduceD(int opcode, int vlen, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2);
191 
192   // Int Reduction
193   void reduce2I (int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
194   void reduce4I (int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
195   void reduce8I (int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
196   void reduce16I(int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
197 
198   // Byte Reduction
199   void reduce8B (int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
200   void reduce16B(int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
201   void reduce32B(int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
202   void reduce64B(int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
203   void mulreduce8B (int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
204   void mulreduce16B(int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
205   void mulreduce32B(int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
206   void mulreduce64B(int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
207 
208   // Short Reduction
209   void reduce4S (int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
210   void reduce8S (int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
211   void reduce16S(int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
212   void reduce32S(int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
213 
214   // Long Reduction
215 #ifdef _LP64
216   void reduce2L(int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
217   void reduce4L(int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
218   void reduce8L(int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
219 #endif // _LP64
220 
221   // Float Reduction
222   void reduce2F (int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp);
223   void reduce4F (int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp);
224   void reduce8F (int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2);
225   void reduce16F(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2);
226 
227   // Double Reduction
228   void reduce2D(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp);
229   void reduce4D(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2);
230   void reduce8D(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2);
231 
232   // Base reduction instruction
233   void reduce_operation_128(BasicType typ, int opcode, XMMRegister dst, XMMRegister src);
234   void reduce_operation_256(BasicType typ, int opcode, XMMRegister dst, XMMRegister src1, XMMRegister src2);
235 
236  public:
237 #ifdef _LP64
238   void vector_mask_operation_helper(int opc, Register dst, Register tmp, int masklen);
239 
240   void vector_mask_operation(int opc, Register dst, KRegister mask, Register tmp, int masklen, int masksize, int vec_enc);
241 
242   void vector_mask_operation(int opc, Register dst, XMMRegister mask, XMMRegister xtmp,
243                              Register tmp, int masklen, BasicType bt, int vec_enc);
244   void vector_long_to_maskvec(XMMRegister dst, Register src, Register rtmp1,
245                               Register rtmp2, XMMRegister xtmp, int mask_len, int vec_enc);
246 #endif
247 
248   void vector_maskall_operation(KRegister dst, Register src, int mask_len);
249 
250 #ifndef _LP64
251   void vector_maskall_operation32(KRegister dst, Register src, KRegister ktmp, int mask_len);
252 #endif
253 
254   void string_indexof_char(Register str1, Register cnt1, Register ch, Register result,
255                            XMMRegister vec1, XMMRegister vec2, XMMRegister vec3, Register tmp);
256 
257   void stringL_indexof_char(Register str1, Register cnt1, Register ch, Register result,
258                            XMMRegister vec1, XMMRegister vec2, XMMRegister vec3, Register tmp);
259 
260   // IndexOf strings.
261   // Small strings are loaded through stack if they cross page boundary.
262   void string_indexof(Register str1, Register str2,
263                       Register cnt1, Register cnt2,
264                       int int_cnt2,  Register result,
265                       XMMRegister vec, Register tmp,
266                       int ae);
267 
268   // IndexOf for constant substrings with size >= 8 elements
269   // which don't need to be loaded through stack.
270   void string_indexofC8(Register str1, Register str2,
271                       Register cnt1, Register cnt2,
272                       int int_cnt2,  Register result,
273                       XMMRegister vec, Register tmp,
274                       int ae);
275 
276     // Smallest code: we don't need to load through stack,
277     // check string tail.
278 
279   // helper function for string_compare
280   void load_next_elements(Register elem1, Register elem2, Register str1, Register str2,
281                           Address::ScaleFactor scale, Address::ScaleFactor scale1,
282                           Address::ScaleFactor scale2, Register index, int ae);
283   // Compare strings.
284   void string_compare(Register str1, Register str2,
285                       Register cnt1, Register cnt2, Register result,
286                       XMMRegister vec1, int ae, KRegister mask = knoreg);
287 
288   // Search for Non-ASCII character (Negative byte value) in a byte array,
289   // return index of the first such character, otherwise len.
290   void count_positives(Register ary1, Register len,
291                        Register result, Register tmp1,
292                        XMMRegister vec1, XMMRegister vec2, KRegister mask1 = knoreg, KRegister mask2 = knoreg);
293   // Compare char[] or byte[] arrays.
294   void arrays_equals(bool is_array_equ, Register ary1, Register ary2,
295                      Register limit, Register result, Register chr,
296                      XMMRegister vec1, XMMRegister vec2, bool is_char, KRegister mask = knoreg);
297 
298   void arrays_hashcode(Register str1, Register cnt1, Register result,
299                        Register tmp1, Register tmp2, Register tmp3, XMMRegister vnext,
300                        XMMRegister vcoef0, XMMRegister vcoef1, XMMRegister vcoef2, XMMRegister vcoef3,
301                        XMMRegister vresult0, XMMRegister vresult1, XMMRegister vresult2, XMMRegister vresult3,
302                        XMMRegister vtmp0, XMMRegister vtmp1, XMMRegister vtmp2, XMMRegister vtmp3,
303                        BasicType eltype);
304 
305   // helper functions for arrays_hashcode
306   int arrays_hashcode_elsize(BasicType eltype);
307   void arrays_hashcode_elload(Register dst, Address src, BasicType eltype);
308   void arrays_hashcode_elvload(XMMRegister dst, Address src, BasicType eltype);
309   void arrays_hashcode_elvload(XMMRegister dst, AddressLiteral src, BasicType eltype);
310   void arrays_hashcode_elvcast(XMMRegister dst, BasicType eltype);
311 
312 #ifdef _LP64
313   void convertF2I(BasicType dst_bt, BasicType src_bt, Register dst, XMMRegister src);
314 #endif
315 
316   void evmasked_op(int ideal_opc, BasicType eType, KRegister mask,
317                    XMMRegister dst, XMMRegister src1, XMMRegister src2,
318                    bool merge, int vlen_enc, bool is_varshift = false);
319 
320   void evmasked_op(int ideal_opc, BasicType eType, KRegister mask,
321                    XMMRegister dst, XMMRegister src1, Address src2,
322                    bool merge, int vlen_enc);
323 
324   void evmasked_op(int ideal_opc, BasicType eType, KRegister mask, XMMRegister dst,
325                    XMMRegister src1, int imm8, bool merge, int vlen_enc);
326 
327   void masked_op(int ideal_opc, int mask_len, KRegister dst,
328                  KRegister src1, KRegister src2);
329 
330   void vector_unsigned_cast(XMMRegister dst, XMMRegister src, int vlen_enc,
331                             BasicType from_elem_bt, BasicType to_elem_bt);
332 
333   void vector_signed_cast(XMMRegister dst, XMMRegister src, int vlen_enc,
334                           BasicType from_elem_bt, BasicType to_elem_bt);
335 
336   void vector_cast_int_to_subword(BasicType to_elem_bt, XMMRegister dst, XMMRegister zero,
337                                   XMMRegister xtmp, Register rscratch, int vec_enc);
338 
339   void vector_castF2X_avx(BasicType to_elem_bt, XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
340                           XMMRegister xtmp2, XMMRegister xtmp3, XMMRegister xtmp4,
341                           AddressLiteral float_sign_flip, Register rscratch, int vec_enc);
342 
343   void vector_castF2X_evex(BasicType to_elem_bt, XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
344                            XMMRegister xtmp2, KRegister ktmp1, KRegister ktmp2, AddressLiteral float_sign_flip,
345                            Register rscratch, int vec_enc);
346 
347   void vector_castF2L_evex(XMMRegister dst, XMMRegister src, XMMRegister xtmp1, XMMRegister xtmp2,
348                            KRegister ktmp1, KRegister ktmp2, AddressLiteral double_sign_flip,
349                            Register rscratch, int vec_enc);
350 
351   void vector_castD2X_evex(BasicType to_elem_bt, XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
352                            XMMRegister xtmp2, KRegister ktmp1, KRegister ktmp2, AddressLiteral sign_flip,
353                            Register rscratch, int vec_enc);
354 
355   void vector_castD2X_avx(BasicType to_elem_bt, XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
356                           XMMRegister xtmp2, XMMRegister xtmp3, XMMRegister xtmp4, XMMRegister xtmp5,
357                           AddressLiteral float_sign_flip, Register rscratch, int vec_enc);
358 
359 
360   void vector_cast_double_to_int_special_cases_avx(XMMRegister dst, XMMRegister src, XMMRegister xtmp1, XMMRegister xtmp2,
361                                                    XMMRegister xtmp3, XMMRegister xtmp4, XMMRegister xtmp5, Register rscratch,
362                                                    AddressLiteral float_sign_flip, int vec_enc);
363 
364   void vector_cast_double_to_int_special_cases_evex(XMMRegister dst, XMMRegister src, XMMRegister xtmp1, XMMRegister xtmp2,
365                                                     KRegister ktmp1, KRegister ktmp2, Register rscratch, AddressLiteral float_sign_flip,
366                                                     int vec_enc);
367 
368   void vector_cast_double_to_long_special_cases_evex(XMMRegister dst, XMMRegister src, XMMRegister xtmp1, XMMRegister xtmp2,
369                                                      KRegister ktmp1, KRegister ktmp2, Register rscratch, AddressLiteral double_sign_flip,
370                                                      int vec_enc);
371 
372   void vector_cast_float_to_int_special_cases_evex(XMMRegister dst, XMMRegister src, XMMRegister xtmp1, XMMRegister xtmp2,
373                                                    KRegister ktmp1, KRegister ktmp2, Register rscratch, AddressLiteral float_sign_flip,
374                                                    int vec_enc);
375 
376   void vector_cast_float_to_long_special_cases_evex(XMMRegister dst, XMMRegister src, XMMRegister xtmp1, XMMRegister xtmp2,
377                                                     KRegister ktmp1, KRegister ktmp2, Register rscratch, AddressLiteral double_sign_flip,
378                                                     int vec_enc);
379 
380   void vector_cast_float_to_int_special_cases_avx(XMMRegister dst, XMMRegister src, XMMRegister xtmp1, XMMRegister xtmp2, XMMRegister xtmp3,
381                                                   XMMRegister xtmp4, Register rscratch, AddressLiteral float_sign_flip,
382                                                   int vec_enc);
383 
384   void vector_crosslane_doubleword_pack_avx(XMMRegister dst, XMMRegister src, XMMRegister zero,
385                                             XMMRegister xtmp, int index, int vec_enc);
386 
387   void vector_mask_cast(XMMRegister dst, XMMRegister src, BasicType dst_bt, BasicType src_bt, int vlen);
388 
389 #ifdef _LP64
390   void vector_round_double_evex(XMMRegister dst, XMMRegister src, AddressLiteral double_sign_flip, AddressLiteral new_mxcsr, int vec_enc,
391                                 Register tmp, XMMRegister xtmp1, XMMRegister xtmp2, KRegister ktmp1, KRegister ktmp2);
392 
393   void vector_round_float_evex(XMMRegister dst, XMMRegister src, AddressLiteral double_sign_flip, AddressLiteral new_mxcsr, int vec_enc,
394                                Register tmp, XMMRegister xtmp1, XMMRegister xtmp2, KRegister ktmp1, KRegister ktmp2);
395 
396   void vector_round_float_avx(XMMRegister dst, XMMRegister src, AddressLiteral float_sign_flip, AddressLiteral new_mxcsr, int vec_enc,
397                               Register tmp, XMMRegister xtmp1, XMMRegister xtmp2, XMMRegister xtmp3, XMMRegister xtmp4);
398 
399   void vector_compress_expand_avx2(int opcode, XMMRegister dst, XMMRegister src, XMMRegister mask,
400                                    Register rtmp, Register rscratch, XMMRegister permv, XMMRegister xtmp,
401                                    BasicType bt, int vec_enc);
402 #endif // _LP64
403 
404   void udivI(Register rax, Register divisor, Register rdx);
405   void umodI(Register rax, Register divisor, Register rdx);
406   void udivmodI(Register rax, Register divisor, Register rdx, Register tmp);
407 
408 #ifdef _LP64
409   void reverseI(Register dst, Register src, XMMRegister xtmp1,
410                 XMMRegister xtmp2, Register rtmp);
411   void reverseL(Register dst, Register src, XMMRegister xtmp1,
412                 XMMRegister xtmp2, Register rtmp1, Register rtmp2);
413   void udivL(Register rax, Register divisor, Register rdx);
414   void umodL(Register rax, Register divisor, Register rdx);
415   void udivmodL(Register rax, Register divisor, Register rdx, Register tmp);
416 #endif
417 
418   void evpternlog(XMMRegister dst, int func, KRegister mask, XMMRegister src2, XMMRegister src3,
419                   bool merge, BasicType bt, int vlen_enc);
420 
421   void evpternlog(XMMRegister dst, int func, KRegister mask, XMMRegister src2, Address src3,
422                   bool merge, BasicType bt, int vlen_enc);
423 
424   void vector_reverse_bit(BasicType bt, XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
425                           XMMRegister xtmp2, Register rtmp, int vec_enc);
426 
427   void vector_reverse_bit_gfni(BasicType bt, XMMRegister dst, XMMRegister src, AddressLiteral mask, int vec_enc,
428                                XMMRegister xtmp, Register rscratch = noreg);
429 
430   void vector_reverse_byte(BasicType bt, XMMRegister dst, XMMRegister src, int vec_enc);
431 
432   void vector_popcount_int(XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
433                            XMMRegister xtmp2, Register rtmp, int vec_enc);
434 
435   void vector_popcount_long(XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
436                             XMMRegister xtmp2, Register rtmp, int vec_enc);
437 
438   void vector_popcount_short(XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
439                              XMMRegister xtmp2, Register rtmp, int vec_enc);
440 
441   void vector_popcount_byte(XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
442                             XMMRegister xtmp2, Register rtmp, int vec_enc);
443 
444   void vector_popcount_integral(BasicType bt, XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
445                                 XMMRegister xtmp2, Register rtmp, int vec_enc);
446 
447   void vector_popcount_integral_evex(BasicType bt, XMMRegister dst, XMMRegister src,
448                                      KRegister mask, bool merge, int vec_enc);
449 
450   void vbroadcast(BasicType bt, XMMRegister dst, int imm32, Register rtmp, int vec_enc);
451 
452   void vector_reverse_byte64(BasicType bt, XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
453                              XMMRegister xtmp2, Register rtmp, int vec_enc);
454 
455   void vector_count_leading_zeros_evex(BasicType bt, XMMRegister dst, XMMRegister src,
456                                        XMMRegister xtmp1, XMMRegister xtmp2, XMMRegister xtmp3,
457                                        KRegister ktmp, Register rtmp, bool merge, int vec_enc);
458 
459   void vector_count_leading_zeros_byte_avx(XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
460                                            XMMRegister xtmp2, XMMRegister xtmp3, Register rtmp, int vec_enc);
461 
462   void vector_count_leading_zeros_short_avx(XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
463                                             XMMRegister xtmp2, XMMRegister xtmp3, Register rtmp, int vec_enc);
464 
465   void vector_count_leading_zeros_int_avx(XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
466                                           XMMRegister xtmp2, XMMRegister xtmp3, int vec_enc);
467 
468   void vector_count_leading_zeros_long_avx(XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
469                                            XMMRegister xtmp2, XMMRegister xtmp3, Register rtmp, int vec_enc);
470 
471   void vector_count_leading_zeros_avx(BasicType bt, XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
472                                       XMMRegister xtmp2, XMMRegister xtmp3, Register rtmp, int vec_enc);
473 
474   void vpadd(BasicType bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, int vec_enc);
475 
476   void vpsub(BasicType bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, int vec_enc);
477 
478   void vector_count_trailing_zeros_evex(BasicType bt, XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
479                                         XMMRegister xtmp2, XMMRegister xtmp3, XMMRegister xtmp4, KRegister ktmp,
480                                         Register rtmp, int vec_enc);
481 
482   void vector_swap_nbits(int nbits, int bitmask, XMMRegister dst, XMMRegister src,
483                          XMMRegister xtmp1, Register rtmp, int vec_enc);
484 
485   void vector_count_trailing_zeros_avx(BasicType bt, XMMRegister dst, XMMRegister src, XMMRegister xtmp1,
486                                        XMMRegister xtmp2, XMMRegister xtmp3, Register rtmp, int vec_enc);
487 
488   void vector_signum_avx(int opcode, XMMRegister dst, XMMRegister src, XMMRegister zero, XMMRegister one,
489                          XMMRegister xtmp1, int vec_enc);
490 
491   void vector_signum_evex(int opcode, XMMRegister dst, XMMRegister src, XMMRegister zero, XMMRegister one,
492                           KRegister ktmp1, int vec_enc);
493 
494   void vmovmask(BasicType elem_bt, XMMRegister dst, Address src, XMMRegister mask, int vec_enc);
495 
496   void vmovmask(BasicType elem_bt, Address dst, XMMRegister src, XMMRegister mask, int vec_enc);
497 
498   void rearrange_bytes(XMMRegister dst, XMMRegister shuffle, XMMRegister src, XMMRegister xtmp1,
499                        XMMRegister xtmp2, XMMRegister xtmp3, Register rtmp, KRegister ktmp, int vlen_enc);
500 
501   void vector_rearrange_int_float(BasicType bt, XMMRegister dst, XMMRegister shuffle,
502                                   XMMRegister src, int vlen_enc);
503 
504 #endif // CPU_X86_C2_MACROASSEMBLER_X86_HPP