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