Bug 497723 - forgot to restore callgrind output cleanup
[valgrind.git] / VEX / priv / guest_ppc_defs.h
blob220fbf1395ec364fdc991dbb2c66fd2029a59ae0
2 /*---------------------------------------------------------------*/
3 /*--- begin guest_ppc_defs.h ---*/
4 /*---------------------------------------------------------------*/
6 /*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
10 Copyright (C) 2004-2017 OpenWorks LLP
11 info@open-works.net
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
28 Neither the names of the U.S. Department of Energy nor the
29 University of California nor the names of its contributors may be
30 used to endorse or promote products derived from this software
31 without prior written permission.
34 /* Only to be used within the guest-ppc directory. */
37 #ifndef __VEX_GUEST_PPC_DEFS_H
38 #define __VEX_GUEST_PPC_DEFS_H
40 #include "libvex_basictypes.h"
41 #include "libvex_guest_ppc32.h" // VexGuestPPC32State
42 #include "libvex_guest_ppc64.h" // VexGuestPPC64State
43 #include "guest_generic_bb_to_IR.h" // DisResult
45 /*---------------------------------------------------------*/
46 /*--- ppc to IR conversion ---*/
47 /*---------------------------------------------------------*/
49 /* Convert one ppc insn to IR. See the type DisOneInstrFn in
50 guest_generic_bb_to_IR.h. */
51 extern
52 DisResult disInstr_PPC ( IRSB* irbb,
53 const UChar* guest_code,
54 Long delta,
55 Addr guest_IP,
56 VexArch guest_arch,
57 const VexArchInfo* archinfo,
58 const VexAbiInfo* abiinfo,
59 VexEndness host_endness,
60 Bool sigill_diag );
62 /* Used by the optimiser to specialise calls to helpers. */
63 extern
64 IRExpr* guest_ppc32_spechelper ( const HChar* function_name,
65 IRExpr** args,
66 IRStmt** precedingStmts,
67 Int n_precedingStmts );
69 extern
70 IRExpr* guest_ppc64_spechelper ( const HChar* function_name,
71 IRExpr** args,
72 IRStmt** precedingStmts,
73 Int n_precedingStmts );
75 /* Describes to the optimser which part of the guest state require
76 precise memory exceptions. This is logically part of the guest
77 state description. */
78 extern
79 Bool guest_ppc32_state_requires_precise_mem_exns ( Int, Int,
80 VexRegisterUpdates );
82 extern
83 Bool guest_ppc64_state_requires_precise_mem_exns ( Int, Int,
84 VexRegisterUpdates );
86 extern
87 VexGuestLayout ppc32Guest_layout;
89 extern
90 VexGuestLayout ppc64Guest_layout;
93 /* FP Rounding mode - different encoding to IR */
94 typedef
95 enum {
96 PPCrm_NEAREST = 0,
97 PPCrm_NegINF = 1,
98 PPCrm_PosINF = 2,
99 PPCrm_ZERO = 3
100 } PPCRoundingMode;
102 /* Floating point comparison values - different encoding to IR */
103 typedef
104 enum {
105 PPCcr_LT = 0x8,
106 PPCcr_GT = 0x4,
107 PPCcr_EQ = 0x2,
108 PPCcr_UN = 0x1
110 PPCCmpF64Result;
113 Enumeration for xer_ca/ov calculation helper functions
115 enum {
116 /* 0 */ PPCG_FLAG_OP_ADD=0, // addc[o], addic
117 /* 1 */ PPCG_FLAG_OP_ADDE, // adde[o], addme[o], addze[o]
118 /* 2 */ PPCG_FLAG_OP_DIVW, // divwo
119 /* 3 */ PPCG_FLAG_OP_DIVWU, // divwuo
120 /* 4 */ PPCG_FLAG_OP_MULLW, // mullwo
121 /* 5 */ PPCG_FLAG_OP_NEG, // nego
122 /* 6 */ PPCG_FLAG_OP_SUBF, // subfo
123 /* 7 */ PPCG_FLAG_OP_SUBFC, // subfc[o]
124 /* 8 */ PPCG_FLAG_OP_SUBFE, // subfe[o], subfme[o], subfze[o]
125 /* 9 */ PPCG_FLAG_OP_SUBFI, // subfic
126 /* 10 */ PPCG_FLAG_OP_SRAW, // sraw
127 /* 11 */ PPCG_FLAG_OP_SRAWI, // srawi
128 /* 12 */ PPCG_FLAG_OP_SRAD, // srad
129 /* 13 */ PPCG_FLAG_OP_SRADI, // sradi
130 /* 14 */ PPCG_FLAG_OP_DIVDE, // divdeo
131 /* 15 */ PPCG_FLAG_OP_DIVWEU, // divweuo
132 /* 16 */ PPCG_FLAG_OP_DIVWE, // divweo
133 /* 17 */ PPCG_FLAG_OP_DIVDEU, // divdeuo
134 /* 18 */ PPCG_FLAG_OP_MULLD, // mulldo
135 PPCG_FLAG_OP_NUMBER
139 /*---------------------------------------------------------*/
140 /*--- ppc guest helpers ---*/
141 /*---------------------------------------------------------*/
143 /* --- CLEAN HELPERS --- */
145 extern ULong is_BCDstring128_helper( ULong Signed, ULong hi64, ULong low64 );
146 extern ULong increment_BCDstring32_helper( ULong Signed,
147 ULong bcd_string, ULong carry_in );
148 extern ULong convert_to_zoned_helper( ULong src_hi, ULong src_low,
149 ULong upper_byte,
150 ULong return_upper );
151 extern ULong convert_to_national_helper( ULong src, ULong return_upper );
152 extern ULong convert_from_zoned_helper( ULong src_hi, ULong src_low );
153 extern ULong convert_from_floattobf16_helper( ULong src );
154 extern ULong convert_from_bf16tofloat_helper( ULong src );
155 extern ULong convert_from_national_helper( ULong src_hi, ULong src_low );
156 extern ULong generate_C_FPCC_helper( ULong size, ULong src_hi, ULong src );
157 extern ULong extract_bits_under_mask_helper( ULong src, ULong mask,
158 UInt flag );
159 extern UInt generate_DFP_FPRF_value_helper( UInt gfield, ULong exponent,
160 UInt exponent_bias,
161 Int min_norm_exp,
162 UInt sign, UInt T_value_is_zero );
163 extern UInt count_bits_under_mask_helper( ULong src, ULong mask,
164 UInt flag );
165 extern ULong deposit_bits_under_mask_helper( ULong src, ULong mask );
166 extern ULong population_count64_helper( ULong src );
167 extern UInt vbpermq_clean_helper( ULong vA_high, ULong vA_low, ULong vB);
168 extern ULong vector_evaluate64_helper( ULong srcA, ULong srcB, ULong srcC,
169 ULong IMM );
170 void write_ACC_entry (VexGuestPPC64State* gst, UInt offset, UInt acc,
171 UInt reg, UInt *result);
172 void get_ACC_entry (VexGuestPPC64State* gst, UInt offset, UInt acc,
173 UInt reg, UInt *result);
175 extern void vector_gen_pvc_byte_mask_dirty_helper( VexGuestPPC64State* gst,
176 ULong src_hi,
177 ULong src_lo,
178 UInt rtn_val, UInt IMM );
179 extern void vector_gen_pvc_hword_mask_dirty_helper( VexGuestPPC64State* gst,
180 ULong src_hi,
181 ULong src_lo,
182 UInt rtn_val, UInt IMM );
183 extern void vector_gen_pvc_word_mask_dirty_helper( VexGuestPPC64State* gst,
184 ULong src_hi,
185 ULong src_lo,
186 UInt rtn_val, UInt IMM );
187 extern void vector_gen_pvc_dword_mask_dirty_helper( VexGuestPPC64State* gst,
188 ULong src_hi,
189 ULong src_lo,
190 UInt rtn_val, UInt IMM );
192 /* 8-bit XO value from instruction description */
193 #define XVI4GER8 0b00100011
194 #define XVI4GER8PP 0b00100010
195 #define XVI8GER4 0b00000011
196 #define XVI8GER4PP 0b00000010
197 #define XVI8GER4SPP 0b01100011
198 #define XVI16GER2 0b01001011
199 #define XVI16GER2PP 0b01101011
200 #define XVI16GER2S 0b00101011
201 #define XVI16GER2SPP 0b00101010
202 #define XVF16GER2 0b00010011
203 #define XVF16GER2PP 0b00010010
204 #define XVF16GER2PN 0b10010010
205 #define XVF16GER2NP 0b01010010
206 #define XVF16GER2NN 0b11010010
207 #define XVBF16GER2 0b00110011
208 #define XVBF16GER2PP 0b00110010
209 #define XVBF16GER2PN 0b10110010
210 #define XVBF16GER2NP 0b01110010
211 #define XVBF16GER2NN 0b11110010
212 #define XVF32GER 0b00011011
213 #define XVF32GERPP 0b00011010
214 #define XVF32GERPN 0b10011010
215 #define XVF32GERNP 0b01011010
216 #define XVF32GERNN 0b11011010
217 #define XVF64GER 0b00111011
218 #define XVF64GERPP 0b00111010
219 #define XVF64GERPN 0b10111010
220 #define XVF64GERNP 0b01111010
221 #define XVF64GERNN 0b11111010
223 #define INVALD_INST 1
224 #define COPY_INST 2
225 #define PASTE_INST 3
226 #define CPABORT_INST 4
228 /* --- DIRTY HELPERS --- */
230 extern ULong ppcg_dirtyhelper_MFTB ( void );
232 extern UInt ppc32g_dirtyhelper_MFSPR_268_269 ( UInt );
234 extern UInt ppc32g_dirtyhelper_MFSPR_287 ( void );
236 extern void ppc32g_dirtyhelper_LVS ( VexGuestPPC32State* gst,
237 UInt vD_idx, UInt sh,
238 UInt shift_right );
240 extern void ppc64g_dirtyhelper_LVS ( VexGuestPPC64State* gst,
241 UInt vD_idx, UInt sh,
242 UInt shift_right,
243 UInt endness );
245 extern void vsx_matrix_4bit_ger_dirty_helper( VexGuestPPC64State* gst,
246 UInt offset,
247 ULong srcA_hi, ULong srcA_lo,
248 ULong srcB_hi, ULong srcB_lo,
249 UInt inst_mask );
250 extern void vsx_matrix_8bit_ger_dirty_helper( VexGuestPPC64State* gst,
251 UInt offset,
252 ULong srcA_hi, ULong srcA_lo,
253 ULong srcB_hi, ULong srcB_lo,
254 UInt inst_mask );
255 extern void vsx_matrix_16bit_ger_dirty_helper( VexGuestPPC64State* gst,
256 UInt offset,
257 ULong srcA_hi, ULong srcA_lo,
258 ULong srcB_hi, ULong srcB_lo,
259 UInt inst_mask );
260 extern void vsx_matrix_16bit_float_ger_dirty_helper( VexGuestPPC64State* gst,
261 UInt offset,
262 ULong srcA_hi,
263 ULong srcA_lo,
264 ULong srcB_hi,
265 ULong srcB_lo,
266 UInt masks_inst );
267 extern void vsx_matrix_32bit_float_ger_dirty_helper( VexGuestPPC64State* gst,
268 UInt offset,
269 ULong srcA_hi,
270 ULong srcA_lo,
271 ULong srcB_hi,
272 ULong srcB_lo,
273 UInt masks_inst );
274 extern void vsx_matrix_64bit_float_ger_dirty_helper( VexGuestPPC64State* gst,
275 UInt offset,
276 ULong srcX_hi,
277 ULong srcX_lo,
278 ULong srcY_hi,
279 ULong srcY_lo,
280 UInt masks_inst );
281 extern ULong darn_dirty_helper ( UInt L );
282 extern UInt copy_paste_abort_dirty_helper(UInt addr, UInt op);
284 #endif /* ndef __VEX_GUEST_PPC_DEFS_H */
286 /* SCV flag defines. Must be consistently defined here and in
287 coregrind/pub_core_syscall.h,in the do_syscall_WRK() assembly code in
288 coregrind/m_syscall.c and coregrind/m_syswrap/syscall-ppc64le-linux.S
289 code. */
290 #define SC_FLAG 1
291 #define SCV_FLAG 2
293 /*---------------------------------------------------------------*/
294 /*--- end guest_ppc_defs.h ---*/
295 /*---------------------------------------------------------------*/