cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 1 | |
| 2 | /*---------------------------------------------------------------*/ |
sewardj | 752f906 | 2010-05-03 21:38:49 +0000 | [diff] [blame] | 3 | /*--- begin guest_ppc_defs.h ---*/ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 4 | /*---------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
sewardj | 752f906 | 2010-05-03 21:38:49 +0000 | [diff] [blame] | 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 9 | |
Elliott Hughes | ed39800 | 2017-06-21 14:41:24 -0700 | [diff] [blame^] | 10 | Copyright (C) 2004-2017 OpenWorks LLP |
sewardj | 752f906 | 2010-05-03 21:38:49 +0000 | [diff] [blame] | 11 | info@open-works.net |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 12 | |
sewardj | 752f906 | 2010-05-03 21:38:49 +0000 | [diff] [blame] | 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. |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 17 | |
sewardj | 752f906 | 2010-05-03 21:38:49 +0000 | [diff] [blame] | 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 |
sewardj | 7bd6ffe | 2005-08-03 16:07:36 +0000 | [diff] [blame] | 26 | 02110-1301, USA. |
| 27 | |
sewardj | 752f906 | 2010-05-03 21:38:49 +0000 | [diff] [blame] | 28 | The GNU General Public License is contained in the file COPYING. |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 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. |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 34 | */ |
| 35 | |
cerion | d0eae2d | 2005-12-23 11:43:01 +0000 | [diff] [blame] | 36 | /* Only to be used within the guest-ppc directory. */ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 37 | |
| 38 | |
sewardj | cef7d3e | 2009-07-02 12:21:59 +0000 | [diff] [blame] | 39 | #ifndef __VEX_GUEST_PPC_DEFS_H |
| 40 | #define __VEX_GUEST_PPC_DEFS_H |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 41 | |
florian | 58a637b | 2012-09-30 20:30:17 +0000 | [diff] [blame] | 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 |
sewardj | 9e6491a | 2005-07-02 19:24:10 +0000 | [diff] [blame] | 46 | |
| 47 | /*---------------------------------------------------------*/ |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 48 | /*--- ppc to IR conversion ---*/ |
sewardj | 9e6491a | 2005-07-02 19:24:10 +0000 | [diff] [blame] | 49 | /*---------------------------------------------------------*/ |
| 50 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 51 | /* Convert one ppc insn to IR. See the type DisOneInstrFn in |
Elliott Hughes | ed39800 | 2017-06-21 14:41:24 -0700 | [diff] [blame^] | 52 | guest_generic_bb_to_IR.h. */ |
sewardj | 9e6491a | 2005-07-02 19:24:10 +0000 | [diff] [blame] | 53 | extern |
sewardj | dd40fdf | 2006-12-24 02:20:24 +0000 | [diff] [blame] | 54 | DisResult disInstr_PPC ( IRSB* irbb, |
florian | beac530 | 2014-12-31 12:09:38 +0000 | [diff] [blame] | 55 | Bool (*resteerOkFn) ( void*, Addr ), |
sewardj | 984d9b1 | 2010-01-15 10:53:21 +0000 | [diff] [blame] | 56 | Bool resteerCisOk, |
sewardj | c716aea | 2006-01-17 01:48:46 +0000 | [diff] [blame] | 57 | void* callback_opaque, |
florian | 8462d11 | 2014-09-24 15:18:09 +0000 | [diff] [blame] | 58 | const UChar* guest_code, |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 59 | Long delta, |
florian | d4cc0de | 2015-01-02 11:44:12 +0000 | [diff] [blame] | 60 | Addr guest_IP, |
sewardj | a5f55da | 2006-04-30 23:37:32 +0000 | [diff] [blame] | 61 | VexArch guest_arch, |
florian | cacba8e | 2014-12-15 18:58:07 +0000 | [diff] [blame] | 62 | const VexArchInfo* archinfo, |
| 63 | const VexAbiInfo* abiinfo, |
sewardj | 9b76916 | 2014-07-24 12:42:03 +0000 | [diff] [blame] | 64 | VexEndness host_endness, |
sewardj | 442e51a | 2012-12-06 18:08:04 +0000 | [diff] [blame] | 65 | Bool sigill_diag ); |
sewardj | 9e6491a | 2005-07-02 19:24:10 +0000 | [diff] [blame] | 66 | |
| 67 | /* Used by the optimiser to specialise calls to helpers. */ |
| 68 | extern |
florian | 1ff4756 | 2012-10-21 02:09:51 +0000 | [diff] [blame] | 69 | IRExpr* guest_ppc32_spechelper ( const HChar* function_name, |
sewardj | be91791 | 2010-08-22 12:38:53 +0000 | [diff] [blame] | 70 | IRExpr** args, |
| 71 | IRStmt** precedingStmts, |
| 72 | Int n_precedingStmts ); |
sewardj | 9e6491a | 2005-07-02 19:24:10 +0000 | [diff] [blame] | 73 | |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 74 | extern |
florian | 1ff4756 | 2012-10-21 02:09:51 +0000 | [diff] [blame] | 75 | IRExpr* guest_ppc64_spechelper ( const HChar* function_name, |
sewardj | be91791 | 2010-08-22 12:38:53 +0000 | [diff] [blame] | 76 | IRExpr** args, |
| 77 | IRStmt** precedingStmts, |
| 78 | Int n_precedingStmts ); |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 79 | |
sewardj | 9e6491a | 2005-07-02 19:24:10 +0000 | [diff] [blame] | 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 |
sewardj | ca2c3c7 | 2015-02-05 12:53:20 +0000 | [diff] [blame] | 84 | Bool guest_ppc32_state_requires_precise_mem_exns ( Int, Int, |
| 85 | VexRegisterUpdates ); |
sewardj | 9e6491a | 2005-07-02 19:24:10 +0000 | [diff] [blame] | 86 | |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 87 | extern |
sewardj | ca2c3c7 | 2015-02-05 12:53:20 +0000 | [diff] [blame] | 88 | Bool guest_ppc64_state_requires_precise_mem_exns ( Int, Int, |
| 89 | VexRegisterUpdates ); |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 90 | |
sewardj | 9e6491a | 2005-07-02 19:24:10 +0000 | [diff] [blame] | 91 | extern |
| 92 | VexGuestLayout ppc32Guest_layout; |
| 93 | |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 94 | extern |
| 95 | VexGuestLayout ppc64Guest_layout; |
| 96 | |
sewardj | 9e6491a | 2005-07-02 19:24:10 +0000 | [diff] [blame] | 97 | |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 98 | /* FP Rounding mode - different encoding to IR */ |
| 99 | typedef |
| 100 | enum { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 101 | PPCrm_NEAREST = 0, |
| 102 | PPCrm_NegINF = 1, |
| 103 | PPCrm_PosINF = 2, |
| 104 | PPCrm_ZERO = 3 |
| 105 | } PPCRoundingMode; |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 106 | |
| 107 | /* Floating point comparison values - different encoding to IR */ |
| 108 | typedef |
| 109 | enum { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 110 | PPCcr_LT = 0x8, |
| 111 | PPCcr_GT = 0x4, |
| 112 | PPCcr_EQ = 0x2, |
| 113 | PPCcr_UN = 0x1 |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 114 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 115 | PPCCmpF64Result; |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 116 | |
cerion | ae69462 | 2005-01-28 17:52:47 +0000 | [diff] [blame] | 117 | /* |
cerion | e9d361a | 2005-03-04 17:35:29 +0000 | [diff] [blame] | 118 | Enumeration for xer_ca/ov calculation helper functions |
| 119 | */ |
cerion | ae69462 | 2005-01-28 17:52:47 +0000 | [diff] [blame] | 120 | enum { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 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 |
sewardj | 4aa412a | 2011-07-24 14:13:21 +0000 | [diff] [blame] | 135 | /* 14 */ PPCG_FLAG_OP_DIVDE, // divdeo |
| 136 | /* 15 */ PPCG_FLAG_OP_DIVWEU, // divweuo |
sewardj | e71e56a | 2011-09-05 12:11:06 +0000 | [diff] [blame] | 137 | /* 16 */ PPCG_FLAG_OP_DIVWE, // divweo |
| 138 | /* 17 */ PPCG_FLAG_OP_DIVDEU, // divdeuo |
carll | 38b79ac | 2013-09-06 22:27:34 +0000 | [diff] [blame] | 139 | /* 18 */ PPCG_FLAG_OP_MULLD, // mulldo |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 140 | PPCG_FLAG_OP_NUMBER |
cerion | ae69462 | 2005-01-28 17:52:47 +0000 | [diff] [blame] | 141 | }; |
| 142 | |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 143 | |
sewardj | 73a9197 | 2005-09-06 10:25:46 +0000 | [diff] [blame] | 144 | /*---------------------------------------------------------*/ |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 145 | /*--- ppc guest helpers ---*/ |
sewardj | 73a9197 | 2005-09-06 10:25:46 +0000 | [diff] [blame] | 146 | /*---------------------------------------------------------*/ |
| 147 | |
| 148 | /* --- CLEAN HELPERS --- */ |
| 149 | |
Elliott Hughes | a0664b9 | 2017-04-18 17:46:52 -0700 | [diff] [blame] | 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, |
| 154 | ULong upper_byte, |
| 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 | |
sewardj | 73a9197 | 2005-09-06 10:25:46 +0000 | [diff] [blame] | 160 | |
| 161 | /* --- DIRTY HELPERS --- */ |
| 162 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 163 | extern ULong ppcg_dirtyhelper_MFTB ( void ); |
sewardj | 73a9197 | 2005-09-06 10:25:46 +0000 | [diff] [blame] | 164 | |
sewardj | abb321c | 2006-12-27 18:39:46 +0000 | [diff] [blame] | 165 | extern UInt ppc32g_dirtyhelper_MFSPR_268_269 ( UInt ); |
| 166 | |
sewardj | 37b2ee8 | 2009-08-02 14:35:45 +0000 | [diff] [blame] | 167 | extern UInt ppc32g_dirtyhelper_MFSPR_287 ( void ); |
| 168 | |
cerion | 6f6c6a0 | 2005-09-13 18:41:09 +0000 | [diff] [blame] | 169 | extern void ppc32g_dirtyhelper_LVS ( VexGuestPPC32State* gst, |
| 170 | UInt vD_idx, UInt sh, |
sewardj | d147094 | 2005-10-22 02:01:16 +0000 | [diff] [blame] | 171 | UInt shift_right ); |
sewardj | 73a9197 | 2005-09-06 10:25:46 +0000 | [diff] [blame] | 172 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 173 | extern void ppc64g_dirtyhelper_LVS ( VexGuestPPC64State* gst, |
| 174 | UInt vD_idx, UInt sh, |
carll | 1f5fe1f | 2014-08-07 23:25:23 +0000 | [diff] [blame] | 175 | UInt shift_right, |
| 176 | UInt endness ); |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 177 | |
sewardj | cef7d3e | 2009-07-02 12:21:59 +0000 | [diff] [blame] | 178 | #endif /* ndef __VEX_GUEST_PPC_DEFS_H */ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 179 | |
| 180 | /*---------------------------------------------------------------*/ |
sewardj | cef7d3e | 2009-07-02 12:21:59 +0000 | [diff] [blame] | 181 | /*--- end guest_ppc_defs.h ---*/ |
cerion | 896a137 | 2005-01-25 12:24:25 +0000 | [diff] [blame] | 182 | /*---------------------------------------------------------------*/ |