1 /*
 2  * Copyright (c) 2020, 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_PPC_C2_MACROASSEMBLER_PPC_HPP
26 #define CPU_PPC_C2_MACROASSEMBLER_PPC_HPP
27 
28 // C2_MacroAssembler contains high-level macros for C2
29 
30  public:
31   // Code used by cmpFastLockLightweight and cmpFastUnlockLightweight mach instructions in .ad file.
32   void fast_lock_lightweight(ConditionRegister flag, Register obj, Register box,
33                              Register tmp1, Register tmp2, Register tmp3);
34   void fast_unlock_lightweight(ConditionRegister flag, Register obj, Register box,
35                                Register tmp1, Register tmp2, Register tmp3);
36 
37   // Intrinsics for CompactStrings
38   // Compress char[] to byte[] by compressing 16 bytes at once.
39   void string_compress_16(Register src, Register dst, Register cnt,
40                           Register tmp1, Register tmp2, Register tmp3, Register tmp4, Register tmp5,
41                           Label& Lfailure, bool ascii = false);
42 
43   // Compress char[] to byte[]. cnt must be positive int.
44   void string_compress(Register src, Register dst, Register cnt, Register tmp,
45                        Label& Lfailure, bool ascii = false);
46 
47   // Encode UTF16 to ISO_8859_1 or ASCII. Return len on success or position of first mismatch.
48   void encode_iso_array(Register src, Register dst, Register len,
49                         Register tmp1, Register tmp2, Register tmp3, Register tmp4, Register tmp5,
50                         Register result, bool ascii);
51 
52   // Inflate byte[] to char[] by inflating 16 bytes at once.
53   void string_inflate_16(Register src, Register dst, Register cnt,
54                          Register tmp1, Register tmp2, Register tmp3, Register tmp4, Register tmp5);
55 
56   // Inflate byte[] to char[]. cnt must be positive int.
57   void string_inflate(Register src, Register dst, Register cnt, Register tmp);
58 
59   void string_compare(Register str1, Register str2, Register cnt1, Register cnt2,
60                       Register tmp1, Register result, int ae);
61 
62   void array_equals(bool is_array_equ, Register ary1, Register ary2,
63                     Register limit, Register tmp1, Register result, bool is_byte);
64 
65   void string_indexof(Register result, Register haystack, Register haycnt,
66                       Register needle, ciTypeArray* needle_values, Register needlecnt, int needlecntval,
67                       Register tmp1, Register tmp2, Register tmp3, Register tmp4, int ae);
68 
69   void string_indexof_char(Register result, Register haystack, Register haycnt,
70                            Register needle, jchar needleChar, Register tmp1, Register tmp2, bool is_byte);
71 
72   void count_positives(Register src, Register cnt, Register result, Register tmp1, Register tmp2);
73 
74 #endif // CPU_PPC_C2_MACROASSEMBLER_PPC_HPP