cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 1 | |
| 2 | /*---------------------------------------------------------------*/ |
| 3 | /*--- ---*/ |
cerion | d0eae2d | 2005-12-23 11:43:01 +0000 | [diff] [blame^] | 4 | /*--- This file (host-ppc/hdefs.h) is ---*/ |
sewardj | dbcfae7 | 2005-08-02 11:14:04 +0000 | [diff] [blame] | 5 | /*--- Copyright (C) OpenWorks LLP. All rights reserved. ---*/ |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 6 | /*--- ---*/ |
| 7 | /*---------------------------------------------------------------*/ |
| 8 | |
| 9 | /* |
| 10 | This file is part of LibVEX, a library for dynamic binary |
| 11 | instrumentation and translation. |
| 12 | |
sewardj | 7bd6ffe | 2005-08-03 16:07:36 +0000 | [diff] [blame] | 13 | Copyright (C) 2004-2005 OpenWorks LLP. All rights reserved. |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 14 | |
sewardj | 7bd6ffe | 2005-08-03 16:07:36 +0000 | [diff] [blame] | 15 | This library is made available under a dual licensing scheme. |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 16 | |
sewardj | 7bd6ffe | 2005-08-03 16:07:36 +0000 | [diff] [blame] | 17 | If you link LibVEX against other code all of which is itself |
| 18 | licensed under the GNU General Public License, version 2 dated June |
| 19 | 1991 ("GPL v2"), then you may use LibVEX under the terms of the GPL |
| 20 | v2, as appearing in the file LICENSE.GPL. If the file LICENSE.GPL |
| 21 | is missing, you can obtain a copy of the GPL v2 from the Free |
| 22 | Software Foundation Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 23 | 02110-1301, USA. |
| 24 | |
| 25 | For any other uses of LibVEX, you must first obtain a commercial |
| 26 | license from OpenWorks LLP. Please contact info@open-works.co.uk |
| 27 | for information about commercial licensing. |
| 28 | |
| 29 | This software is provided by OpenWorks LLP "as is" and any express |
| 30 | or implied warranties, including, but not limited to, the implied |
| 31 | warranties of merchantability and fitness for a particular purpose |
| 32 | are disclaimed. In no event shall OpenWorks LLP be liable for any |
| 33 | direct, indirect, incidental, special, exemplary, or consequential |
| 34 | damages (including, but not limited to, procurement of substitute |
| 35 | goods or services; loss of use, data, or profits; or business |
| 36 | interruption) however caused and on any theory of liability, |
| 37 | whether in contract, strict liability, or tort (including |
| 38 | negligence or otherwise) arising in any way out of the use of this |
| 39 | software, even if advised of the possibility of such damage. |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 40 | |
| 41 | Neither the names of the U.S. Department of Energy nor the |
| 42 | University of California nor the names of its contributors may be |
| 43 | used to endorse or promote products derived from this software |
| 44 | without prior written permission. |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 45 | */ |
| 46 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 47 | #ifndef __LIBVEX_HOST_PPC_HDEFS_H |
| 48 | #define __LIBVEX_HOST_PPC_HDEFS_H |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 49 | |
cerion | 2c49e03 | 2005-02-09 17:29:49 +0000 | [diff] [blame] | 50 | /* Num registers used for function calls */ |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 51 | #define PPC_N_REGPARMS 8 |
cerion | 2c49e03 | 2005-02-09 17:29:49 +0000 | [diff] [blame] | 52 | |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 53 | |
| 54 | /* --------- Registers. --------- */ |
| 55 | |
| 56 | /* The usual HReg abstraction. There are 32 real int regs, |
cerion | 225a034 | 2005-09-12 20:49:09 +0000 | [diff] [blame] | 57 | 32 real float regs, and 32 real vector regs. |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 58 | */ |
| 59 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 60 | extern void ppHRegPPC ( HReg ); |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 61 | |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 62 | extern HReg hregPPC_GPR0 ( Bool mode64 ); // scratch reg / zero reg |
| 63 | extern HReg hregPPC_GPR1 ( Bool mode64 ); // Stack Frame Pointer |
| 64 | extern HReg hregPPC_GPR2 ( Bool mode64 ); // not used: TOC pointer |
| 65 | extern HReg hregPPC_GPR3 ( Bool mode64 ); |
| 66 | extern HReg hregPPC_GPR4 ( Bool mode64 ); |
| 67 | extern HReg hregPPC_GPR5 ( Bool mode64 ); |
| 68 | extern HReg hregPPC_GPR6 ( Bool mode64 ); |
| 69 | extern HReg hregPPC_GPR7 ( Bool mode64 ); |
| 70 | extern HReg hregPPC_GPR8 ( Bool mode64 ); |
| 71 | extern HReg hregPPC_GPR9 ( Bool mode64 ); |
| 72 | extern HReg hregPPC_GPR10 ( Bool mode64 ); |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 73 | extern HReg hregPPC_GPR11 ( Bool mode64 ); |
| 74 | extern HReg hregPPC_GPR12 ( Bool mode64 ); |
| 75 | extern HReg hregPPC_GPR13 ( Bool mode64 ); |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 76 | extern HReg hregPPC_GPR14 ( Bool mode64 ); |
| 77 | extern HReg hregPPC_GPR15 ( Bool mode64 ); |
| 78 | extern HReg hregPPC_GPR16 ( Bool mode64 ); |
| 79 | extern HReg hregPPC_GPR17 ( Bool mode64 ); |
| 80 | extern HReg hregPPC_GPR18 ( Bool mode64 ); |
| 81 | extern HReg hregPPC_GPR19 ( Bool mode64 ); |
| 82 | extern HReg hregPPC_GPR20 ( Bool mode64 ); |
| 83 | extern HReg hregPPC_GPR21 ( Bool mode64 ); |
| 84 | extern HReg hregPPC_GPR22 ( Bool mode64 ); |
| 85 | extern HReg hregPPC_GPR23 ( Bool mode64 ); |
| 86 | extern HReg hregPPC_GPR24 ( Bool mode64 ); |
| 87 | extern HReg hregPPC_GPR25 ( Bool mode64 ); |
| 88 | extern HReg hregPPC_GPR26 ( Bool mode64 ); |
| 89 | extern HReg hregPPC_GPR27 ( Bool mode64 ); |
| 90 | extern HReg hregPPC_GPR28 ( Bool mode64 ); |
sewardj | b8a8dba | 2005-12-15 21:33:50 +0000 | [diff] [blame] | 91 | extern HReg hregPPC_GPR29 ( Bool mode64 ); // reserved for dispatcher |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 92 | extern HReg hregPPC_GPR30 ( Bool mode64 ); // used as VMX spill temp |
sewardj | b8a8dba | 2005-12-15 21:33:50 +0000 | [diff] [blame] | 93 | extern HReg hregPPC_GPR31 ( Bool mode64 ); // GuestStatePtr (callee-saved) |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 94 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 95 | extern HReg hregPPC_FPR0 ( void ); |
| 96 | extern HReg hregPPC_FPR1 ( void ); |
| 97 | extern HReg hregPPC_FPR2 ( void ); |
| 98 | extern HReg hregPPC_FPR3 ( void ); |
| 99 | extern HReg hregPPC_FPR4 ( void ); |
| 100 | extern HReg hregPPC_FPR5 ( void ); |
| 101 | extern HReg hregPPC_FPR6 ( void ); |
| 102 | extern HReg hregPPC_FPR7 ( void ); |
| 103 | extern HReg hregPPC_FPR8 ( void ); |
| 104 | extern HReg hregPPC_FPR9 ( void ); |
| 105 | extern HReg hregPPC_FPR10 ( void ); |
| 106 | extern HReg hregPPC_FPR11 ( void ); |
| 107 | extern HReg hregPPC_FPR12 ( void ); |
| 108 | extern HReg hregPPC_FPR13 ( void ); |
| 109 | extern HReg hregPPC_FPR14 ( void ); |
| 110 | extern HReg hregPPC_FPR15 ( void ); |
| 111 | extern HReg hregPPC_FPR16 ( void ); |
| 112 | extern HReg hregPPC_FPR17 ( void ); |
| 113 | extern HReg hregPPC_FPR18 ( void ); |
| 114 | extern HReg hregPPC_FPR19 ( void ); |
| 115 | extern HReg hregPPC_FPR20 ( void ); |
| 116 | extern HReg hregPPC_FPR21 ( void ); |
| 117 | extern HReg hregPPC_FPR22 ( void ); |
| 118 | extern HReg hregPPC_FPR23 ( void ); |
| 119 | extern HReg hregPPC_FPR24 ( void ); |
| 120 | extern HReg hregPPC_FPR25 ( void ); |
| 121 | extern HReg hregPPC_FPR26 ( void ); |
| 122 | extern HReg hregPPC_FPR27 ( void ); |
| 123 | extern HReg hregPPC_FPR28 ( void ); |
| 124 | extern HReg hregPPC_FPR29 ( void ); |
| 125 | extern HReg hregPPC_FPR30 ( void ); |
| 126 | extern HReg hregPPC_FPR31 ( void ); |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 127 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 128 | extern HReg hregPPC_VR0 ( void ); |
| 129 | extern HReg hregPPC_VR1 ( void ); |
| 130 | extern HReg hregPPC_VR2 ( void ); |
| 131 | extern HReg hregPPC_VR3 ( void ); |
| 132 | extern HReg hregPPC_VR4 ( void ); |
| 133 | extern HReg hregPPC_VR5 ( void ); |
| 134 | extern HReg hregPPC_VR6 ( void ); |
| 135 | extern HReg hregPPC_VR7 ( void ); |
| 136 | extern HReg hregPPC_VR8 ( void ); |
| 137 | extern HReg hregPPC_VR9 ( void ); |
| 138 | extern HReg hregPPC_VR10 ( void ); |
| 139 | extern HReg hregPPC_VR11 ( void ); |
| 140 | extern HReg hregPPC_VR12 ( void ); |
| 141 | extern HReg hregPPC_VR13 ( void ); |
| 142 | extern HReg hregPPC_VR14 ( void ); |
| 143 | extern HReg hregPPC_VR15 ( void ); |
| 144 | extern HReg hregPPC_VR16 ( void ); |
| 145 | extern HReg hregPPC_VR17 ( void ); |
| 146 | extern HReg hregPPC_VR18 ( void ); |
| 147 | extern HReg hregPPC_VR19 ( void ); |
| 148 | extern HReg hregPPC_VR20 ( void ); |
| 149 | extern HReg hregPPC_VR21 ( void ); |
| 150 | extern HReg hregPPC_VR22 ( void ); |
| 151 | extern HReg hregPPC_VR23 ( void ); |
| 152 | extern HReg hregPPC_VR24 ( void ); |
| 153 | extern HReg hregPPC_VR25 ( void ); |
| 154 | extern HReg hregPPC_VR26 ( void ); |
| 155 | extern HReg hregPPC_VR27 ( void ); |
| 156 | extern HReg hregPPC_VR28 ( void ); |
| 157 | extern HReg hregPPC_VR29 ( void ); |
| 158 | extern HReg hregPPC_VR30 ( void ); |
| 159 | extern HReg hregPPC_VR31 ( void ); |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 160 | |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 161 | #define StackFramePtr(_mode64) hregPPC_GPR1(_mode64) |
| 162 | #define GuestStatePtr(_mode64) hregPPC_GPR31(_mode64) |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 163 | |
cerion | 2c49e03 | 2005-02-09 17:29:49 +0000 | [diff] [blame] | 164 | |
| 165 | |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 166 | /* --------- Condition codes --------- */ |
cerion | 2c49e03 | 2005-02-09 17:29:49 +0000 | [diff] [blame] | 167 | |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 168 | /* This gives names from bitfields in CR; hence it names BI numbers */ |
| 169 | /* Using IBM/hardware indexing convention */ |
cerion | 2c49e03 | 2005-02-09 17:29:49 +0000 | [diff] [blame] | 170 | typedef |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 171 | enum { |
| 172 | // CR7, which we use for integer compares |
| 173 | Pcf_7LT = 28, /* neg | lt */ |
| 174 | Pcf_7GT = 29, /* pos | gt */ |
| 175 | Pcf_7EQ = 30, /* zero | equal */ |
| 176 | Pcf_7SO = 31 /* summary overflow */ |
cerion | ab9132d | 2005-02-15 15:46:59 +0000 | [diff] [blame] | 177 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 178 | PPCCondFlag; |
cerion | 2c49e03 | 2005-02-09 17:29:49 +0000 | [diff] [blame] | 179 | |
cerion | ab9132d | 2005-02-15 15:46:59 +0000 | [diff] [blame] | 180 | typedef |
cerion | 7cf8e4e | 2005-02-16 16:08:17 +0000 | [diff] [blame] | 181 | enum { /* Maps bc bitfield BO */ |
cerion | 33aa6da | 2005-02-16 10:25:26 +0000 | [diff] [blame] | 182 | Pct_FALSE = 0x4, |
| 183 | Pct_TRUE = 0xC, |
| 184 | Pct_ALWAYS = 0x14 |
cerion | ab9132d | 2005-02-15 15:46:59 +0000 | [diff] [blame] | 185 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 186 | PPCCondTest; |
cerion | ab9132d | 2005-02-15 15:46:59 +0000 | [diff] [blame] | 187 | |
| 188 | typedef |
| 189 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 190 | PPCCondFlag flag; |
| 191 | PPCCondTest test; |
cerion | 2c49e03 | 2005-02-09 17:29:49 +0000 | [diff] [blame] | 192 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 193 | PPCCondCode; |
cerion | 2c49e03 | 2005-02-09 17:29:49 +0000 | [diff] [blame] | 194 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 195 | extern HChar* showPPCCondCode ( PPCCondCode ); |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 196 | |
cerion | 7cf8e4e | 2005-02-16 16:08:17 +0000 | [diff] [blame] | 197 | /* constructor */ |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 198 | extern PPCCondCode mk_PPCCondCode ( PPCCondTest, PPCCondFlag ); |
cerion | 7cf8e4e | 2005-02-16 16:08:17 +0000 | [diff] [blame] | 199 | |
| 200 | /* false->true, true->false */ |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 201 | extern PPCCondTest invertCondTest ( PPCCondTest ); |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 202 | |
cerion | ab9132d | 2005-02-15 15:46:59 +0000 | [diff] [blame] | 203 | |
| 204 | |
cerion | 33aa6da | 2005-02-16 10:25:26 +0000 | [diff] [blame] | 205 | |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 206 | /* --------- Memory address expressions (amodes). --------- */ |
| 207 | |
| 208 | typedef |
| 209 | enum { |
sewardj | a5f957d | 2005-07-02 01:29:32 +0000 | [diff] [blame] | 210 | Pam_IR, /* Immediate (signed 16-bit) + Reg */ |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 211 | Pam_RR /* Reg1 + Reg2 */ |
| 212 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 213 | PPCAModeTag; |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 214 | |
| 215 | typedef |
| 216 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 217 | PPCAModeTag tag; |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 218 | union { |
| 219 | struct { |
| 220 | HReg base; |
sewardj | a5f957d | 2005-07-02 01:29:32 +0000 | [diff] [blame] | 221 | Int index; |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 222 | } IR; |
| 223 | struct { |
| 224 | HReg base; |
| 225 | HReg index; |
| 226 | } RR; |
| 227 | } Pam; |
| 228 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 229 | PPCAMode; |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 230 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 231 | extern PPCAMode* PPCAMode_IR ( Int, HReg ); |
| 232 | extern PPCAMode* PPCAMode_RR ( HReg, HReg ); |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 233 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 234 | extern PPCAMode* dopyPPCAMode ( PPCAMode* ); |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 235 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 236 | extern void ppPPCAMode ( PPCAMode* ); |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 237 | |
| 238 | |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 239 | /* --------- Operand, which can be a reg or a u16/s16. --------- */ |
| 240 | /* ("RH" == "Register or Halfword immediate") */ |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 241 | typedef |
| 242 | enum { |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 243 | Prh_Imm=1, |
| 244 | Prh_Reg=2 |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 245 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 246 | PPCRHTag; |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 247 | |
| 248 | typedef |
| 249 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 250 | PPCRHTag tag; |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 251 | union { |
| 252 | struct { |
| 253 | Bool syned; |
| 254 | UShort imm16; |
| 255 | } Imm; |
| 256 | struct { |
| 257 | HReg reg; |
| 258 | } Reg; |
| 259 | } |
| 260 | Prh; |
| 261 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 262 | PPCRH; |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 263 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 264 | extern PPCRH* PPCRH_Imm ( Bool, UShort ); |
| 265 | extern PPCRH* PPCRH_Reg ( HReg ); |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 266 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 267 | extern void ppPPCRH ( PPCRH* ); |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 268 | |
| 269 | |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 270 | /* --------- Operand, which can be a reg or a u32/64. --------- */ |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 271 | |
| 272 | typedef |
| 273 | enum { |
| 274 | Pri_Imm=3, |
| 275 | Pri_Reg=4 |
| 276 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 277 | PPCRITag; |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 278 | |
| 279 | typedef |
| 280 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 281 | PPCRITag tag; |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 282 | union { |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 283 | ULong Imm; |
| 284 | HReg Reg; |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 285 | } |
| 286 | Pri; |
| 287 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 288 | PPCRI; |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 289 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 290 | extern PPCRI* PPCRI_Imm ( ULong ); |
| 291 | extern PPCRI* PPCRI_Reg ( HReg ); |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 292 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 293 | extern void ppPPCRI ( PPCRI* ); |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 294 | |
| 295 | |
cerion | 27b3d7e | 2005-09-14 20:35:47 +0000 | [diff] [blame] | 296 | /* --------- Operand, which can be a vector reg or a s6. --------- */ |
| 297 | /* ("VI" == "Vector Register or Immediate") */ |
| 298 | typedef |
| 299 | enum { |
| 300 | Pvi_Imm=5, |
| 301 | Pvi_Reg=6 |
| 302 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 303 | PPCVI5sTag; |
cerion | 27b3d7e | 2005-09-14 20:35:47 +0000 | [diff] [blame] | 304 | |
| 305 | typedef |
| 306 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 307 | PPCVI5sTag tag; |
cerion | 27b3d7e | 2005-09-14 20:35:47 +0000 | [diff] [blame] | 308 | union { |
| 309 | Char Imm5s; |
| 310 | HReg Reg; |
| 311 | } |
| 312 | Pvi; |
| 313 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 314 | PPCVI5s; |
cerion | 27b3d7e | 2005-09-14 20:35:47 +0000 | [diff] [blame] | 315 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 316 | extern PPCVI5s* PPCVI5s_Imm ( Char ); |
| 317 | extern PPCVI5s* PPCVI5s_Reg ( HReg ); |
cerion | 27b3d7e | 2005-09-14 20:35:47 +0000 | [diff] [blame] | 318 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 319 | extern void ppPPCVI5s ( PPCVI5s* ); |
cerion | 27b3d7e | 2005-09-14 20:35:47 +0000 | [diff] [blame] | 320 | |
| 321 | |
cerion | cd30449 | 2005-02-08 19:40:24 +0000 | [diff] [blame] | 322 | /* --------- Instructions. --------- */ |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 323 | |
cerion | 2c49e03 | 2005-02-09 17:29:49 +0000 | [diff] [blame] | 324 | /* --------- */ |
| 325 | typedef |
| 326 | enum { |
| 327 | Pun_NEG, |
cerion | e13bb31 | 2005-02-10 19:51:03 +0000 | [diff] [blame] | 328 | Pun_NOT, |
cerion | 07b07a9 | 2005-12-22 14:32:35 +0000 | [diff] [blame] | 329 | Pun_CLZ32, |
| 330 | Pun_CLZ64 |
cerion | 2c49e03 | 2005-02-09 17:29:49 +0000 | [diff] [blame] | 331 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 332 | PPCUnaryOp; |
cerion | 2c49e03 | 2005-02-09 17:29:49 +0000 | [diff] [blame] | 333 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 334 | extern HChar* showPPCUnaryOp ( PPCUnaryOp ); |
cerion | cd30449 | 2005-02-08 19:40:24 +0000 | [diff] [blame] | 335 | |
| 336 | |
| 337 | /* --------- */ |
| 338 | typedef |
| 339 | enum { |
| 340 | Palu_INVALID, |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 341 | Palu_ADD, Palu_SUB, |
| 342 | Palu_AND, Palu_OR, Palu_XOR, |
cerion | cd30449 | 2005-02-08 19:40:24 +0000 | [diff] [blame] | 343 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 344 | PPCAluOp; |
cerion | cd30449 | 2005-02-08 19:40:24 +0000 | [diff] [blame] | 345 | |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 346 | extern |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 347 | HChar* showPPCAluOp ( PPCAluOp, |
| 348 | Bool /* is the 2nd operand an immediate? */); |
cerion | bb01b7c | 2005-12-16 13:40:18 +0000 | [diff] [blame] | 349 | |
| 350 | |
| 351 | /* --------- */ |
| 352 | typedef |
| 353 | enum { |
| 354 | Pshft_INVALID, |
| 355 | Pshft_SHL, Pshft_SHR, Pshft_SAR, |
| 356 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 357 | PPCShftOp; |
cerion | bb01b7c | 2005-12-16 13:40:18 +0000 | [diff] [blame] | 358 | |
| 359 | extern |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 360 | HChar* showPPCShftOp ( PPCShftOp, |
| 361 | Bool /* is the 2nd operand an immediate? */, |
| 362 | Bool /* is this a 32bit or 64bit op? */ ); |
cerion | ab9132d | 2005-02-15 15:46:59 +0000 | [diff] [blame] | 363 | |
| 364 | |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 365 | /* --------- */ |
| 366 | typedef |
| 367 | enum { |
| 368 | Pfp_INVALID, |
| 369 | /* Binary */ |
| 370 | Pfp_ADD, Pfp_SUB, Pfp_MUL, Pfp_DIV, |
| 371 | |
| 372 | /* Unary */ |
| 373 | Pfp_SQRT, Pfp_ABS, Pfp_NEG, Pfp_MOV |
| 374 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 375 | PPCFpOp; |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 376 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 377 | extern HChar* showPPCFpOp ( PPCFpOp ); |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 378 | |
| 379 | |
| 380 | /* --------- */ |
| 381 | typedef |
| 382 | enum { |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 383 | Pav_INVALID, |
| 384 | |
| 385 | /* Integer Unary */ |
| 386 | Pav_MOV, /* Mov */ |
| 387 | Pav_NOT, /* Bitwise */ |
| 388 | Pav_UNPCKH8S, Pav_UNPCKH16S, /* Unpack */ |
| 389 | Pav_UNPCKL8S, Pav_UNPCKL16S, |
| 390 | Pav_UNPCKHPIX, Pav_UNPCKLPIX, |
| 391 | |
| 392 | /* Integer Binary */ |
cerion | 8ea0d3e | 2005-11-14 00:44:47 +0000 | [diff] [blame] | 393 | Pav_AND, Pav_OR, Pav_XOR, /* Bitwise */ |
cerion | f34ccc4 | 2005-09-16 08:55:50 +0000 | [diff] [blame] | 394 | Pav_ADDU, Pav_QADDU, Pav_QADDS, |
cerion | f34ccc4 | 2005-09-16 08:55:50 +0000 | [diff] [blame] | 395 | Pav_SUBU, Pav_QSUBU, Pav_QSUBS, |
cerion | 6b6f59e | 2005-06-28 20:59:18 +0000 | [diff] [blame] | 396 | Pav_OMULU, Pav_OMULS, Pav_EMULU, Pav_EMULS, |
cerion | 6b6f59e | 2005-06-28 20:59:18 +0000 | [diff] [blame] | 397 | Pav_AVGU, Pav_AVGS, |
| 398 | Pav_MAXU, Pav_MAXS, |
| 399 | Pav_MINU, Pav_MINS, |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 400 | |
| 401 | /* Compare (always affects CR field 6) */ |
cerion | 6b6f59e | 2005-06-28 20:59:18 +0000 | [diff] [blame] | 402 | Pav_CMPEQU, Pav_CMPGTU, Pav_CMPGTS, |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 403 | |
| 404 | /* Shift */ |
cerion | 6b6f59e | 2005-06-28 20:59:18 +0000 | [diff] [blame] | 405 | Pav_SHL, Pav_SHR, Pav_SAR, Pav_ROTL, |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 406 | |
| 407 | /* Pack */ |
cerion | f34ccc4 | 2005-09-16 08:55:50 +0000 | [diff] [blame] | 408 | Pav_PACKUU, Pav_QPACKUU, Pav_QPACKSU, Pav_QPACKSS, |
cerion | 6b6f59e | 2005-06-28 20:59:18 +0000 | [diff] [blame] | 409 | Pav_PACKPXL, |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 410 | |
| 411 | /* Merge */ |
cerion | 6b6f59e | 2005-06-28 20:59:18 +0000 | [diff] [blame] | 412 | Pav_MRGHI, Pav_MRGLO, |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 413 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 414 | PPCAvOp; |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 415 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 416 | extern HChar* showPPCAvOp ( PPCAvOp ); |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 417 | |
| 418 | |
| 419 | /* --------- */ |
| 420 | typedef |
| 421 | enum { |
cerion | 8ea0d3e | 2005-11-14 00:44:47 +0000 | [diff] [blame] | 422 | Pavfp_INVALID, |
| 423 | |
| 424 | /* Floating point binary */ |
| 425 | Pavfp_ADDF, Pavfp_SUBF, Pavfp_MULF, |
| 426 | Pavfp_MAXF, Pavfp_MINF, |
| 427 | Pavfp_CMPEQF, Pavfp_CMPGTF, Pavfp_CMPGEF, |
| 428 | |
| 429 | /* Floating point unary */ |
| 430 | Pavfp_RCPF, Pavfp_RSQRTF, |
cerion | d963eb4 | 2005-11-16 18:02:58 +0000 | [diff] [blame] | 431 | Pavfp_CVTU2F, Pavfp_CVTS2F, Pavfp_QCVTF2U, Pavfp_QCVTF2S, |
| 432 | Pavfp_ROUNDM, Pavfp_ROUNDP, Pavfp_ROUNDN, Pavfp_ROUNDZ, |
cerion | 8ea0d3e | 2005-11-14 00:44:47 +0000 | [diff] [blame] | 433 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 434 | PPCAvFpOp; |
cerion | 8ea0d3e | 2005-11-14 00:44:47 +0000 | [diff] [blame] | 435 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 436 | extern HChar* showPPCAvFpOp ( PPCAvFpOp ); |
cerion | 8ea0d3e | 2005-11-14 00:44:47 +0000 | [diff] [blame] | 437 | |
| 438 | |
| 439 | /* --------- */ |
| 440 | typedef |
| 441 | enum { |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 442 | Pin_LI, /* load word (32/64-bit) immediate (fake insn) */ |
cerion | bb01b7c | 2005-12-16 13:40:18 +0000 | [diff] [blame] | 443 | Pin_Alu, /* word add/sub/and/or/xor */ |
| 444 | Pin_Shft, /* word shl/shr/sar */ |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 445 | Pin_AddSubC, /* add/sub with read/write carry */ |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 446 | Pin_Cmp, /* word compare */ |
| 447 | Pin_Unary, /* not, neg, clz */ |
cerion | ed623db | 2005-06-20 12:42:04 +0000 | [diff] [blame] | 448 | Pin_MulL, /* widening multiply */ |
| 449 | Pin_Div, /* div */ |
| 450 | Pin_Call, /* call to address in register */ |
| 451 | Pin_Goto, /* conditional/unconditional jmp to dst */ |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 452 | Pin_CMov, /* conditional move */ |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 453 | Pin_Load, /* load a 8|16|32|64 bit value from mem */ |
| 454 | Pin_Store, /* store a 8|16|32|64 bit value to mem */ |
| 455 | Pin_Set, /* convert condition code to value 0 or 1 */ |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 456 | Pin_MfCR, /* move from condition register to GPR */ |
| 457 | Pin_MFence, /* mem fence */ |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 458 | |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 459 | Pin_FpUnary, /* FP unary op */ |
| 460 | Pin_FpBinary, /* FP binary op */ |
| 461 | Pin_FpLdSt, /* FP load/store */ |
| 462 | Pin_FpF64toF32, /* FP round IEEE754 double to IEEE754 single */ |
| 463 | Pin_FpF64toI32, /* FP round IEEE754 double to 32-bit integer */ |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 464 | Pin_FpF64toI64, /* FP round IEEE754 double to 64-bit integer */ |
cerion | 07b07a9 | 2005-12-22 14:32:35 +0000 | [diff] [blame] | 465 | Pin_FpI64toF64, /* FP round IEEE754 64-bit integer to double */ |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 466 | Pin_FpCMov, /* FP floating point conditional move */ |
| 467 | Pin_FpLdFPSCR, /* mtfsf */ |
| 468 | Pin_FpCmp, /* FP compare, generating value into int reg */ |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 469 | Pin_RdWrLR, /* Read/Write Link Register */ |
| 470 | |
| 471 | // Pin_AvConst, /* Generate restricted AV literal */ |
| 472 | Pin_AvLdSt, /* AV load/store (kludging for AMode_IR) */ |
| 473 | Pin_AvUnary, /* AV unary general reg=>reg */ |
cerion | 6b6f59e | 2005-06-28 20:59:18 +0000 | [diff] [blame] | 474 | |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 475 | Pin_AvBinary, /* AV binary general reg,reg=>reg */ |
cerion | 6b6f59e | 2005-06-28 20:59:18 +0000 | [diff] [blame] | 476 | Pin_AvBin8x16, /* AV binary, 8x4 */ |
| 477 | Pin_AvBin16x8, /* AV binary, 16x4 */ |
| 478 | Pin_AvBin32x4, /* AV binary, 32x4 */ |
| 479 | |
| 480 | Pin_AvBin32Fx4, /* AV FP binary, 32Fx4 */ |
cerion | 8ea0d3e | 2005-11-14 00:44:47 +0000 | [diff] [blame] | 481 | Pin_AvUn32Fx4, /* AV FP unary, 32Fx4 */ |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 482 | |
| 483 | Pin_AvPerm, /* AV permute (shuffle) */ |
| 484 | Pin_AvSel, /* AV select */ |
| 485 | Pin_AvShlDbl, /* AV shift-left double by imm */ |
| 486 | Pin_AvSplat, /* One elem repeated throughout dst */ |
cerion | 6b6f59e | 2005-06-28 20:59:18 +0000 | [diff] [blame] | 487 | Pin_AvLdVSCR, /* mtvscr */ |
| 488 | Pin_AvCMov /* AV conditional move */ |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 489 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 490 | PPCInstrTag; |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 491 | |
cerion | cd30449 | 2005-02-08 19:40:24 +0000 | [diff] [blame] | 492 | /* Destinations are on the LEFT (first operand) */ |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 493 | |
| 494 | typedef |
| 495 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 496 | PPCInstrTag tag; |
cerion | cd30449 | 2005-02-08 19:40:24 +0000 | [diff] [blame] | 497 | union { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 498 | /* Get a 32/64-bit literal into a register. |
| 499 | May turn into a number of real insns. */ |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 500 | struct { |
| 501 | HReg dst; |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 502 | ULong imm64; |
| 503 | } LI; |
cerion | bb01b7c | 2005-12-16 13:40:18 +0000 | [diff] [blame] | 504 | /* Integer add/sub/and/or/xor. Limitations: |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 505 | - For add, the immediate, if it exists, is a signed 16. |
| 506 | - For sub, the immediate, if it exists, is a signed 16 |
| 507 | which may not be -32768, since no such instruction |
| 508 | exists, and so we have to emit addi with +32768, but |
| 509 | that is not possible. |
| 510 | - For and/or/xor, the immediate, if it exists, |
| 511 | is an unsigned 16. |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 512 | */ |
cerion | cd30449 | 2005-02-08 19:40:24 +0000 | [diff] [blame] | 513 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 514 | PPCAluOp op; |
| 515 | HReg dst; |
| 516 | HReg srcL; |
| 517 | PPCRH* srcR; |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 518 | } Alu; |
cerion | bb01b7c | 2005-12-16 13:40:18 +0000 | [diff] [blame] | 519 | /* Integer shl/shr/sar. |
| 520 | Limitations: the immediate, if it exists, |
| 521 | is a signed 5-bit value between 1 and 31 inclusive. |
| 522 | */ |
| 523 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 524 | PPCShftOp op; |
| 525 | Bool sz32; /* mode64 has both 32 and 64bit shft */ |
| 526 | HReg dst; |
| 527 | HReg srcL; |
| 528 | PPCRH* srcR; |
cerion | bb01b7c | 2005-12-16 13:40:18 +0000 | [diff] [blame] | 529 | } Shft; |
cerion | 4a49b03 | 2005-11-08 16:23:07 +0000 | [diff] [blame] | 530 | /* */ |
| 531 | struct { |
| 532 | Bool isAdd; /* else sub */ |
| 533 | Bool setC; /* else read carry */ |
| 534 | HReg dst; |
| 535 | HReg srcL; |
| 536 | HReg srcR; |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 537 | } AddSubC; |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 538 | /* If signed, the immediate, if it exists, is a signed 16, |
| 539 | else it is an unsigned 16. */ |
cerion | cd30449 | 2005-02-08 19:40:24 +0000 | [diff] [blame] | 540 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 541 | Bool syned; |
| 542 | Bool sz32; /* mode64 has both 32 and 64bit cmp */ |
| 543 | UInt crfD; |
| 544 | HReg srcL; |
| 545 | PPCRH* srcR; |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 546 | } Cmp; |
cerion | 2c49e03 | 2005-02-09 17:29:49 +0000 | [diff] [blame] | 547 | /* Not and Neg */ |
| 548 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 549 | PPCUnaryOp op; |
| 550 | HReg dst; |
| 551 | HReg src; |
| 552 | } Unary; |
cerion | 92f5dc7 | 2005-02-10 16:11:35 +0000 | [diff] [blame] | 553 | struct { |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 554 | Bool syned; /* meaningless if hi32==False */ |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 555 | Bool hi; /* False=>low, True=>high */ |
cerion | bb01b7c | 2005-12-16 13:40:18 +0000 | [diff] [blame] | 556 | Bool sz32; /* mode64 has both 32 & 64bit mull */ |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 557 | HReg dst; |
| 558 | HReg srcL; |
| 559 | HReg srcR; |
cerion | 92f5dc7 | 2005-02-10 16:11:35 +0000 | [diff] [blame] | 560 | } MulL; |
cerion | 9e263e3 | 2005-03-03 17:21:51 +0000 | [diff] [blame] | 561 | /* ppc32 div/divu instruction. */ |
cerion | c0e707e | 2005-02-10 22:35:34 +0000 | [diff] [blame] | 562 | struct { |
cerion | 33aa6da | 2005-02-16 10:25:26 +0000 | [diff] [blame] | 563 | Bool syned; |
cerion | bb01b7c | 2005-12-16 13:40:18 +0000 | [diff] [blame] | 564 | Bool sz32; /* mode64 has both 32 & 64bit div */ |
cerion | 33aa6da | 2005-02-16 10:25:26 +0000 | [diff] [blame] | 565 | HReg dst; |
cerion | a2f7588 | 2005-03-15 16:33:38 +0000 | [diff] [blame] | 566 | HReg srcL; |
| 567 | HReg srcR; |
cerion | c0e707e | 2005-02-10 22:35:34 +0000 | [diff] [blame] | 568 | } Div; |
cerion | 2c49e03 | 2005-02-09 17:29:49 +0000 | [diff] [blame] | 569 | /* Pseudo-insn. Call target (an absolute address), on given |
sewardj | 6a64a9f | 2005-08-21 00:48:37 +0000 | [diff] [blame] | 570 | condition (which could be Pct_ALWAYS). argiregs indicates |
| 571 | which of r3 .. r10 carries argument values for this call, |
| 572 | using a bit mask (1<<N is set if rN holds an arg, for N in |
| 573 | 3 .. 10 inclusive). */ |
cerion | 2c49e03 | 2005-02-09 17:29:49 +0000 | [diff] [blame] | 574 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 575 | PPCCondCode cond; |
| 576 | Addr64 target; |
| 577 | UInt argiregs; |
cerion | 2c49e03 | 2005-02-09 17:29:49 +0000 | [diff] [blame] | 578 | } Call; |
| 579 | /* Pseudo-insn. Goto dst, on given condition (which could be |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 580 | Pct_ALWAYS). */ |
cerion | 2c49e03 | 2005-02-09 17:29:49 +0000 | [diff] [blame] | 581 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 582 | IRJumpKind jk; |
| 583 | PPCCondCode cond; |
| 584 | PPCRI* dst; |
cerion | 2c49e03 | 2005-02-09 17:29:49 +0000 | [diff] [blame] | 585 | } Goto; |
cerion | b536af9 | 2005-02-10 15:03:19 +0000 | [diff] [blame] | 586 | /* Mov src to dst on the given condition, which may not |
cerion | 9abfcbc | 2005-02-25 11:16:58 +0000 | [diff] [blame] | 587 | be the bogus Pct_ALWAYS. */ |
cerion | b536af9 | 2005-02-10 15:03:19 +0000 | [diff] [blame] | 588 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 589 | PPCCondCode cond; |
cerion | cd30449 | 2005-02-08 19:40:24 +0000 | [diff] [blame] | 590 | HReg dst; |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 591 | PPCRI* src; |
| 592 | } CMov; |
| 593 | /* Sign/Zero extending loads. Dst size is host word size */ |
| 594 | struct { |
| 595 | UChar sz; /* 1|2|4|8 */ |
| 596 | Bool syned; |
| 597 | HReg dst; |
| 598 | PPCAMode* src; |
cerion | 7cf8e4e | 2005-02-16 16:08:17 +0000 | [diff] [blame] | 599 | } Load; |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 600 | /* 64/32/16/8 bit stores */ |
cerion | cd30449 | 2005-02-08 19:40:24 +0000 | [diff] [blame] | 601 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 602 | UChar sz; /* 1|2|4|8 */ |
| 603 | PPCAMode* dst; |
| 604 | HReg src; |
cerion | cd30449 | 2005-02-08 19:40:24 +0000 | [diff] [blame] | 605 | } Store; |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 606 | /* Convert a ppc condition code to value 0 or 1. */ |
cerion | b536af9 | 2005-02-10 15:03:19 +0000 | [diff] [blame] | 607 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 608 | PPCCondCode cond; |
| 609 | HReg dst; |
| 610 | } Set; |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 611 | /* Move the entire CR to a GPR */ |
| 612 | struct { |
| 613 | HReg dst; |
| 614 | } MfCR; |
cerion | 98411db | 2005-02-16 14:14:49 +0000 | [diff] [blame] | 615 | /* Mem fence. In short, an insn which flushes all preceding |
| 616 | loads and stores as much as possible before continuing. |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 617 | On PPC we emit a "sync". */ |
cerion | 92f5dc7 | 2005-02-10 16:11:35 +0000 | [diff] [blame] | 618 | struct { |
cerion | 92f5dc7 | 2005-02-10 16:11:35 +0000 | [diff] [blame] | 619 | } MFence; |
cerion | cd30449 | 2005-02-08 19:40:24 +0000 | [diff] [blame] | 620 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 621 | /* PPC Floating point */ |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 622 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 623 | PPCFpOp op; |
| 624 | HReg dst; |
| 625 | HReg src; |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 626 | } FpUnary; |
| 627 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 628 | PPCFpOp op; |
| 629 | HReg dst; |
| 630 | HReg srcL; |
| 631 | HReg srcR; |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 632 | } FpBinary; |
| 633 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 634 | Bool isLoad; |
| 635 | UChar sz; /* only 4 (IEEE single) or 8 (IEEE double) */ |
| 636 | HReg reg; |
| 637 | PPCAMode* addr; |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 638 | } FpLdSt; |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 639 | /* By observing the current FPU rounding mode, round src->dst, |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 640 | re-interpreting dst to an IEEE754 32-bit (float) type. */ |
| 641 | struct { |
| 642 | HReg src; |
| 643 | HReg dst; |
| 644 | } FpF64toF32; |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 645 | /* By observing the current FPU rounding mode, round src->dst, |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 646 | re-interpreting dst to an 32-bit integer type. */ |
| 647 | struct { |
| 648 | HReg src; |
| 649 | HReg dst; |
| 650 | } FpF64toI32; |
cerion | 07b07a9 | 2005-12-22 14:32:35 +0000 | [diff] [blame] | 651 | /* Ditto to 64-bit integer type. */ |
| 652 | struct { |
| 653 | HReg src; |
| 654 | HReg dst; |
| 655 | } FpF64toI64; |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 656 | /* By observing the current FPU rounding mode, reinterpret src |
| 657 | from a 64bit integer to double type, and round into dst. */ |
cerion | 07b07a9 | 2005-12-22 14:32:35 +0000 | [diff] [blame] | 658 | struct { |
| 659 | HReg src; |
| 660 | HReg dst; |
| 661 | } FpI64toF64; |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 662 | /* Mov src to dst on the given condition, which may not |
| 663 | be the bogus Xcc_ALWAYS. */ |
| 664 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 665 | PPCCondCode cond; |
| 666 | HReg dst; |
| 667 | HReg src; |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 668 | } FpCMov; |
| 669 | /* Load FP Status & Control Register */ |
| 670 | struct { |
| 671 | HReg src; |
| 672 | } FpLdFPSCR; |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 673 | /* Do a compare, generating result into an int register. */ |
cerion | 094d139 | 2005-06-20 13:45:57 +0000 | [diff] [blame] | 674 | struct { |
| 675 | UChar crfD; |
| 676 | HReg dst; |
| 677 | HReg srcL; |
| 678 | HReg srcR; |
| 679 | } FpCmp; |
cerion | cd30449 | 2005-02-08 19:40:24 +0000 | [diff] [blame] | 680 | |
cerion | 7f000af | 2005-02-22 20:36:49 +0000 | [diff] [blame] | 681 | /* Read/Write Link Register */ |
| 682 | struct { |
| 683 | Bool wrLR; |
| 684 | HReg gpr; |
| 685 | } RdWrLR; |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 686 | |
| 687 | /* Simplistic AltiVec */ |
| 688 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 689 | Bool isLoad; |
| 690 | UChar sz; /* 8|16|32|128 */ |
| 691 | HReg reg; |
| 692 | PPCAMode* addr; |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 693 | } AvLdSt; |
| 694 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 695 | PPCAvOp op; |
| 696 | HReg dst; |
| 697 | HReg src; |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 698 | } AvUnary; |
| 699 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 700 | PPCAvOp op; |
| 701 | HReg dst; |
| 702 | HReg srcL; |
| 703 | HReg srcR; |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 704 | } AvBinary; |
cerion | 6b6f59e | 2005-06-28 20:59:18 +0000 | [diff] [blame] | 705 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 706 | PPCAvOp op; |
| 707 | HReg dst; |
| 708 | HReg srcL; |
| 709 | HReg srcR; |
cerion | 6b6f59e | 2005-06-28 20:59:18 +0000 | [diff] [blame] | 710 | } AvBin8x16; |
| 711 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 712 | PPCAvOp op; |
| 713 | HReg dst; |
| 714 | HReg srcL; |
| 715 | HReg srcR; |
cerion | 6b6f59e | 2005-06-28 20:59:18 +0000 | [diff] [blame] | 716 | } AvBin16x8; |
| 717 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 718 | PPCAvOp op; |
| 719 | HReg dst; |
| 720 | HReg srcL; |
| 721 | HReg srcR; |
cerion | 6b6f59e | 2005-06-28 20:59:18 +0000 | [diff] [blame] | 722 | } AvBin32x4; |
| 723 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 724 | PPCAvFpOp op; |
cerion | 6b6f59e | 2005-06-28 20:59:18 +0000 | [diff] [blame] | 725 | HReg dst; |
| 726 | HReg srcL; |
| 727 | HReg srcR; |
| 728 | } AvBin32Fx4; |
cerion | 8ea0d3e | 2005-11-14 00:44:47 +0000 | [diff] [blame] | 729 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 730 | PPCAvFpOp op; |
cerion | 8ea0d3e | 2005-11-14 00:44:47 +0000 | [diff] [blame] | 731 | HReg dst; |
| 732 | HReg src; |
| 733 | } AvUn32Fx4; |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 734 | /* Perm,Sel,SlDbl,Splat are all weird AV permutations */ |
| 735 | struct { |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 736 | HReg dst; |
| 737 | HReg srcL; |
| 738 | HReg srcR; |
cerion | 92d9d87 | 2005-09-15 21:58:50 +0000 | [diff] [blame] | 739 | HReg ctl; |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 740 | } AvPerm; |
| 741 | struct { |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 742 | HReg dst; |
| 743 | HReg srcL; |
| 744 | HReg srcR; |
cerion | 92d9d87 | 2005-09-15 21:58:50 +0000 | [diff] [blame] | 745 | HReg ctl; |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 746 | } AvSel; |
| 747 | struct { |
| 748 | UChar shift; |
| 749 | HReg dst; |
| 750 | HReg srcL; |
| 751 | HReg srcR; |
| 752 | } AvShlDbl; |
| 753 | struct { |
| 754 | UChar sz; /* 8,16,32 */ |
| 755 | HReg dst; |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 756 | PPCVI5s* src; |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 757 | } AvSplat; |
cerion | 6b6f59e | 2005-06-28 20:59:18 +0000 | [diff] [blame] | 758 | /* Mov src to dst on the given condition, which may not |
| 759 | be the bogus Xcc_ALWAYS. */ |
| 760 | struct { |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 761 | PPCCondCode cond; |
| 762 | HReg dst; |
| 763 | HReg src; |
cerion | 6b6f59e | 2005-06-28 20:59:18 +0000 | [diff] [blame] | 764 | } AvCMov; |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 765 | /* Load AltiVec Status & Control Register */ |
cerion | c3d8bdc | 2005-06-28 18:06:23 +0000 | [diff] [blame] | 766 | struct { |
| 767 | HReg src; |
| 768 | } AvLdVSCR; |
cerion | cd30449 | 2005-02-08 19:40:24 +0000 | [diff] [blame] | 769 | } Pin; |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 770 | } |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 771 | PPCInstr; |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 772 | |
cerion | cd30449 | 2005-02-08 19:40:24 +0000 | [diff] [blame] | 773 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 774 | extern PPCInstr* PPCInstr_LI ( HReg, ULong, Bool ); |
| 775 | extern PPCInstr* PPCInstr_Alu ( PPCAluOp, HReg, HReg, PPCRH* ); |
| 776 | extern PPCInstr* PPCInstr_Shft ( PPCShftOp, Bool sz32, HReg, HReg, PPCRH* ); |
| 777 | extern PPCInstr* PPCInstr_AddSubC ( Bool, Bool, HReg, HReg, HReg ); |
| 778 | extern PPCInstr* PPCInstr_Cmp ( Bool, Bool, UInt, HReg, PPCRH* ); |
| 779 | extern PPCInstr* PPCInstr_Unary ( PPCUnaryOp op, HReg dst, HReg src ); |
| 780 | extern PPCInstr* PPCInstr_MulL ( Bool syned, Bool hi32, Bool sz32, HReg, HReg, HReg ); |
| 781 | extern PPCInstr* PPCInstr_Div ( Bool syned, Bool sz32, HReg dst, HReg srcL, HReg srcR ); |
| 782 | extern PPCInstr* PPCInstr_Call ( PPCCondCode, Addr64, UInt ); |
| 783 | extern PPCInstr* PPCInstr_Goto ( IRJumpKind, PPCCondCode cond, PPCRI* dst ); |
| 784 | extern PPCInstr* PPCInstr_CMov ( PPCCondCode, HReg dst, PPCRI* src ); |
| 785 | extern PPCInstr* PPCInstr_Load ( UChar sz, Bool syned, |
| 786 | HReg dst, PPCAMode* src, Bool mode64 ); |
| 787 | extern PPCInstr* PPCInstr_Store ( UChar sz, PPCAMode* dst, |
| 788 | HReg src, Bool mode64 ); |
| 789 | extern PPCInstr* PPCInstr_Set ( PPCCondCode cond, HReg dst ); |
| 790 | extern PPCInstr* PPCInstr_MfCR ( HReg dst ); |
| 791 | extern PPCInstr* PPCInstr_MFence ( void ); |
cerion | ed623db | 2005-06-20 12:42:04 +0000 | [diff] [blame] | 792 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 793 | extern PPCInstr* PPCInstr_FpUnary ( PPCFpOp op, HReg dst, HReg src ); |
| 794 | extern PPCInstr* PPCInstr_FpBinary ( PPCFpOp op, HReg dst, HReg srcL, HReg srcR ); |
| 795 | extern PPCInstr* PPCInstr_FpLdSt ( Bool isLoad, UChar sz, HReg, PPCAMode* ); |
| 796 | extern PPCInstr* PPCInstr_FpF64toF32 ( HReg dst, HReg src ); |
| 797 | extern PPCInstr* PPCInstr_FpF64toI32 ( HReg dst, HReg src ); |
| 798 | extern PPCInstr* PPCInstr_FpF64toI64 ( HReg dst, HReg src ); |
| 799 | extern PPCInstr* PPCInstr_FpI64toF64 ( HReg dst, HReg src ); |
| 800 | extern PPCInstr* PPCInstr_FpCMov ( PPCCondCode, HReg dst, HReg src ); |
| 801 | extern PPCInstr* PPCInstr_FpLdFPSCR ( HReg src ); |
| 802 | extern PPCInstr* PPCInstr_FpCmp ( HReg dst, HReg srcL, HReg srcR ); |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 803 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 804 | extern PPCInstr* PPCInstr_RdWrLR ( Bool wrLR, HReg gpr ); |
cerion | 7f000af | 2005-02-22 20:36:49 +0000 | [diff] [blame] | 805 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 806 | extern PPCInstr* PPCInstr_AvLdSt ( Bool isLoad, UChar sz, HReg, PPCAMode* ); |
| 807 | extern PPCInstr* PPCInstr_AvUnary ( PPCAvOp op, HReg dst, HReg src ); |
| 808 | extern PPCInstr* PPCInstr_AvBinary ( PPCAvOp op, HReg dst, HReg srcL, HReg srcR ); |
| 809 | extern PPCInstr* PPCInstr_AvBin8x16 ( PPCAvOp op, HReg dst, HReg srcL, HReg srcR ); |
| 810 | extern PPCInstr* PPCInstr_AvBin16x8 ( PPCAvOp op, HReg dst, HReg srcL, HReg srcR ); |
| 811 | extern PPCInstr* PPCInstr_AvBin32x4 ( PPCAvOp op, HReg dst, HReg srcL, HReg srcR ); |
| 812 | extern PPCInstr* PPCInstr_AvBin32Fx4 ( PPCAvOp op, HReg dst, HReg srcL, HReg srcR ); |
| 813 | extern PPCInstr* PPCInstr_AvUn32Fx4 ( PPCAvOp op, HReg dst, HReg src ); |
| 814 | extern PPCInstr* PPCInstr_AvPerm ( HReg dst, HReg srcL, HReg srcR, HReg ctl ); |
| 815 | extern PPCInstr* PPCInstr_AvSel ( HReg ctl, HReg dst, HReg srcL, HReg srcR ); |
| 816 | extern PPCInstr* PPCInstr_AvShlDbl ( UChar shift, HReg dst, HReg srcL, HReg srcR ); |
| 817 | extern PPCInstr* PPCInstr_AvSplat ( UChar sz, HReg dst, PPCVI5s* src ); |
| 818 | extern PPCInstr* PPCInstr_AvCMov ( PPCCondCode, HReg dst, HReg src ); |
| 819 | extern PPCInstr* PPCInstr_AvLdVSCR ( HReg src ); |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 820 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 821 | extern void ppPPCInstr ( PPCInstr*, Bool mode64 ); |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 822 | |
| 823 | /* Some functions that insulate the register allocator from details |
| 824 | of the underlying instruction set. */ |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 825 | extern void getRegUsage_PPCInstr ( HRegUsage*, PPCInstr*, Bool mode64 ); |
| 826 | extern void mapRegs_PPCInstr ( HRegRemap*, PPCInstr* , Bool mode64); |
| 827 | extern Bool isMove_PPCInstr ( PPCInstr*, HReg*, HReg* ); |
| 828 | extern Int emit_PPCInstr ( UChar* buf, Int nbuf, PPCInstr*, |
| 829 | Bool mode64, void* dispatch ); |
| 830 | extern PPCInstr* genSpill_PPC ( HReg rreg, UShort offsetB, Bool mode64 ); |
| 831 | extern PPCInstr* genReload_PPC ( HReg rreg, UShort offsetB, Bool mode64 ); |
| 832 | extern void getAllocableRegs_PPC ( Int*, HReg**, Bool mode64 ); |
| 833 | extern HInstrArray* iselBB_PPC ( IRBB*, VexArchInfo* ); |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 834 | |
cerion | 5b2325f | 2005-12-23 00:55:09 +0000 | [diff] [blame] | 835 | #endif /* ndef __LIBVEX_HOST_PPC_HDEFS_H */ |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 836 | |
| 837 | /*---------------------------------------------------------------*/ |
cerion | d0eae2d | 2005-12-23 11:43:01 +0000 | [diff] [blame^] | 838 | /*--- end host-ppc/hdefs.h ---*/ |
cerion | bcf8c3e | 2005-02-04 16:17:07 +0000 | [diff] [blame] | 839 | /*---------------------------------------------------------------*/ |