2 /*---------------------------------------------------------------*/
3 /*--- begin guest_ppc_defs.h ---*/
4 /*---------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2004-2017 OpenWorks LLP
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, write to the Free Software
25 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28 The GNU General Public License is contained in the file COPYING.
30 Neither the names of the U.S. Department of Energy nor the
31 University of California nor the names of its contributors may be
32 used to endorse or promote products derived from this software
33 without prior written permission.
36 /* Only to be used within the guest-ppc directory. */
39 #ifndef __VEX_GUEST_PPC_DEFS_H
40 #define __VEX_GUEST_PPC_DEFS_H
42 #include "libvex_basictypes.h"
43 #include "libvex_guest_ppc32.h" // VexGuestPPC32State
44 #include "libvex_guest_ppc64.h" // VexGuestPPC64State
45 #include "guest_generic_bb_to_IR.h" // DisResult
47 /*---------------------------------------------------------*/
48 /*--- ppc to IR conversion ---*/
49 /*---------------------------------------------------------*/
51 /* Convert one ppc insn to IR. See the type DisOneInstrFn in
52 guest_generic_bb_to_IR.h. */
54 DisResult
disInstr_PPC ( IRSB
* irbb
,
55 Bool (*resteerOkFn
) ( void*, Addr
),
57 void* callback_opaque
,
58 const UChar
* guest_code
,
62 const VexArchInfo
* archinfo
,
63 const VexAbiInfo
* abiinfo
,
64 VexEndness host_endness
,
67 /* Used by the optimiser to specialise calls to helpers. */
69 IRExpr
* guest_ppc32_spechelper ( const HChar
* function_name
,
71 IRStmt
** precedingStmts
,
72 Int n_precedingStmts
);
75 IRExpr
* guest_ppc64_spechelper ( const HChar
* function_name
,
77 IRStmt
** precedingStmts
,
78 Int n_precedingStmts
);
80 /* Describes to the optimser which part of the guest state require
81 precise memory exceptions. This is logically part of the guest
84 Bool
guest_ppc32_state_requires_precise_mem_exns ( Int
, Int
,
88 Bool
guest_ppc64_state_requires_precise_mem_exns ( Int
, Int
,
92 VexGuestLayout ppc32Guest_layout
;
95 VexGuestLayout ppc64Guest_layout
;
98 /* FP Rounding mode - different encoding to IR */
107 /* Floating point comparison values - different encoding to IR */
118 Enumeration for xer_ca/ov calculation helper functions
121 /* 0 */ PPCG_FLAG_OP_ADD
=0, // addc[o], addic
122 /* 1 */ PPCG_FLAG_OP_ADDE
, // adde[o], addme[o], addze[o]
123 /* 2 */ PPCG_FLAG_OP_DIVW
, // divwo
124 /* 3 */ PPCG_FLAG_OP_DIVWU
, // divwuo
125 /* 4 */ PPCG_FLAG_OP_MULLW
, // mullwo
126 /* 5 */ PPCG_FLAG_OP_NEG
, // nego
127 /* 6 */ PPCG_FLAG_OP_SUBF
, // subfo
128 /* 7 */ PPCG_FLAG_OP_SUBFC
, // subfc[o]
129 /* 8 */ PPCG_FLAG_OP_SUBFE
, // subfe[o], subfme[o], subfze[o]
130 /* 9 */ PPCG_FLAG_OP_SUBFI
, // subfic
131 /* 10 */ PPCG_FLAG_OP_SRAW
, // sraw
132 /* 11 */ PPCG_FLAG_OP_SRAWI
, // srawi
133 /* 12 */ PPCG_FLAG_OP_SRAD
, // srad
134 /* 13 */ PPCG_FLAG_OP_SRADI
, // sradi
135 /* 14 */ PPCG_FLAG_OP_DIVDE
, // divdeo
136 /* 15 */ PPCG_FLAG_OP_DIVWEU
, // divweuo
137 /* 16 */ PPCG_FLAG_OP_DIVWE
, // divweo
138 /* 17 */ PPCG_FLAG_OP_DIVDEU
, // divdeuo
139 /* 18 */ PPCG_FLAG_OP_MULLD
, // mulldo
144 /*---------------------------------------------------------*/
145 /*--- ppc guest helpers ---*/
146 /*---------------------------------------------------------*/
148 /* --- CLEAN HELPERS --- */
150 extern ULong
is_BCDstring128_helper( ULong Signed
, ULong hi64
, ULong low64
);
151 extern ULong
increment_BCDstring32_helper( ULong Signed
,
152 ULong bcd_string
, ULong carry_in
);
153 extern ULong
convert_to_zoned_helper( ULong src_hi
, ULong src_low
,
155 ULong return_upper
);
156 extern ULong
convert_to_national_helper( ULong src
, ULong return_upper
);
157 extern ULong
convert_from_zoned_helper( ULong src_hi
, ULong src_low
);
158 extern ULong
convert_from_national_helper( ULong src_hi
, ULong src_low
);
159 extern ULong
generate_C_FPCC_helper( ULong size
, ULong src_hi
, ULong src
);
162 /* --- DIRTY HELPERS --- */
164 extern ULong
ppcg_dirtyhelper_MFTB ( void );
166 extern UInt
ppc32g_dirtyhelper_MFSPR_268_269 ( UInt
);
168 extern UInt
ppc32g_dirtyhelper_MFSPR_287 ( void );
170 extern void ppc32g_dirtyhelper_LVS ( VexGuestPPC32State
* gst
,
171 UInt vD_idx
, UInt sh
,
174 extern void ppc64g_dirtyhelper_LVS ( VexGuestPPC64State
* gst
,
175 UInt vD_idx
, UInt sh
,
179 #endif /* ndef __VEX_GUEST_PPC_DEFS_H */
181 /*---------------------------------------------------------------*/
182 /*--- end guest_ppc_defs.h ---*/
183 /*---------------------------------------------------------------*/