blob: 25d9fe3aa05b2aaa1b051953a48e96bc6c524bf7 [file] [log] [blame]
cerion896a1372005-01-25 12:24:25 +00001
2/*---------------------------------------------------------------*/
sewardj752f9062010-05-03 21:38:49 +00003/*--- begin guest_ppc_defs.h ---*/
cerion896a1372005-01-25 12:24:25 +00004/*---------------------------------------------------------------*/
5
6/*
sewardj752f9062010-05-03 21:38:49 +00007 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
cerion896a1372005-01-25 12:24:25 +00009
sewardj89ae8472013-10-18 14:12:58 +000010 Copyright (C) 2004-2013 OpenWorks LLP
sewardj752f9062010-05-03 21:38:49 +000011 info@open-works.net
cerion896a1372005-01-25 12:24:25 +000012
sewardj752f9062010-05-03 21:38:49 +000013 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.
cerion896a1372005-01-25 12:24:25 +000017
sewardj752f9062010-05-03 21:38:49 +000018 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.
22
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
sewardj7bd6ffe2005-08-03 16:07:36 +000026 02110-1301, USA.
27
sewardj752f9062010-05-03 21:38:49 +000028 The GNU General Public License is contained in the file COPYING.
cerion896a1372005-01-25 12:24:25 +000029
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.
cerion896a1372005-01-25 12:24:25 +000034*/
35
ceriond0eae2d2005-12-23 11:43:01 +000036/* Only to be used within the guest-ppc directory. */
cerion896a1372005-01-25 12:24:25 +000037
38
sewardjcef7d3e2009-07-02 12:21:59 +000039#ifndef __VEX_GUEST_PPC_DEFS_H
40#define __VEX_GUEST_PPC_DEFS_H
cerion896a1372005-01-25 12:24:25 +000041
florian58a637b2012-09-30 20:30:17 +000042#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
sewardj9e6491a2005-07-02 19:24:10 +000046
47/*---------------------------------------------------------*/
cerion5b2325f2005-12-23 00:55:09 +000048/*--- ppc to IR conversion ---*/
sewardj9e6491a2005-07-02 19:24:10 +000049/*---------------------------------------------------------*/
50
cerion5b2325f2005-12-23 00:55:09 +000051/* Convert one ppc insn to IR. See the type DisOneInstrFn in
sewardj9e6491a2005-07-02 19:24:10 +000052 bb_to_IR.h. */
53extern
sewardjdd40fdf2006-12-24 02:20:24 +000054DisResult disInstr_PPC ( IRSB* irbb,
sewardjc716aea2006-01-17 01:48:46 +000055 Bool (*resteerOkFn) ( void*, Addr64 ),
sewardj984d9b12010-01-15 10:53:21 +000056 Bool resteerCisOk,
sewardjc716aea2006-01-17 01:48:46 +000057 void* callback_opaque,
florian8462d112014-09-24 15:18:09 +000058 const UChar* guest_code,
cerion5b2325f2005-12-23 00:55:09 +000059 Long delta,
60 Addr64 guest_IP,
sewardja5f55da2006-04-30 23:37:32 +000061 VexArch guest_arch,
cerion5b2325f2005-12-23 00:55:09 +000062 VexArchInfo* archinfo,
sewardjdd40fdf2006-12-24 02:20:24 +000063 VexAbiInfo* abiinfo,
sewardj9b769162014-07-24 12:42:03 +000064 VexEndness host_endness,
sewardj442e51a2012-12-06 18:08:04 +000065 Bool sigill_diag );
sewardj9e6491a2005-07-02 19:24:10 +000066
67/* Used by the optimiser to specialise calls to helpers. */
68extern
florian1ff47562012-10-21 02:09:51 +000069IRExpr* guest_ppc32_spechelper ( const HChar* function_name,
sewardjbe917912010-08-22 12:38:53 +000070 IRExpr** args,
71 IRStmt** precedingStmts,
72 Int n_precedingStmts );
sewardj9e6491a2005-07-02 19:24:10 +000073
cerionf0de28c2005-12-13 20:21:11 +000074extern
florian1ff47562012-10-21 02:09:51 +000075IRExpr* guest_ppc64_spechelper ( const HChar* function_name,
sewardjbe917912010-08-22 12:38:53 +000076 IRExpr** args,
77 IRStmt** precedingStmts,
78 Int n_precedingStmts );
cerionf0de28c2005-12-13 20:21:11 +000079
sewardj9e6491a2005-07-02 19:24:10 +000080/* Describes to the optimser which part of the guest state require
81 precise memory exceptions. This is logically part of the guest
82 state description. */
83extern
84Bool guest_ppc32_state_requires_precise_mem_exns ( Int, Int );
85
cerionf0de28c2005-12-13 20:21:11 +000086extern
87Bool guest_ppc64_state_requires_precise_mem_exns ( Int, Int );
88
sewardj9e6491a2005-07-02 19:24:10 +000089extern
90VexGuestLayout ppc32Guest_layout;
91
cerionf0de28c2005-12-13 20:21:11 +000092extern
93VexGuestLayout ppc64Guest_layout;
94
sewardj9e6491a2005-07-02 19:24:10 +000095
cerion094d1392005-06-20 13:45:57 +000096/* FP Rounding mode - different encoding to IR */
97typedef
98 enum {
cerion5b2325f2005-12-23 00:55:09 +000099 PPCrm_NEAREST = 0,
100 PPCrm_NegINF = 1,
101 PPCrm_PosINF = 2,
102 PPCrm_ZERO = 3
103 } PPCRoundingMode;
cerion094d1392005-06-20 13:45:57 +0000104
105/* Floating point comparison values - different encoding to IR */
106typedef
107 enum {
cerion5b2325f2005-12-23 00:55:09 +0000108 PPCcr_LT = 0x8,
109 PPCcr_GT = 0x4,
110 PPCcr_EQ = 0x2,
111 PPCcr_UN = 0x1
cerion094d1392005-06-20 13:45:57 +0000112 }
cerion5b2325f2005-12-23 00:55:09 +0000113 PPCCmpF64Result;
cerion896a1372005-01-25 12:24:25 +0000114
cerionae694622005-01-28 17:52:47 +0000115/*
cerione9d361a2005-03-04 17:35:29 +0000116 Enumeration for xer_ca/ov calculation helper functions
117*/
cerionae694622005-01-28 17:52:47 +0000118enum {
cerion5b2325f2005-12-23 00:55:09 +0000119 /* 0 */ PPCG_FLAG_OP_ADD=0, // addc[o], addic
120 /* 1 */ PPCG_FLAG_OP_ADDE, // adde[o], addme[o], addze[o]
121 /* 2 */ PPCG_FLAG_OP_DIVW, // divwo
122 /* 3 */ PPCG_FLAG_OP_DIVWU, // divwuo
123 /* 4 */ PPCG_FLAG_OP_MULLW, // mullwo
124 /* 5 */ PPCG_FLAG_OP_NEG, // nego
125 /* 6 */ PPCG_FLAG_OP_SUBF, // subfo
126 /* 7 */ PPCG_FLAG_OP_SUBFC, // subfc[o]
127 /* 8 */ PPCG_FLAG_OP_SUBFE, // subfe[o], subfme[o], subfze[o]
128 /* 9 */ PPCG_FLAG_OP_SUBFI, // subfic
129 /* 10 */ PPCG_FLAG_OP_SRAW, // sraw
130 /* 11 */ PPCG_FLAG_OP_SRAWI, // srawi
131 /* 12 */ PPCG_FLAG_OP_SRAD, // srad
132 /* 13 */ PPCG_FLAG_OP_SRADI, // sradi
sewardj4aa412a2011-07-24 14:13:21 +0000133 /* 14 */ PPCG_FLAG_OP_DIVDE, // divdeo
134 /* 15 */ PPCG_FLAG_OP_DIVWEU, // divweuo
sewardje71e56a2011-09-05 12:11:06 +0000135 /* 16 */ PPCG_FLAG_OP_DIVWE, // divweo
136 /* 17 */ PPCG_FLAG_OP_DIVDEU, // divdeuo
carll38b79ac2013-09-06 22:27:34 +0000137 /* 18 */ PPCG_FLAG_OP_MULLD, // mulldo
cerion5b2325f2005-12-23 00:55:09 +0000138 PPCG_FLAG_OP_NUMBER
cerionae694622005-01-28 17:52:47 +0000139};
140
cerion896a1372005-01-25 12:24:25 +0000141
sewardj73a91972005-09-06 10:25:46 +0000142/*---------------------------------------------------------*/
cerion5b2325f2005-12-23 00:55:09 +0000143/*--- ppc guest helpers ---*/
sewardj73a91972005-09-06 10:25:46 +0000144/*---------------------------------------------------------*/
145
146/* --- CLEAN HELPERS --- */
147
148/* none, right now */
149
150/* --- DIRTY HELPERS --- */
151
cerion5b2325f2005-12-23 00:55:09 +0000152extern ULong ppcg_dirtyhelper_MFTB ( void );
sewardj73a91972005-09-06 10:25:46 +0000153
sewardjabb321c2006-12-27 18:39:46 +0000154extern UInt ppc32g_dirtyhelper_MFSPR_268_269 ( UInt );
155
sewardj37b2ee82009-08-02 14:35:45 +0000156extern UInt ppc32g_dirtyhelper_MFSPR_287 ( void );
157
cerion6f6c6a02005-09-13 18:41:09 +0000158extern void ppc32g_dirtyhelper_LVS ( VexGuestPPC32State* gst,
159 UInt vD_idx, UInt sh,
sewardjd1470942005-10-22 02:01:16 +0000160 UInt shift_right );
sewardj73a91972005-09-06 10:25:46 +0000161
cerion5b2325f2005-12-23 00:55:09 +0000162extern void ppc64g_dirtyhelper_LVS ( VexGuestPPC64State* gst,
163 UInt vD_idx, UInt sh,
carll1f5fe1f2014-08-07 23:25:23 +0000164 UInt shift_right,
165 UInt endness );
cerion5b2325f2005-12-23 00:55:09 +0000166
sewardjcef7d3e2009-07-02 12:21:59 +0000167#endif /* ndef __VEX_GUEST_PPC_DEFS_H */
cerion896a1372005-01-25 12:24:25 +0000168
169/*---------------------------------------------------------------*/
sewardjcef7d3e2009-07-02 12:21:59 +0000170/*--- end guest_ppc_defs.h ---*/
cerion896a1372005-01-25 12:24:25 +0000171/*---------------------------------------------------------------*/