sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 1 | |
| 2 | /*---------------------------------------------------------------*/ |
| 3 | /*--- begin guest_mips_defs.h ---*/ |
| 4 | /*---------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
| 9 | |
sewardj | 785952d | 2015-08-21 11:29:16 +0000 | [diff] [blame] | 10 | Copyright (C) 2010-2015 RT-RK |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 11 | mips-valgrind@rt-rk.com |
| 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., 59 Temple Place, Suite 330, Boston, MA |
| 26 | 02111-1307, USA. |
| 27 | |
| 28 | The GNU General Public License is contained in the file COPYING. |
| 29 | */ |
| 30 | |
| 31 | /* Only to be used within the guest-mips directory. */ |
| 32 | |
| 33 | #ifndef __VEX_GUEST_MIPS_DEFS_H |
| 34 | #define __VEX_GUEST_MIPS_DEFS_H |
| 35 | |
florian | 58a637b | 2012-09-30 20:30:17 +0000 | [diff] [blame] | 36 | #include "libvex_basictypes.h" |
petarj | b92a954 | 2013-02-27 22:57:17 +0000 | [diff] [blame] | 37 | #include "guest_generic_bb_to_IR.h" /* DisResult */ |
florian | 58a637b | 2012-09-30 20:30:17 +0000 | [diff] [blame] | 38 | |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 39 | /*---------------------------------------------------------*/ |
petarj | b92a954 | 2013-02-27 22:57:17 +0000 | [diff] [blame] | 40 | /*--- mips to IR conversion ---*/ |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 41 | /*---------------------------------------------------------*/ |
| 42 | |
petarj | b92a954 | 2013-02-27 22:57:17 +0000 | [diff] [blame] | 43 | /* Convert one MIPS insn to IR. See the type DisOneInstrFn in bb_to_IR.h. */ |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 44 | extern DisResult disInstr_MIPS ( IRSB* irbb, |
florian | beac530 | 2014-12-31 12:09:38 +0000 | [diff] [blame] | 45 | Bool (*resteerOkFn) (void *, Addr), |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 46 | Bool resteerCisOk, |
| 47 | void* callback_opaque, |
florian | 8462d11 | 2014-09-24 15:18:09 +0000 | [diff] [blame] | 48 | const UChar* guest_code, |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 49 | Long delta, |
florian | d4cc0de | 2015-01-02 11:44:12 +0000 | [diff] [blame] | 50 | Addr guest_IP, |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 51 | VexArch guest_arch, |
florian | cacba8e | 2014-12-15 18:58:07 +0000 | [diff] [blame] | 52 | const VexArchInfo* archinfo, |
| 53 | const VexAbiInfo* abiinfo, |
sewardj | 9b76916 | 2014-07-24 12:42:03 +0000 | [diff] [blame] | 54 | VexEndness host_endness, |
sewardj | 442e51a | 2012-12-06 18:08:04 +0000 | [diff] [blame] | 55 | Bool sigill_diag ); |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 56 | |
| 57 | /* Used by the optimiser to specialise calls to helpers. */ |
petarj | b92a954 | 2013-02-27 22:57:17 +0000 | [diff] [blame] | 58 | extern IRExpr *guest_mips32_spechelper ( const HChar * function_name, |
| 59 | IRExpr ** args, |
| 60 | IRStmt ** precedingStmts, |
| 61 | Int n_precedingStmts ); |
| 62 | |
| 63 | extern IRExpr *guest_mips64_spechelper ( const HChar * function_name, |
| 64 | IRExpr ** args, |
| 65 | IRStmt ** precedingStmts, |
| 66 | Int n_precedingStmts); |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 67 | |
| 68 | /* Describes to the optimser which part of the guest state require |
| 69 | precise memory exceptions. This is logically part of the guest |
| 70 | state description. */ |
sewardj | ca2c3c7 | 2015-02-05 12:53:20 +0000 | [diff] [blame] | 71 | extern |
| 72 | Bool guest_mips32_state_requires_precise_mem_exns ( Int, Int, |
| 73 | VexRegisterUpdates ); |
petarj | b92a954 | 2013-02-27 22:57:17 +0000 | [diff] [blame] | 74 | |
sewardj | ca2c3c7 | 2015-02-05 12:53:20 +0000 | [diff] [blame] | 75 | extern |
| 76 | Bool guest_mips64_state_requires_precise_mem_exns ( Int, Int, |
| 77 | VexRegisterUpdates ); |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 78 | |
| 79 | extern VexGuestLayout mips32Guest_layout; |
petarj | b92a954 | 2013-02-27 22:57:17 +0000 | [diff] [blame] | 80 | extern VexGuestLayout mips64Guest_layout; |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 81 | |
| 82 | /*---------------------------------------------------------*/ |
petarj | b92a954 | 2013-02-27 22:57:17 +0000 | [diff] [blame] | 83 | /*--- mips guest helpers ---*/ |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 84 | /*---------------------------------------------------------*/ |
dejanj | 8007ea6 | 2013-09-18 10:06:13 +0000 | [diff] [blame] | 85 | typedef enum { |
| 86 | CEILWS=0, CEILWD, CEILLS, CEILLD, |
| 87 | FLOORWS, FLOORWD, FLOORLS, FLOORLD, |
| 88 | ROUNDWS, ROUNDWD, ROUNDLS, ROUNDLD, |
| 89 | TRUNCWS, TRUNCWD, TRUNCLS, TRUNCLD, |
| 90 | CVTDS, CVTDW, CVTSD, CVTSW, |
| 91 | CVTWS, CVTWD, CVTDL, CVTLS, |
dejanj | 4183322 | 2013-11-14 15:44:42 +0000 | [diff] [blame] | 92 | CVTLD, CVTSL, ADDS, ADDD, |
| 93 | SUBS, SUBD, DIVS |
dejanj | 8007ea6 | 2013-09-18 10:06:13 +0000 | [diff] [blame] | 94 | } flt_op; |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 95 | |
petarj | b92a954 | 2013-02-27 22:57:17 +0000 | [diff] [blame] | 96 | #if defined(__mips__) && ((defined(__mips_isa_rev) && __mips_isa_rev >= 2)) |
dejanj | a445f1b | 2013-10-22 08:52:46 +0000 | [diff] [blame] | 97 | extern UInt mips32_dirtyhelper_rdhwr ( UInt rt, UInt rd ); |
petarj | b92a954 | 2013-02-27 22:57:17 +0000 | [diff] [blame] | 98 | extern ULong mips64_dirtyhelper_rdhwr ( ULong rt, ULong rd ); |
| 99 | #endif |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 100 | |
dejanj | 0e006f2 | 2014-02-19 11:56:29 +0000 | [diff] [blame] | 101 | /* Calculate FCSR in fp32 mode. */ |
| 102 | extern UInt mips_dirtyhelper_calculate_FCSR_fp32 ( void* guest_state, UInt fs, |
| 103 | UInt ft, flt_op op ); |
| 104 | /* Calculate FCSR in fp64 mode. */ |
| 105 | extern UInt mips_dirtyhelper_calculate_FCSR_fp64 ( void* guest_state, UInt fs, |
| 106 | UInt ft, flt_op op ); |
dejanj | 8007ea6 | 2013-09-18 10:06:13 +0000 | [diff] [blame] | 107 | |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 108 | /*---------------------------------------------------------*/ |
petarj | b92a954 | 2013-02-27 22:57:17 +0000 | [diff] [blame] | 109 | /*--- Condition code stuff ---*/ |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 110 | /*---------------------------------------------------------*/ |
| 111 | |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 112 | typedef enum { |
petarj | b92a954 | 2013-02-27 22:57:17 +0000 | [diff] [blame] | 113 | MIPSCondEQ = 0, /* equal : Z=1 */ |
| 114 | MIPSCondNE = 1, /* not equal : Z=0 */ |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 115 | |
petarj | b92a954 | 2013-02-27 22:57:17 +0000 | [diff] [blame] | 116 | MIPSCondHS = 2, /* >=u (higher or same) : C=1 */ |
| 117 | MIPSCondLO = 3, /* <u (lower) : C=0 */ |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 118 | |
petarj | b92a954 | 2013-02-27 22:57:17 +0000 | [diff] [blame] | 119 | MIPSCondMI = 4, /* minus (negative) : N=1 */ |
| 120 | MIPSCondPL = 5, /* plus (zero or +ve) : N=0 */ |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 121 | |
petarj | b92a954 | 2013-02-27 22:57:17 +0000 | [diff] [blame] | 122 | MIPSCondVS = 6, /* overflow : V=1 */ |
| 123 | MIPSCondVC = 7, /* no overflow : V=0 */ |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 124 | |
petarj | b92a954 | 2013-02-27 22:57:17 +0000 | [diff] [blame] | 125 | MIPSCondHI = 8, /* >u (higher) : C=1 && Z=0 */ |
| 126 | MIPSCondLS = 9, /* <=u (lower or same) : C=0 || Z=1 */ |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 127 | |
| 128 | MIPSCondGE = 10, /* >=s (signed greater or equal) : N=V */ |
| 129 | MIPSCondLT = 11, /* <s (signed less than) : N!=V */ |
| 130 | |
| 131 | MIPSCondGT = 12, /* >s (signed greater) : Z=0 && N=V */ |
| 132 | MIPSCondLE = 13, /* <=s (signed less or equal) : Z=1 || N!=V */ |
| 133 | |
| 134 | MIPSCondAL = 14, /* always (unconditional) : 1 */ |
petarj | b92a954 | 2013-02-27 22:57:17 +0000 | [diff] [blame] | 135 | MIPSCondNV = 15 /* never (unconditional): : 0 */ |
sewardj | 362cf84 | 2012-06-07 08:59:53 +0000 | [diff] [blame] | 136 | } MIPSCondcode; |
| 137 | |
| 138 | #endif /* __VEX_GUEST_MIPS_DEFS_H */ |
| 139 | |
| 140 | /*---------------------------------------------------------------*/ |
| 141 | /*--- end guest_mips_defs.h ---*/ |
| 142 | /*---------------------------------------------------------------*/ |