1 2 /*---------------------------------------------------------------*/ 3 /*--- begin guest_ppc_defs.h ---*/ 4 /*---------------------------------------------------------------*/ 5 6 /* 7 This file is part of Valgrind, a dynamic binary instrumentation 8 framework. 9 10 Copyright (C) 2004-2015 OpenWorks LLP 11 info (at) open-works.net 12 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. 17 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. 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 26 02110-1301, USA. 27 28 The GNU General Public License is contained in the file COPYING. 29 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. 34 */ 35 36 /* Only to be used within the guest-ppc directory. */ 37 38 39 #ifndef __VEX_GUEST_PPC_DEFS_H 40 #define __VEX_GUEST_PPC_DEFS_H 41 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 46 47 /*---------------------------------------------------------*/ 48 /*--- ppc to IR conversion ---*/ 49 /*---------------------------------------------------------*/ 50 51 /* Convert one ppc insn to IR. See the type DisOneInstrFn in 52 bb_to_IR.h. */ 53 extern 54 DisResult disInstr_PPC ( IRSB* irbb, 55 Bool (*resteerOkFn) ( void*, Addr ), 56 Bool resteerCisOk, 57 void* callback_opaque, 58 const UChar* guest_code, 59 Long delta, 60 Addr guest_IP, 61 VexArch guest_arch, 62 const VexArchInfo* archinfo, 63 const VexAbiInfo* abiinfo, 64 VexEndness host_endness, 65 Bool sigill_diag ); 66 67 /* Used by the optimiser to specialise calls to helpers. */ 68 extern 69 IRExpr* guest_ppc32_spechelper ( const HChar* function_name, 70 IRExpr** args, 71 IRStmt** precedingStmts, 72 Int n_precedingStmts ); 73 74 extern 75 IRExpr* guest_ppc64_spechelper ( const HChar* function_name, 76 IRExpr** args, 77 IRStmt** precedingStmts, 78 Int n_precedingStmts ); 79 80 /* 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. */ 83 extern 84 Bool guest_ppc32_state_requires_precise_mem_exns ( Int, Int, 85 VexRegisterUpdates ); 86 87 extern 88 Bool guest_ppc64_state_requires_precise_mem_exns ( Int, Int, 89 VexRegisterUpdates ); 90 91 extern 92 VexGuestLayout ppc32Guest_layout; 93 94 extern 95 VexGuestLayout ppc64Guest_layout; 96 97 98 /* FP Rounding mode - different encoding to IR */ 99 typedef 100 enum { 101 PPCrm_NEAREST = 0, 102 PPCrm_NegINF = 1, 103 PPCrm_PosINF = 2, 104 PPCrm_ZERO = 3 105 } PPCRoundingMode; 106 107 /* Floating point comparison values - different encoding to IR */ 108 typedef 109 enum { 110 PPCcr_LT = 0x8, 111 PPCcr_GT = 0x4, 112 PPCcr_EQ = 0x2, 113 PPCcr_UN = 0x1 114 } 115 PPCCmpF64Result; 116 117 /* 118 Enumeration for xer_ca/ov calculation helper functions 119 */ 120 enum { 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 140 PPCG_FLAG_OP_NUMBER 141 }; 142 143 144 /*---------------------------------------------------------*/ 145 /*--- ppc guest helpers ---*/ 146 /*---------------------------------------------------------*/ 147 148 /* --- CLEAN HELPERS --- */ 149 150 /* none, right now */ 151 152 /* --- DIRTY HELPERS --- */ 153 154 extern ULong ppcg_dirtyhelper_MFTB ( void ); 155 156 extern UInt ppc32g_dirtyhelper_MFSPR_268_269 ( UInt ); 157 158 extern UInt ppc32g_dirtyhelper_MFSPR_287 ( void ); 159 160 extern void ppc32g_dirtyhelper_LVS ( VexGuestPPC32State* gst, 161 UInt vD_idx, UInt sh, 162 UInt shift_right ); 163 164 extern void ppc64g_dirtyhelper_LVS ( VexGuestPPC64State* gst, 165 UInt vD_idx, UInt sh, 166 UInt shift_right, 167 UInt endness ); 168 169 #endif /* ndef __VEX_GUEST_PPC_DEFS_H */ 170 171 /*---------------------------------------------------------------*/ 172 /*--- end guest_ppc_defs.h ---*/ 173 /*---------------------------------------------------------------*/ 174