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-2011 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 43 /*---------------------------------------------------------*/ 44 /*--- ppc to IR conversion ---*/ 45 /*---------------------------------------------------------*/ 46 47 /* Convert one ppc insn to IR. See the type DisOneInstrFn in 48 bb_to_IR.h. */ 49 extern 50 DisResult disInstr_PPC ( IRSB* irbb, 51 Bool put_IP, 52 Bool (*resteerOkFn) ( void*, Addr64 ), 53 Bool resteerCisOk, 54 void* callback_opaque, 55 UChar* guest_code, 56 Long delta, 57 Addr64 guest_IP, 58 VexArch guest_arch, 59 VexArchInfo* archinfo, 60 VexAbiInfo* abiinfo, 61 Bool host_bigendian ); 62 63 /* Used by the optimiser to specialise calls to helpers. */ 64 extern 65 IRExpr* guest_ppc32_spechelper ( HChar* function_name, 66 IRExpr** args, 67 IRStmt** precedingStmts, 68 Int n_precedingStmts ); 69 70 extern 71 IRExpr* guest_ppc64_spechelper ( HChar* function_name, 72 IRExpr** args, 73 IRStmt** precedingStmts, 74 Int n_precedingStmts ); 75 76 /* Describes to the optimser which part of the guest state require 77 precise memory exceptions. This is logically part of the guest 78 state description. */ 79 extern 80 Bool guest_ppc32_state_requires_precise_mem_exns ( Int, Int ); 81 82 extern 83 Bool guest_ppc64_state_requires_precise_mem_exns ( Int, Int ); 84 85 extern 86 VexGuestLayout ppc32Guest_layout; 87 88 extern 89 VexGuestLayout ppc64Guest_layout; 90 91 92 /* FP Rounding mode - different encoding to IR */ 93 typedef 94 enum { 95 PPCrm_NEAREST = 0, 96 PPCrm_NegINF = 1, 97 PPCrm_PosINF = 2, 98 PPCrm_ZERO = 3 99 } PPCRoundingMode; 100 101 /* Floating point comparison values - different encoding to IR */ 102 typedef 103 enum { 104 PPCcr_LT = 0x8, 105 PPCcr_GT = 0x4, 106 PPCcr_EQ = 0x2, 107 PPCcr_UN = 0x1 108 } 109 PPCCmpF64Result; 110 111 /* 112 Enumeration for xer_ca/ov calculation helper functions 113 */ 114 enum { 115 /* 0 */ PPCG_FLAG_OP_ADD=0, // addc[o], addic 116 /* 1 */ PPCG_FLAG_OP_ADDE, // adde[o], addme[o], addze[o] 117 /* 2 */ PPCG_FLAG_OP_DIVW, // divwo 118 /* 3 */ PPCG_FLAG_OP_DIVWU, // divwuo 119 /* 4 */ PPCG_FLAG_OP_MULLW, // mullwo 120 /* 5 */ PPCG_FLAG_OP_NEG, // nego 121 /* 6 */ PPCG_FLAG_OP_SUBF, // subfo 122 /* 7 */ PPCG_FLAG_OP_SUBFC, // subfc[o] 123 /* 8 */ PPCG_FLAG_OP_SUBFE, // subfe[o], subfme[o], subfze[o] 124 /* 9 */ PPCG_FLAG_OP_SUBFI, // subfic 125 /* 10 */ PPCG_FLAG_OP_SRAW, // sraw 126 /* 11 */ PPCG_FLAG_OP_SRAWI, // srawi 127 /* 12 */ PPCG_FLAG_OP_SRAD, // srad 128 /* 13 */ PPCG_FLAG_OP_SRADI, // sradi 129 /* 14 */ PPCG_FLAG_OP_DIVDE, // divdeo 130 /* 15 */ PPCG_FLAG_OP_DIVWEU, // divweuo 131 /* 16 */ PPCG_FLAG_OP_DIVWE, // divweo 132 /* 17 */ PPCG_FLAG_OP_DIVDEU, // divdeuo 133 PPCG_FLAG_OP_NUMBER 134 }; 135 136 137 /*---------------------------------------------------------*/ 138 /*--- ppc guest helpers ---*/ 139 /*---------------------------------------------------------*/ 140 141 /* --- CLEAN HELPERS --- */ 142 143 /* none, right now */ 144 145 /* --- DIRTY HELPERS --- */ 146 147 extern ULong ppcg_dirtyhelper_MFTB ( void ); 148 149 extern UInt ppc32g_dirtyhelper_MFSPR_268_269 ( UInt ); 150 151 extern UInt ppc32g_dirtyhelper_MFSPR_287 ( void ); 152 153 extern void ppc32g_dirtyhelper_LVS ( VexGuestPPC32State* gst, 154 UInt vD_idx, UInt sh, 155 UInt shift_right ); 156 157 extern void ppc64g_dirtyhelper_LVS ( VexGuestPPC64State* gst, 158 UInt vD_idx, UInt sh, 159 UInt shift_right ); 160 161 #endif /* ndef __VEX_GUEST_PPC_DEFS_H */ 162 163 /*---------------------------------------------------------------*/ 164 /*--- end guest_ppc_defs.h ---*/ 165 /*---------------------------------------------------------------*/ 166