sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 1 | |
| 2 | /*---------------------------------------------------------------*/ |
| 3 | /*--- ---*/ |
sewardj | c0ee2ed | 2004-07-27 10:29:41 +0000 | [diff] [blame] | 4 | /*--- This file (ir/irdefs.c) is ---*/ |
sewardj | dbcfae7 | 2005-08-02 11:14:04 +0000 | [diff] [blame] | 5 | /*--- Copyright (C) OpenWorks LLP. All rights reserved. ---*/ |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 6 | /*--- ---*/ |
| 7 | /*---------------------------------------------------------------*/ |
| 8 | |
sewardj | f8ed9d8 | 2004-11-12 17:40:23 +0000 | [diff] [blame] | 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. |
sewardj | f8ed9d8 | 2004-11-12 17:40:23 +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. |
sewardj | f8ed9d8 | 2004-11-12 17:40:23 +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. |
sewardj | f8ed9d8 | 2004-11-12 17:40:23 +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. |
sewardj | f8ed9d8 | 2004-11-12 17:40:23 +0000 | [diff] [blame] | 45 | */ |
| 46 | |
sewardj | 887a11a | 2004-07-05 17:26:47 +0000 | [diff] [blame] | 47 | #include "libvex_basictypes.h" |
| 48 | #include "libvex_ir.h" |
| 49 | #include "libvex.h" |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 50 | |
sewardj | c0ee2ed | 2004-07-27 10:29:41 +0000 | [diff] [blame] | 51 | #include "main/vex_util.h" |
| 52 | |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 53 | |
| 54 | /*---------------------------------------------------------------*/ |
| 55 | /*--- Printing the IR ---*/ |
| 56 | /*---------------------------------------------------------------*/ |
| 57 | |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 58 | void ppIRType ( IRType ty ) |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 59 | { |
sewardj | 3e83893 | 2005-01-07 12:09:15 +0000 | [diff] [blame] | 60 | switch (ty) { |
| 61 | case Ity_INVALID: vex_printf("Ity_INVALID"); break; |
sewardj | 9b96767 | 2005-02-08 11:13:09 +0000 | [diff] [blame] | 62 | case Ity_I1: vex_printf( "I1"); break; |
| 63 | case Ity_I8: vex_printf( "I8"); break; |
| 64 | case Ity_I16: vex_printf( "I16"); break; |
| 65 | case Ity_I32: vex_printf( "I32"); break; |
| 66 | case Ity_I64: vex_printf( "I64"); break; |
| 67 | case Ity_I128: vex_printf( "I128"); break; |
| 68 | case Ity_F32: vex_printf( "F32"); break; |
| 69 | case Ity_F64: vex_printf( "F64"); break; |
sewardj | 3e83893 | 2005-01-07 12:09:15 +0000 | [diff] [blame] | 70 | case Ity_V128: vex_printf( "V128"); break; |
| 71 | default: vex_printf("ty = 0x%x\n", (Int)ty); |
| 72 | vpanic("ppIRType"); |
| 73 | } |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 74 | } |
| 75 | |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 76 | void ppIRConst ( IRConst* con ) |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 77 | { |
sewardj | a162c2c | 2005-12-18 03:07:11 +0000 | [diff] [blame] | 78 | union { ULong i64; Double f64; } u; |
sewardj | 6332740 | 2006-01-25 03:26:27 +0000 | [diff] [blame] | 79 | vassert(sizeof(ULong) == sizeof(Double)); |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 80 | switch (con->tag) { |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 81 | case Ico_U1: vex_printf( "%d:I1", con->Ico.U1 ? 1 : 0); break; |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 82 | case Ico_U8: vex_printf( "0x%x:I8", (UInt)(con->Ico.U8)); break; |
| 83 | case Ico_U16: vex_printf( "0x%x:I16", (UInt)(con->Ico.U16)); break; |
| 84 | case Ico_U32: vex_printf( "0x%x:I32", (UInt)(con->Ico.U32)); break; |
| 85 | case Ico_U64: vex_printf( "0x%llx:I64", (ULong)(con->Ico.U64)); break; |
sewardj | a162c2c | 2005-12-18 03:07:11 +0000 | [diff] [blame] | 86 | case Ico_F64: u.f64 = con->Ico.F64; |
| 87 | vex_printf( "F64{0x%llx}", u.i64); |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 88 | break; |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 89 | case Ico_F64i: vex_printf( "F64i{0x%llx}", con->Ico.F64i); break; |
sewardj | 1e6ad74 | 2004-12-02 16:16:11 +0000 | [diff] [blame] | 90 | case Ico_V128: vex_printf( "V128{0x%04x}", (UInt)(con->Ico.V128)); break; |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 91 | default: vpanic("ppIRConst"); |
| 92 | } |
| 93 | } |
| 94 | |
sewardj | 8ea867b | 2004-10-30 19:03:02 +0000 | [diff] [blame] | 95 | void ppIRCallee ( IRCallee* ce ) |
| 96 | { |
| 97 | vex_printf("%s", ce->name); |
sewardj | 7735254 | 2004-10-30 20:39:01 +0000 | [diff] [blame] | 98 | if (ce->regparms > 0) |
sewardj | 43c5646 | 2004-11-06 12:17:57 +0000 | [diff] [blame] | 99 | vex_printf("[rp=%d]", ce->regparms); |
| 100 | if (ce->mcx_mask > 0) |
| 101 | vex_printf("[mcx=0x%x]", ce->mcx_mask); |
sewardj | 8ea867b | 2004-10-30 19:03:02 +0000 | [diff] [blame] | 102 | vex_printf("{%p}", (void*)ce->addr); |
| 103 | } |
| 104 | |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 105 | void ppIRArray ( IRArray* arr ) |
| 106 | { |
sewardj | 0bfea7f | 2004-10-04 07:15:48 +0000 | [diff] [blame] | 107 | vex_printf("(%d:%dx", arr->base, arr->nElems); |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 108 | ppIRType(arr->elemTy); |
sewardj | 0bfea7f | 2004-10-04 07:15:48 +0000 | [diff] [blame] | 109 | vex_printf(")"); |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 110 | } |
| 111 | |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 112 | void ppIRTemp ( IRTemp tmp ) |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 113 | { |
sewardj | 92d168d | 2004-11-15 14:22:12 +0000 | [diff] [blame] | 114 | if (tmp == IRTemp_INVALID) |
| 115 | vex_printf("IRTemp_INVALID"); |
sewardj | fbcaf33 | 2004-07-08 01:46:01 +0000 | [diff] [blame] | 116 | else |
sewardj | 41f43bc | 2004-07-08 14:23:22 +0000 | [diff] [blame] | 117 | vex_printf( "t%d", (Int)tmp); |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 118 | } |
| 119 | |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 120 | void ppIROp ( IROp op ) |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 121 | { |
sewardj | a98bf49 | 2005-02-07 01:39:17 +0000 | [diff] [blame] | 122 | HChar* str; |
| 123 | IROp base; |
sewardj | 41f43bc | 2004-07-08 14:23:22 +0000 | [diff] [blame] | 124 | switch (op) { |
| 125 | case Iop_Add8 ... Iop_Add64: |
| 126 | str = "Add"; base = Iop_Add8; break; |
| 127 | case Iop_Sub8 ... Iop_Sub64: |
| 128 | str = "Sub"; base = Iop_Sub8; break; |
| 129 | case Iop_Mul8 ... Iop_Mul64: |
| 130 | str = "Mul"; base = Iop_Mul8; break; |
| 131 | case Iop_Or8 ... Iop_Or64: |
| 132 | str = "Or"; base = Iop_Or8; break; |
| 133 | case Iop_And8 ... Iop_And64: |
| 134 | str = "And"; base = Iop_And8; break; |
| 135 | case Iop_Xor8 ... Iop_Xor64: |
| 136 | str = "Xor"; base = Iop_Xor8; break; |
| 137 | case Iop_Shl8 ... Iop_Shl64: |
| 138 | str = "Shl"; base = Iop_Shl8; break; |
| 139 | case Iop_Shr8 ... Iop_Shr64: |
| 140 | str = "Shr"; base = Iop_Shr8; break; |
| 141 | case Iop_Sar8 ... Iop_Sar64: |
| 142 | str = "Sar"; base = Iop_Sar8; break; |
sewardj | e90ad6a | 2004-07-10 19:02:10 +0000 | [diff] [blame] | 143 | case Iop_CmpEQ8 ... Iop_CmpEQ64: |
| 144 | str = "CmpEQ"; base = Iop_CmpEQ8; break; |
| 145 | case Iop_CmpNE8 ... Iop_CmpNE64: |
| 146 | str = "CmpNE"; base = Iop_CmpNE8; break; |
sewardj | 41f43bc | 2004-07-08 14:23:22 +0000 | [diff] [blame] | 147 | case Iop_Not8 ... Iop_Not64: |
| 148 | str = "Not"; base = Iop_Not8; break; |
| 149 | /* other cases must explicitly "return;" */ |
sewardj | 9690d92 | 2004-07-14 01:39:17 +0000 | [diff] [blame] | 150 | case Iop_8Uto16: vex_printf("8Uto16"); return; |
| 151 | case Iop_8Uto32: vex_printf("8Uto32"); return; |
| 152 | case Iop_16Uto32: vex_printf("16Uto32"); return; |
| 153 | case Iop_8Sto16: vex_printf("8Sto16"); return; |
| 154 | case Iop_8Sto32: vex_printf("8Sto32"); return; |
| 155 | case Iop_16Sto32: vex_printf("16Sto32"); return; |
sewardj | bb53f8c | 2004-08-14 11:50:01 +0000 | [diff] [blame] | 156 | case Iop_32Sto64: vex_printf("32Sto64"); return; |
sewardj | e5427e8 | 2004-09-11 19:43:51 +0000 | [diff] [blame] | 157 | case Iop_32Uto64: vex_printf("32Uto64"); return; |
sewardj | a238471 | 2004-07-29 14:36:40 +0000 | [diff] [blame] | 158 | case Iop_32to8: vex_printf("32to8"); return; |
sewardj | 291a7e8 | 2005-04-27 11:42:44 +0000 | [diff] [blame] | 159 | case Iop_16Uto64: vex_printf("16Uto64"); return; |
| 160 | case Iop_16Sto64: vex_printf("16Sto64"); return; |
| 161 | case Iop_8Uto64: vex_printf("8Uto64"); return; |
| 162 | case Iop_8Sto64: vex_printf("8Sto64"); return; |
| 163 | case Iop_64to16: vex_printf("64to16"); return; |
| 164 | case Iop_64to8: vex_printf("64to8"); return; |
sewardj | 6e797c5 | 2004-10-13 15:20:17 +0000 | [diff] [blame] | 165 | |
| 166 | case Iop_Not1: vex_printf("Not1"); return; |
sewardj | 9690d92 | 2004-07-14 01:39:17 +0000 | [diff] [blame] | 167 | case Iop_32to1: vex_printf("32to1"); return; |
sewardj | 291a7e8 | 2005-04-27 11:42:44 +0000 | [diff] [blame] | 168 | case Iop_64to1: vex_printf("64to1"); return; |
sewardj | 9690d92 | 2004-07-14 01:39:17 +0000 | [diff] [blame] | 169 | case Iop_1Uto8: vex_printf("1Uto8"); return; |
sewardj | 84ff065 | 2004-08-23 16:16:08 +0000 | [diff] [blame] | 170 | case Iop_1Uto32: vex_printf("1Uto32"); return; |
sewardj | 291a7e8 | 2005-04-27 11:42:44 +0000 | [diff] [blame] | 171 | case Iop_1Uto64: vex_printf("1Uto64"); return; |
sewardj | fd33277 | 2004-11-09 16:01:40 +0000 | [diff] [blame] | 172 | case Iop_1Sto8: vex_printf("1Sto8"); return; |
sewardj | 8eda630 | 2004-11-05 01:55:46 +0000 | [diff] [blame] | 173 | case Iop_1Sto16: vex_printf("1Sto16"); return; |
sewardj | 415d935 | 2004-11-04 15:20:15 +0000 | [diff] [blame] | 174 | case Iop_1Sto32: vex_printf("1Sto32"); return; |
sewardj | b5874aa | 2004-11-04 16:57:50 +0000 | [diff] [blame] | 175 | case Iop_1Sto64: vex_printf("1Sto64"); return; |
sewardj | 9690d92 | 2004-07-14 01:39:17 +0000 | [diff] [blame] | 176 | |
| 177 | case Iop_MullS8: vex_printf("MullS8"); return; |
| 178 | case Iop_MullS16: vex_printf("MullS16"); return; |
| 179 | case Iop_MullS32: vex_printf("MullS32"); return; |
sewardj | 9b96767 | 2005-02-08 11:13:09 +0000 | [diff] [blame] | 180 | case Iop_MullS64: vex_printf("MullS64"); return; |
sewardj | 9690d92 | 2004-07-14 01:39:17 +0000 | [diff] [blame] | 181 | case Iop_MullU8: vex_printf("MullU8"); return; |
| 182 | case Iop_MullU16: vex_printf("MullU16"); return; |
| 183 | case Iop_MullU32: vex_printf("MullU32"); return; |
sewardj | 9b96767 | 2005-02-08 11:13:09 +0000 | [diff] [blame] | 184 | case Iop_MullU64: vex_printf("MullU64"); return; |
sewardj | 9690d92 | 2004-07-14 01:39:17 +0000 | [diff] [blame] | 185 | |
sewardj | f53b735 | 2005-04-06 20:01:56 +0000 | [diff] [blame] | 186 | case Iop_Clz64: vex_printf("Clz64"); return; |
sewardj | ce646f2 | 2004-08-31 23:55:54 +0000 | [diff] [blame] | 187 | case Iop_Clz32: vex_printf("Clz32"); return; |
sewardj | f53b735 | 2005-04-06 20:01:56 +0000 | [diff] [blame] | 188 | case Iop_Ctz64: vex_printf("Ctz64"); return; |
sewardj | ce646f2 | 2004-08-31 23:55:54 +0000 | [diff] [blame] | 189 | case Iop_Ctz32: vex_printf("Ctz32"); return; |
| 190 | |
sewardj | 84ff065 | 2004-08-23 16:16:08 +0000 | [diff] [blame] | 191 | case Iop_CmpLT32S: vex_printf("CmpLT32S"); return; |
| 192 | case Iop_CmpLE32S: vex_printf("CmpLE32S"); return; |
| 193 | case Iop_CmpLT32U: vex_printf("CmpLT32U"); return; |
| 194 | case Iop_CmpLE32U: vex_printf("CmpLE32U"); return; |
| 195 | |
sewardj | 9854007 | 2005-04-26 01:52:01 +0000 | [diff] [blame] | 196 | case Iop_CmpLT64S: vex_printf("CmpLT64S"); return; |
| 197 | case Iop_CmpLE64S: vex_printf("CmpLE64S"); return; |
| 198 | case Iop_CmpLT64U: vex_printf("CmpLT64U"); return; |
| 199 | case Iop_CmpLE64U: vex_printf("CmpLE64U"); return; |
| 200 | |
sewardj | 0033ddc | 2005-04-26 23:34:34 +0000 | [diff] [blame] | 201 | case Iop_CmpNEZ8: vex_printf("CmpNEZ8"); return; |
| 202 | case Iop_CmpNEZ16: vex_printf("CmpNEZ16"); return; |
| 203 | case Iop_CmpNEZ32: vex_printf("CmpNEZ32"); return; |
| 204 | case Iop_CmpNEZ64: vex_printf("CmpNEZ64"); return; |
| 205 | |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 206 | case Iop_CmpORD32U: vex_printf("CmpORD32U"); return; |
| 207 | case Iop_CmpORD32S: vex_printf("CmpORD32S"); return; |
| 208 | |
cerion | 2831b00 | 2005-11-30 19:55:22 +0000 | [diff] [blame] | 209 | case Iop_CmpORD64U: vex_printf("CmpORD64U"); return; |
| 210 | case Iop_CmpORD64S: vex_printf("CmpORD64S"); return; |
| 211 | |
sewardj | 0033ddc | 2005-04-26 23:34:34 +0000 | [diff] [blame] | 212 | case Iop_Neg8: vex_printf("Neg8"); return; |
| 213 | case Iop_Neg16: vex_printf("Neg16"); return; |
| 214 | case Iop_Neg32: vex_printf("Neg32"); return; |
| 215 | case Iop_Neg64: vex_printf("Neg64"); return; |
| 216 | |
cerion | 5c8a0cb | 2005-02-03 13:59:46 +0000 | [diff] [blame] | 217 | case Iop_DivU32: vex_printf("DivU32"); return; |
| 218 | case Iop_DivS32: vex_printf("DivS32"); return; |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 219 | case Iop_DivU64: vex_printf("DivU64"); return; |
| 220 | case Iop_DivS64: vex_printf("DivS64"); return; |
cerion | 5c8a0cb | 2005-02-03 13:59:46 +0000 | [diff] [blame] | 221 | |
sewardj | 9690d92 | 2004-07-14 01:39:17 +0000 | [diff] [blame] | 222 | case Iop_DivModU64to32: vex_printf("DivModU64to32"); return; |
| 223 | case Iop_DivModS64to32: vex_printf("DivModS64to32"); return; |
| 224 | |
sewardj | 343b9d0 | 2005-01-31 18:08:45 +0000 | [diff] [blame] | 225 | case Iop_DivModU128to64: vex_printf("DivModU128to64"); return; |
| 226 | case Iop_DivModS128to64: vex_printf("DivModS128to64"); return; |
| 227 | |
sewardj | b81f8b3 | 2004-07-30 10:17:50 +0000 | [diff] [blame] | 228 | case Iop_16HIto8: vex_printf("16HIto8"); return; |
| 229 | case Iop_16to8: vex_printf("16to8"); return; |
| 230 | case Iop_8HLto16: vex_printf("8HLto16"); return; |
| 231 | |
sewardj | 8c7f1ab | 2004-07-29 20:31:09 +0000 | [diff] [blame] | 232 | case Iop_32HIto16: vex_printf("32HIto16"); return; |
| 233 | case Iop_32to16: vex_printf("32to16"); return; |
| 234 | case Iop_16HLto32: vex_printf("16HLto32"); return; |
| 235 | |
sewardj | 9690d92 | 2004-07-14 01:39:17 +0000 | [diff] [blame] | 236 | case Iop_64HIto32: vex_printf("64HIto32"); return; |
sewardj | 8c7f1ab | 2004-07-29 20:31:09 +0000 | [diff] [blame] | 237 | case Iop_64to32: vex_printf("64to32"); return; |
sewardj | 9690d92 | 2004-07-14 01:39:17 +0000 | [diff] [blame] | 238 | case Iop_32HLto64: vex_printf("32HLto64"); return; |
| 239 | |
sewardj | 9b96767 | 2005-02-08 11:13:09 +0000 | [diff] [blame] | 240 | case Iop_128HIto64: vex_printf("128HIto64"); return; |
| 241 | case Iop_128to64: vex_printf("128to64"); return; |
| 242 | case Iop_64HLto128: vex_printf("64HLto128"); return; |
| 243 | |
sewardj | cfded9a | 2004-09-09 11:44:16 +0000 | [diff] [blame] | 244 | case Iop_AddF64: vex_printf("AddF64"); return; |
| 245 | case Iop_SubF64: vex_printf("SubF64"); return; |
| 246 | case Iop_MulF64: vex_printf("MulF64"); return; |
| 247 | case Iop_DivF64: vex_printf("DivF64"); return; |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 248 | case Iop_AddF64r32: vex_printf("AddF64r32"); return; |
| 249 | case Iop_SubF64r32: vex_printf("SubF64r32"); return; |
| 250 | case Iop_MulF64r32: vex_printf("MulF64r32"); return; |
| 251 | case Iop_DivF64r32: vex_printf("DivF64r32"); return; |
sewardj | 46de407 | 2004-09-11 19:23:24 +0000 | [diff] [blame] | 252 | |
sewardj | 442d0be | 2004-10-15 22:57:13 +0000 | [diff] [blame] | 253 | case Iop_ScaleF64: vex_printf("ScaleF64"); return; |
| 254 | case Iop_AtanF64: vex_printf("AtanF64"); return; |
| 255 | case Iop_Yl2xF64: vex_printf("Yl2xF64"); return; |
| 256 | case Iop_Yl2xp1F64: vex_printf("Yl2xp1F64"); return; |
| 257 | case Iop_PRemF64: vex_printf("PRemF64"); return; |
| 258 | case Iop_PRemC3210F64: vex_printf("PRemC3210F64"); return; |
| 259 | case Iop_PRem1F64: vex_printf("PRem1F64"); return; |
| 260 | case Iop_PRem1C3210F64: vex_printf("PRem1C3210F64"); return; |
| 261 | case Iop_NegF64: vex_printf("NegF64"); return; |
| 262 | case Iop_SqrtF64: vex_printf("SqrtF64"); return; |
sewardj | 46de407 | 2004-09-11 19:23:24 +0000 | [diff] [blame] | 263 | |
sewardj | 883b00b | 2004-09-11 09:30:24 +0000 | [diff] [blame] | 264 | case Iop_AbsF64: vex_printf("AbsF64"); return; |
sewardj | cfded9a | 2004-09-09 11:44:16 +0000 | [diff] [blame] | 265 | case Iop_SinF64: vex_printf("SinF64"); return; |
| 266 | case Iop_CosF64: vex_printf("CosF64"); return; |
sewardj | 99016a7 | 2004-10-15 22:09:17 +0000 | [diff] [blame] | 267 | case Iop_TanF64: vex_printf("TanF64"); return; |
sewardj | 06c32a0 | 2004-09-12 12:07:34 +0000 | [diff] [blame] | 268 | case Iop_2xm1F64: vex_printf("2xm1F64"); return; |
sewardj | bdc7d21 | 2004-09-09 02:46:40 +0000 | [diff] [blame] | 269 | |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 270 | case Iop_MAddF64: vex_printf("MAddF64"); return; |
| 271 | case Iop_MSubF64: vex_printf("MSubF64"); return; |
| 272 | case Iop_MAddF64r32: vex_printf("MAddF64r32"); return; |
| 273 | case Iop_MSubF64r32: vex_printf("MSubF64r32"); return; |
| 274 | |
| 275 | case Iop_Est5FRSqrt: vex_printf("Est5FRSqrt"); return; |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 276 | case Iop_TruncF64asF32: vex_printf("TruncF64asF32"); return; |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 277 | case Iop_CalcFPRF: vex_printf("CalcFPRF"); |
sewardj | baf971a | 2006-01-27 15:09:35 +0000 | [diff] [blame] | 278 | |
sewardj | 46de407 | 2004-09-11 19:23:24 +0000 | [diff] [blame] | 279 | case Iop_CmpF64: vex_printf("CmpF64"); return; |
| 280 | |
sewardj | 3bca906 | 2004-12-04 14:36:09 +0000 | [diff] [blame] | 281 | case Iop_F64toI16: vex_printf("F64toI16"); return; |
| 282 | case Iop_F64toI32: vex_printf("F64toI32"); return; |
| 283 | case Iop_F64toI64: vex_printf("F64toI64"); return; |
| 284 | |
| 285 | case Iop_I16toF64: vex_printf("I16toF64"); return; |
sewardj | 89cd093 | 2004-09-08 18:23:25 +0000 | [diff] [blame] | 286 | case Iop_I32toF64: vex_printf("I32toF64"); return; |
sewardj | bdc7d21 | 2004-09-09 02:46:40 +0000 | [diff] [blame] | 287 | case Iop_I64toF64: vex_printf("I64toF64"); return; |
sewardj | cfded9a | 2004-09-09 11:44:16 +0000 | [diff] [blame] | 288 | |
sewardj | 89cd093 | 2004-09-08 18:23:25 +0000 | [diff] [blame] | 289 | case Iop_F32toF64: vex_printf("F32toF64"); return; |
| 290 | case Iop_F64toF32: vex_printf("F64toF32"); return; |
sewardj | bb53f8c | 2004-08-14 11:50:01 +0000 | [diff] [blame] | 291 | |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 292 | case Iop_RoundF64toInt: vex_printf("RoundF64toInt"); return; |
| 293 | case Iop_RoundF64toF32: vex_printf("RoundF64toF32"); return; |
sewardj | 3bca906 | 2004-12-04 14:36:09 +0000 | [diff] [blame] | 294 | |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 295 | case Iop_ReinterpF64asI64: vex_printf("ReinterpF64asI64"); return; |
| 296 | case Iop_ReinterpI64asF64: vex_printf("ReinterpI64asF64"); return; |
sewardj | fd22645 | 2004-12-07 19:02:18 +0000 | [diff] [blame] | 297 | case Iop_ReinterpI32asF32: vex_printf("ReinterpI32asF32"); return; |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 298 | |
cerion | f294eb3 | 2005-11-16 17:21:10 +0000 | [diff] [blame] | 299 | case Iop_I32UtoFx4: vex_printf("Iop_I32UtoFx4"); return; |
| 300 | case Iop_I32StoFx4: vex_printf("Iop_I32StoFx4"); return; |
| 301 | |
| 302 | case Iop_QFtoI32Ux4_RZ: vex_printf("Iop_QFtoI32Ux4_RZ"); return; |
| 303 | case Iop_QFtoI32Sx4_RZ: vex_printf("Iop_QFtoI32Sx4_RZ"); return; |
| 304 | |
| 305 | case Iop_RoundF32x4_RM: vex_printf("Iop_RoundF32x4_RM"); return; |
| 306 | case Iop_RoundF32x4_RP: vex_printf("Iop_RoundF32x4_RP"); return; |
| 307 | case Iop_RoundF32x4_RN: vex_printf("Iop_RoundF32x4_RN"); return; |
| 308 | case Iop_RoundF32x4_RZ: vex_printf("Iop_RoundF32x4_RZ"); return; |
| 309 | |
sewardj | 38a3f86 | 2005-01-13 15:06:51 +0000 | [diff] [blame] | 310 | case Iop_Add8x8: vex_printf("Add8x8"); return; |
| 311 | case Iop_Add16x4: vex_printf("Add16x4"); return; |
| 312 | case Iop_Add32x2: vex_printf("Add32x2"); return; |
| 313 | case Iop_QAdd8Ux8: vex_printf("QAdd8Ux8"); return; |
| 314 | case Iop_QAdd16Ux4: vex_printf("QAdd16Ux4"); return; |
| 315 | case Iop_QAdd8Sx8: vex_printf("QAdd8Sx8"); return; |
| 316 | case Iop_QAdd16Sx4: vex_printf("QAdd16Sx4"); return; |
| 317 | case Iop_Sub8x8: vex_printf("Sub8x8"); return; |
| 318 | case Iop_Sub16x4: vex_printf("Sub16x4"); return; |
| 319 | case Iop_Sub32x2: vex_printf("Sub32x2"); return; |
| 320 | case Iop_QSub8Ux8: vex_printf("QSub8Ux8"); return; |
| 321 | case Iop_QSub16Ux4: vex_printf("QSub16Ux4"); return; |
| 322 | case Iop_QSub8Sx8: vex_printf("QSub8Sx8"); return; |
| 323 | case Iop_QSub16Sx4: vex_printf("QSub16Sx4"); return; |
| 324 | case Iop_Mul16x4: vex_printf("Mul16x4"); return; |
| 325 | case Iop_MulHi16Ux4: vex_printf("MulHi16Ux4"); return; |
| 326 | case Iop_MulHi16Sx4: vex_printf("MulHi16Sx4"); return; |
| 327 | case Iop_Avg8Ux8: vex_printf("Avg8Ux8"); return; |
| 328 | case Iop_Avg16Ux4: vex_printf("Avg16Ux4"); return; |
| 329 | case Iop_Max16Sx4: vex_printf("Max16Sx4"); return; |
| 330 | case Iop_Max8Ux8: vex_printf("Max8Ux8"); return; |
| 331 | case Iop_Min16Sx4: vex_printf("Min16Sx4"); return; |
| 332 | case Iop_Min8Ux8: vex_printf("Min8Ux8"); return; |
| 333 | case Iop_CmpEQ8x8: vex_printf("CmpEQ8x8"); return; |
| 334 | case Iop_CmpEQ16x4: vex_printf("CmpEQ16x4"); return; |
| 335 | case Iop_CmpEQ32x2: vex_printf("CmpEQ32x2"); return; |
| 336 | case Iop_CmpGT8Sx8: vex_printf("CmpGT8Sx8"); return; |
| 337 | case Iop_CmpGT16Sx4: vex_printf("CmpGT16Sx4"); return; |
| 338 | case Iop_CmpGT32Sx2: vex_printf("CmpGT32Sx2"); return; |
| 339 | case Iop_ShlN16x4: vex_printf("ShlN16x4"); return; |
| 340 | case Iop_ShlN32x2: vex_printf("ShlN32x2"); return; |
| 341 | case Iop_ShrN16x4: vex_printf("ShrN16x4"); return; |
| 342 | case Iop_ShrN32x2: vex_printf("ShrN32x2"); return; |
| 343 | case Iop_SarN16x4: vex_printf("SarN16x4"); return; |
| 344 | case Iop_SarN32x2: vex_printf("SarN32x2"); return; |
| 345 | case Iop_QNarrow16Ux4: vex_printf("QNarrow16Ux4"); return; |
| 346 | case Iop_QNarrow16Sx4: vex_printf("QNarrow16Sx4"); return; |
| 347 | case Iop_QNarrow32Sx2: vex_printf("QNarrow32Sx2"); return; |
| 348 | case Iop_InterleaveHI8x8: vex_printf("InterleaveHI8x8"); return; |
| 349 | case Iop_InterleaveHI16x4: vex_printf("InterleaveHI16x4"); return; |
| 350 | case Iop_InterleaveHI32x2: vex_printf("InterleaveHI32x2"); return; |
| 351 | case Iop_InterleaveLO8x8: vex_printf("InterleaveLO8x8"); return; |
| 352 | case Iop_InterleaveLO16x4: vex_printf("InterleaveLO16x4"); return; |
| 353 | case Iop_InterleaveLO32x2: vex_printf("InterleaveLO32x2"); return; |
| 354 | |
sewardj | 1806918 | 2005-01-13 19:16:04 +0000 | [diff] [blame] | 355 | case Iop_CmpNEZ32x2: vex_printf("CmpNEZ32x2"); return; |
| 356 | case Iop_CmpNEZ16x4: vex_printf("CmpNEZ16x4"); return; |
| 357 | case Iop_CmpNEZ8x8: vex_printf("CmpNEZ8x8"); return; |
| 358 | |
sewardj | 1e6ad74 | 2004-12-02 16:16:11 +0000 | [diff] [blame] | 359 | case Iop_Add32Fx4: vex_printf("Add32Fx4"); return; |
| 360 | case Iop_Add32F0x4: vex_printf("Add32F0x4"); return; |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 361 | case Iop_Add64Fx2: vex_printf("Add64Fx2"); return; |
| 362 | case Iop_Add64F0x2: vex_printf("Add64F0x2"); return; |
sewardj | 1e6ad74 | 2004-12-02 16:16:11 +0000 | [diff] [blame] | 363 | |
sewardj | 176a59c | 2004-12-03 20:08:31 +0000 | [diff] [blame] | 364 | case Iop_Div32Fx4: vex_printf("Div32Fx4"); return; |
| 365 | case Iop_Div32F0x4: vex_printf("Div32F0x4"); return; |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 366 | case Iop_Div64Fx2: vex_printf("Div64Fx2"); return; |
| 367 | case Iop_Div64F0x2: vex_printf("Div64F0x2"); return; |
sewardj | 176a59c | 2004-12-03 20:08:31 +0000 | [diff] [blame] | 368 | |
| 369 | case Iop_Max32Fx4: vex_printf("Max32Fx4"); return; |
| 370 | case Iop_Max32F0x4: vex_printf("Max32F0x4"); return; |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 371 | case Iop_Max64Fx2: vex_printf("Max64Fx2"); return; |
| 372 | case Iop_Max64F0x2: vex_printf("Max64F0x2"); return; |
sewardj | 176a59c | 2004-12-03 20:08:31 +0000 | [diff] [blame] | 373 | |
| 374 | case Iop_Min32Fx4: vex_printf("Min32Fx4"); return; |
| 375 | case Iop_Min32F0x4: vex_printf("Min32F0x4"); return; |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 376 | case Iop_Min64Fx2: vex_printf("Min64Fx2"); return; |
| 377 | case Iop_Min64F0x2: vex_printf("Min64F0x2"); return; |
sewardj | 176a59c | 2004-12-03 20:08:31 +0000 | [diff] [blame] | 378 | |
sewardj | 9636b44 | 2004-12-04 01:38:37 +0000 | [diff] [blame] | 379 | case Iop_Mul32Fx4: vex_printf("Mul32Fx4"); return; |
| 380 | case Iop_Mul32F0x4: vex_printf("Mul32F0x4"); return; |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 381 | case Iop_Mul64Fx2: vex_printf("Mul64Fx2"); return; |
| 382 | case Iop_Mul64F0x2: vex_printf("Mul64F0x2"); return; |
sewardj | 9636b44 | 2004-12-04 01:38:37 +0000 | [diff] [blame] | 383 | |
sewardj | 0bd7ce6 | 2004-12-05 02:47:40 +0000 | [diff] [blame] | 384 | case Iop_Recip32Fx4: vex_printf("Recip32Fx4"); return; |
| 385 | case Iop_Recip32F0x4: vex_printf("Recip32F0x4"); return; |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 386 | case Iop_Recip64Fx2: vex_printf("Recip64Fx2"); return; |
| 387 | case Iop_Recip64F0x2: vex_printf("Recip64F0x2"); return; |
sewardj | 0bd7ce6 | 2004-12-05 02:47:40 +0000 | [diff] [blame] | 388 | |
sewardj | c1e7dfc | 2004-12-05 19:29:45 +0000 | [diff] [blame] | 389 | case Iop_RSqrt32Fx4: vex_printf("RSqrt32Fx4"); return; |
| 390 | case Iop_RSqrt32F0x4: vex_printf("RSqrt32F0x4"); return; |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 391 | case Iop_RSqrt64Fx2: vex_printf("RSqrt64Fx2"); return; |
| 392 | case Iop_RSqrt64F0x2: vex_printf("RSqrt64F0x2"); return; |
sewardj | c1e7dfc | 2004-12-05 19:29:45 +0000 | [diff] [blame] | 393 | |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 394 | case Iop_Sqrt32Fx4: vex_printf("Sqrt32Fx4"); return; |
| 395 | case Iop_Sqrt32F0x4: vex_printf("Sqrt32F0x4"); return; |
| 396 | case Iop_Sqrt64Fx2: vex_printf("Sqrt64Fx2"); return; |
| 397 | case Iop_Sqrt64F0x2: vex_printf("Sqrt64F0x2"); return; |
sewardj | c1e7dfc | 2004-12-05 19:29:45 +0000 | [diff] [blame] | 398 | |
| 399 | case Iop_Sub32Fx4: vex_printf("Sub32Fx4"); return; |
| 400 | case Iop_Sub32F0x4: vex_printf("Sub32F0x4"); return; |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 401 | case Iop_Sub64Fx2: vex_printf("Sub64Fx2"); return; |
| 402 | case Iop_Sub64F0x2: vex_printf("Sub64F0x2"); return; |
sewardj | c1e7dfc | 2004-12-05 19:29:45 +0000 | [diff] [blame] | 403 | |
sewardj | 1e6ad74 | 2004-12-02 16:16:11 +0000 | [diff] [blame] | 404 | case Iop_CmpEQ32Fx4: vex_printf("CmpEQ32Fx4"); return; |
| 405 | case Iop_CmpLT32Fx4: vex_printf("CmpLT32Fx4"); return; |
| 406 | case Iop_CmpLE32Fx4: vex_printf("CmpLE32Fx4"); return; |
cerion | 206c364 | 2005-11-14 00:35:59 +0000 | [diff] [blame] | 407 | case Iop_CmpGT32Fx4: vex_printf("CmpGT32Fx4"); return; |
| 408 | case Iop_CmpGE32Fx4: vex_printf("CmpGE32Fx4"); return; |
sewardj | 1e6ad74 | 2004-12-02 16:16:11 +0000 | [diff] [blame] | 409 | case Iop_CmpUN32Fx4: vex_printf("CmpUN32Fx4"); return; |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 410 | case Iop_CmpEQ64Fx2: vex_printf("CmpEQ64Fx2"); return; |
| 411 | case Iop_CmpLT64Fx2: vex_printf("CmpLT64Fx2"); return; |
| 412 | case Iop_CmpLE64Fx2: vex_printf("CmpLE64Fx2"); return; |
| 413 | case Iop_CmpUN64Fx2: vex_printf("CmpUN64Fx2"); return; |
sewardj | 1e6ad74 | 2004-12-02 16:16:11 +0000 | [diff] [blame] | 414 | |
| 415 | case Iop_CmpEQ32F0x4: vex_printf("CmpEQ32F0x4"); return; |
| 416 | case Iop_CmpLT32F0x4: vex_printf("CmpLT32F0x4"); return; |
| 417 | case Iop_CmpLE32F0x4: vex_printf("CmpLE32F0x4"); return; |
| 418 | case Iop_CmpUN32F0x4: vex_printf("CmpUN32F0x4"); return; |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 419 | case Iop_CmpEQ64F0x2: vex_printf("CmpEQ64F0x2"); return; |
| 420 | case Iop_CmpLT64F0x2: vex_printf("CmpLT64F0x2"); return; |
| 421 | case Iop_CmpLE64F0x2: vex_printf("CmpLE64F0x2"); return; |
| 422 | case Iop_CmpUN64F0x2: vex_printf("CmpUN64F0x2"); return; |
sewardj | c9a4366 | 2004-11-30 18:51:59 +0000 | [diff] [blame] | 423 | |
sewardj | f0c1c58 | 2005-02-07 23:47:38 +0000 | [diff] [blame] | 424 | case Iop_V128to64: vex_printf("V128to64"); return; |
| 425 | case Iop_V128HIto64: vex_printf("V128HIto64"); return; |
| 426 | case Iop_64HLtoV128: vex_printf("64HLtoV128"); return; |
sewardj | a0037df | 2004-12-10 18:56:29 +0000 | [diff] [blame] | 427 | |
sewardj | f0c1c58 | 2005-02-07 23:47:38 +0000 | [diff] [blame] | 428 | case Iop_64UtoV128: vex_printf("64UtoV128"); return; |
| 429 | case Iop_SetV128lo64: vex_printf("SetV128lo64"); return; |
sewardj | c9a4366 | 2004-11-30 18:51:59 +0000 | [diff] [blame] | 430 | |
sewardj | f0c1c58 | 2005-02-07 23:47:38 +0000 | [diff] [blame] | 431 | case Iop_32UtoV128: vex_printf("32UtoV128"); return; |
| 432 | case Iop_V128to32: vex_printf("V128to32"); return; |
| 433 | case Iop_SetV128lo32: vex_printf("SetV128lo32"); return; |
sewardj | 129b3d9 | 2004-12-05 15:42:05 +0000 | [diff] [blame] | 434 | |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 435 | case Iop_Dup8x16: vex_printf("Dup8x16"); return; |
| 436 | case Iop_Dup16x8: vex_printf("Dup16x8"); return; |
| 437 | case Iop_Dup32x4: vex_printf("Dup32x4"); return; |
| 438 | |
sewardj | f0c1c58 | 2005-02-07 23:47:38 +0000 | [diff] [blame] | 439 | case Iop_NotV128: vex_printf("NotV128"); return; |
| 440 | case Iop_AndV128: vex_printf("AndV128"); return; |
| 441 | case Iop_OrV128: vex_printf("OrV128"); return; |
| 442 | case Iop_XorV128: vex_printf("XorV128"); return; |
sewardj | 1806918 | 2005-01-13 19:16:04 +0000 | [diff] [blame] | 443 | |
sewardj | 2e38386 | 2004-12-12 16:46:47 +0000 | [diff] [blame] | 444 | case Iop_CmpNEZ8x16: vex_printf("CmpNEZ8x16"); return; |
| 445 | case Iop_CmpNEZ16x8: vex_printf("CmpNEZ16x8"); return; |
sewardj | 70f676d | 2004-12-10 14:59:57 +0000 | [diff] [blame] | 446 | case Iop_CmpNEZ32x4: vex_printf("CmpNEZ32x4"); return; |
sewardj | 109ffdb | 2004-12-10 21:45:38 +0000 | [diff] [blame] | 447 | case Iop_CmpNEZ64x2: vex_printf("CmpNEZ64x2"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 448 | |
| 449 | case Iop_Add8x16: vex_printf("Add8x16"); return; |
| 450 | case Iop_Add16x8: vex_printf("Add16x8"); return; |
| 451 | case Iop_Add32x4: vex_printf("Add32x4"); return; |
| 452 | case Iop_Add64x2: vex_printf("Add64x2"); return; |
| 453 | case Iop_QAdd8Ux16: vex_printf("QAdd8Ux16"); return; |
| 454 | case Iop_QAdd16Ux8: vex_printf("QAdd16Ux8"); return; |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 455 | case Iop_QAdd32Ux4: vex_printf("QAdd32Ux4"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 456 | case Iop_QAdd8Sx16: vex_printf("QAdd8Sx16"); return; |
| 457 | case Iop_QAdd16Sx8: vex_printf("QAdd16Sx8"); return; |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 458 | case Iop_QAdd32Sx4: vex_printf("QAdd32Sx4"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 459 | |
| 460 | case Iop_Sub8x16: vex_printf("Sub8x16"); return; |
| 461 | case Iop_Sub16x8: vex_printf("Sub16x8"); return; |
| 462 | case Iop_Sub32x4: vex_printf("Sub32x4"); return; |
| 463 | case Iop_Sub64x2: vex_printf("Sub64x2"); return; |
| 464 | case Iop_QSub8Ux16: vex_printf("QSub8Ux16"); return; |
| 465 | case Iop_QSub16Ux8: vex_printf("QSub16Ux8"); return; |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 466 | case Iop_QSub32Ux4: vex_printf("QSub32Ux4"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 467 | case Iop_QSub8Sx16: vex_printf("QSub8Sx16"); return; |
| 468 | case Iop_QSub16Sx8: vex_printf("QSub16Sx8"); return; |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 469 | case Iop_QSub32Sx4: vex_printf("QSub32Sx4"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 470 | |
| 471 | case Iop_Mul16x8: vex_printf("Mul16x8"); return; |
| 472 | case Iop_MulHi16Ux8: vex_printf("MulHi16Ux8"); return; |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 473 | case Iop_MulHi32Ux4: vex_printf("MulHi32Ux4"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 474 | case Iop_MulHi16Sx8: vex_printf("MulHi16Sx8"); return; |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 475 | case Iop_MulHi32Sx4: vex_printf("MulHi32Sx4"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 476 | |
cerion | 1ac656a | 2005-11-04 19:44:48 +0000 | [diff] [blame] | 477 | case Iop_MullEven8Ux16: vex_printf("MullEven8Ux16"); return; |
| 478 | case Iop_MullEven16Ux8: vex_printf("MullEven16Ux8"); return; |
| 479 | case Iop_MullEven8Sx16: vex_printf("MullEven8Sx16"); return; |
| 480 | case Iop_MullEven16Sx8: vex_printf("MullEven16Sx8"); return; |
| 481 | |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 482 | case Iop_Avg8Ux16: vex_printf("Avg8Ux16"); return; |
| 483 | case Iop_Avg16Ux8: vex_printf("Avg16Ux8"); return; |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 484 | case Iop_Avg32Ux4: vex_printf("Avg32Ux4"); return; |
| 485 | case Iop_Avg8Sx16: vex_printf("Avg8Sx16"); return; |
| 486 | case Iop_Avg16Sx8: vex_printf("Avg16Sx8"); return; |
| 487 | case Iop_Avg32Sx4: vex_printf("Avg32Sx4"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 488 | |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 489 | case Iop_Max8Sx16: vex_printf("Max8Sx16"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 490 | case Iop_Max16Sx8: vex_printf("Max16Sx8"); return; |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 491 | case Iop_Max32Sx4: vex_printf("Max32Sx4"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 492 | case Iop_Max8Ux16: vex_printf("Max8Ux16"); return; |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 493 | case Iop_Max16Ux8: vex_printf("Max16Ux8"); return; |
| 494 | case Iop_Max32Ux4: vex_printf("Max32Ux4"); return; |
| 495 | |
| 496 | case Iop_Min8Sx16: vex_printf("Min8Sx16"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 497 | case Iop_Min16Sx8: vex_printf("Min16Sx8"); return; |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 498 | case Iop_Min32Sx4: vex_printf("Min32Sx4"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 499 | case Iop_Min8Ux16: vex_printf("Min8Ux16"); return; |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 500 | case Iop_Min16Ux8: vex_printf("Min16Ux8"); return; |
| 501 | case Iop_Min32Ux4: vex_printf("Min32Ux4"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 502 | |
| 503 | case Iop_CmpEQ8x16: vex_printf("CmpEQ8x16"); return; |
| 504 | case Iop_CmpEQ16x8: vex_printf("CmpEQ16x8"); return; |
| 505 | case Iop_CmpEQ32x4: vex_printf("CmpEQ32x4"); return; |
| 506 | case Iop_CmpGT8Sx16: vex_printf("CmpGT8Sx16"); return; |
| 507 | case Iop_CmpGT16Sx8: vex_printf("CmpGT16Sx8"); return; |
| 508 | case Iop_CmpGT32Sx4: vex_printf("CmpGT32Sx4"); return; |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 509 | case Iop_CmpGT8Ux16: vex_printf("CmpGT8Ux16"); return; |
| 510 | case Iop_CmpGT16Ux8: vex_printf("CmpGT16Ux8"); return; |
| 511 | case Iop_CmpGT32Ux4: vex_printf("CmpGT32Ux4"); return; |
| 512 | |
| 513 | case Iop_ShlV128: vex_printf("ShlV128"); return; |
| 514 | case Iop_ShrV128: vex_printf("ShrV128"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 515 | |
cerion | 2a4b845 | 2005-09-15 16:28:36 +0000 | [diff] [blame] | 516 | case Iop_ShlN8x16: vex_printf("ShlN8x16"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 517 | case Iop_ShlN16x8: vex_printf("ShlN16x8"); return; |
| 518 | case Iop_ShlN32x4: vex_printf("ShlN32x4"); return; |
| 519 | case Iop_ShlN64x2: vex_printf("ShlN64x2"); return; |
cerion | 2a4b845 | 2005-09-15 16:28:36 +0000 | [diff] [blame] | 520 | case Iop_ShrN8x16: vex_printf("ShrN8x16"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 521 | case Iop_ShrN16x8: vex_printf("ShrN16x8"); return; |
| 522 | case Iop_ShrN32x4: vex_printf("ShrN32x4"); return; |
| 523 | case Iop_ShrN64x2: vex_printf("ShrN64x2"); return; |
cerion | 2a4b845 | 2005-09-15 16:28:36 +0000 | [diff] [blame] | 524 | case Iop_SarN8x16: vex_printf("SarN8x16"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 525 | case Iop_SarN16x8: vex_printf("SarN16x8"); return; |
| 526 | case Iop_SarN32x4: vex_printf("SarN32x4"); return; |
| 527 | |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 528 | case Iop_Shl8x16: vex_printf("Shl8x16"); return; |
| 529 | case Iop_Shl16x8: vex_printf("Shl16x8"); return; |
| 530 | case Iop_Shl32x4: vex_printf("Shl32x4"); return; |
| 531 | case Iop_Shr8x16: vex_printf("Shr8x16"); return; |
| 532 | case Iop_Shr16x8: vex_printf("Shr16x8"); return; |
| 533 | case Iop_Shr32x4: vex_printf("Shr32x4"); return; |
| 534 | case Iop_Sar8x16: vex_printf("Sar8x16"); return; |
| 535 | case Iop_Sar16x8: vex_printf("Sar16x8"); return; |
| 536 | case Iop_Sar32x4: vex_printf("Sar32x4"); return; |
sewardj | 1bee561 | 2005-11-10 18:10:58 +0000 | [diff] [blame] | 537 | case Iop_Rol8x16: vex_printf("Rol8x16"); return; |
| 538 | case Iop_Rol16x8: vex_printf("Rol16x8"); return; |
| 539 | case Iop_Rol32x4: vex_printf("Rol32x4"); return; |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 540 | |
sewardj | 1bee561 | 2005-11-10 18:10:58 +0000 | [diff] [blame] | 541 | case Iop_Narrow16x8: vex_printf("Narrow16x8"); return; |
| 542 | case Iop_Narrow32x4: vex_printf("Narrow32x4"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 543 | case Iop_QNarrow16Ux8: vex_printf("QNarrow16Ux8"); return; |
cerion | 9e7677b | 2005-09-13 17:25:41 +0000 | [diff] [blame] | 544 | case Iop_QNarrow32Ux4: vex_printf("QNarrow32Ux4"); return; |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 545 | case Iop_QNarrow16Sx8: vex_printf("QNarrow16Sx8"); return; |
| 546 | case Iop_QNarrow32Sx4: vex_printf("QNarrow32Sx4"); return; |
| 547 | |
| 548 | case Iop_InterleaveHI8x16: vex_printf("InterleaveHI8x16"); return; |
| 549 | case Iop_InterleaveHI16x8: vex_printf("InterleaveHI16x8"); return; |
| 550 | case Iop_InterleaveHI32x4: vex_printf("InterleaveHI32x4"); return; |
| 551 | case Iop_InterleaveHI64x2: vex_printf("InterleaveHI64x2"); return; |
| 552 | case Iop_InterleaveLO8x16: vex_printf("InterleaveLO8x16"); return; |
| 553 | case Iop_InterleaveLO16x8: vex_printf("InterleaveLO16x8"); return; |
| 554 | case Iop_InterleaveLO32x4: vex_printf("InterleaveLO32x4"); return; |
| 555 | case Iop_InterleaveLO64x2: vex_printf("InterleaveLO64x2"); return; |
| 556 | |
sewardj | dc1f913 | 2005-10-22 12:49:49 +0000 | [diff] [blame] | 557 | case Iop_Perm8x16: vex_printf("Perm8x16"); return; |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 558 | |
sewardj | c9a4366 | 2004-11-30 18:51:59 +0000 | [diff] [blame] | 559 | default: vpanic("ppIROp(1)"); |
sewardj | 41f43bc | 2004-07-08 14:23:22 +0000 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | switch (op - base) { |
| 563 | case 0: vex_printf(str); vex_printf("8"); break; |
| 564 | case 1: vex_printf(str); vex_printf("16"); break; |
| 565 | case 2: vex_printf(str); vex_printf("32"); break; |
| 566 | case 3: vex_printf(str); vex_printf("64"); break; |
| 567 | default: vpanic("ppIROp(2)"); |
| 568 | } |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 569 | } |
| 570 | |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 571 | void ppIRExpr ( IRExpr* e ) |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 572 | { |
sewardj | e87b484 | 2004-07-10 12:23:30 +0000 | [diff] [blame] | 573 | Int i; |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 574 | switch (e->tag) { |
sewardj | 443cd9d | 2004-07-18 23:06:45 +0000 | [diff] [blame] | 575 | case Iex_Binder: |
| 576 | vex_printf("BIND-%d", e->Iex.Binder.binder); |
| 577 | break; |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 578 | case Iex_Get: |
sewardj | c9a4366 | 2004-11-30 18:51:59 +0000 | [diff] [blame] | 579 | vex_printf( "GET:" ); |
sewardj | fbcaf33 | 2004-07-08 01:46:01 +0000 | [diff] [blame] | 580 | ppIRType(e->Iex.Get.ty); |
sewardj | c9a4366 | 2004-11-30 18:51:59 +0000 | [diff] [blame] | 581 | vex_printf("(%d)", e->Iex.Get.offset); |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 582 | break; |
sewardj | bb53f8c | 2004-08-14 11:50:01 +0000 | [diff] [blame] | 583 | case Iex_GetI: |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 584 | vex_printf( "GETI" ); |
| 585 | ppIRArray(e->Iex.GetI.descr); |
| 586 | vex_printf("["); |
sewardj | eeac841 | 2004-11-02 00:26:55 +0000 | [diff] [blame] | 587 | ppIRExpr(e->Iex.GetI.ix); |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 588 | vex_printf(",%d]", e->Iex.GetI.bias); |
sewardj | bb53f8c | 2004-08-14 11:50:01 +0000 | [diff] [blame] | 589 | break; |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 590 | case Iex_Tmp: |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 591 | ppIRTemp(e->Iex.Tmp.tmp); |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 592 | break; |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 593 | case Iex_Qop: |
| 594 | ppIROp(e->Iex.Qop.op); |
| 595 | vex_printf( "(" ); |
| 596 | ppIRExpr(e->Iex.Qop.arg1); |
| 597 | vex_printf( "," ); |
| 598 | ppIRExpr(e->Iex.Qop.arg2); |
| 599 | vex_printf( "," ); |
| 600 | ppIRExpr(e->Iex.Qop.arg3); |
| 601 | vex_printf( "," ); |
| 602 | ppIRExpr(e->Iex.Qop.arg4); |
| 603 | vex_printf( ")" ); |
| 604 | break; |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 605 | case Iex_Triop: |
| 606 | ppIROp(e->Iex.Triop.op); |
| 607 | vex_printf( "(" ); |
| 608 | ppIRExpr(e->Iex.Triop.arg1); |
| 609 | vex_printf( "," ); |
| 610 | ppIRExpr(e->Iex.Triop.arg2); |
| 611 | vex_printf( "," ); |
| 612 | ppIRExpr(e->Iex.Triop.arg3); |
| 613 | vex_printf( ")" ); |
| 614 | break; |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 615 | case Iex_Binop: |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 616 | ppIROp(e->Iex.Binop.op); |
| 617 | vex_printf( "(" ); |
| 618 | ppIRExpr(e->Iex.Binop.arg1); |
| 619 | vex_printf( "," ); |
| 620 | ppIRExpr(e->Iex.Binop.arg2); |
| 621 | vex_printf( ")" ); |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 622 | break; |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 623 | case Iex_Unop: |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 624 | ppIROp(e->Iex.Unop.op); |
| 625 | vex_printf( "(" ); |
| 626 | ppIRExpr(e->Iex.Unop.arg); |
| 627 | vex_printf( ")" ); |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 628 | break; |
sewardj | af1ceca | 2005-06-30 23:31:27 +0000 | [diff] [blame] | 629 | case Iex_Load: |
| 630 | vex_printf( "LD%s:", e->Iex.Load.end==Iend_LE ? "le" : "be" ); |
| 631 | ppIRType(e->Iex.Load.ty); |
sewardj | e05c42c | 2004-07-08 20:25:10 +0000 | [diff] [blame] | 632 | vex_printf( "(" ); |
sewardj | af1ceca | 2005-06-30 23:31:27 +0000 | [diff] [blame] | 633 | ppIRExpr(e->Iex.Load.addr); |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 634 | vex_printf( ")" ); |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 635 | break; |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 636 | case Iex_Const: |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 637 | ppIRConst(e->Iex.Const.con); |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 638 | break; |
sewardj | e87b484 | 2004-07-10 12:23:30 +0000 | [diff] [blame] | 639 | case Iex_CCall: |
sewardj | 8ea867b | 2004-10-30 19:03:02 +0000 | [diff] [blame] | 640 | ppIRCallee(e->Iex.CCall.cee); |
| 641 | vex_printf("("); |
sewardj | e87b484 | 2004-07-10 12:23:30 +0000 | [diff] [blame] | 642 | for (i = 0; e->Iex.CCall.args[i] != NULL; i++) { |
| 643 | ppIRExpr(e->Iex.CCall.args[i]); |
| 644 | if (e->Iex.CCall.args[i+1] != NULL) |
| 645 | vex_printf(","); |
| 646 | } |
| 647 | vex_printf("):"); |
| 648 | ppIRType(e->Iex.CCall.retty); |
| 649 | break; |
sewardj | 4042c7e | 2004-07-18 01:28:30 +0000 | [diff] [blame] | 650 | case Iex_Mux0X: |
| 651 | vex_printf("Mux0X("); |
| 652 | ppIRExpr(e->Iex.Mux0X.cond); |
sewardj | eeb9ef8 | 2004-07-15 12:39:03 +0000 | [diff] [blame] | 653 | vex_printf(","); |
sewardj | 4042c7e | 2004-07-18 01:28:30 +0000 | [diff] [blame] | 654 | ppIRExpr(e->Iex.Mux0X.expr0); |
sewardj | eeb9ef8 | 2004-07-15 12:39:03 +0000 | [diff] [blame] | 655 | vex_printf(","); |
sewardj | 4042c7e | 2004-07-18 01:28:30 +0000 | [diff] [blame] | 656 | ppIRExpr(e->Iex.Mux0X.exprX); |
sewardj | eeb9ef8 | 2004-07-15 12:39:03 +0000 | [diff] [blame] | 657 | vex_printf(")"); |
| 658 | break; |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 659 | default: |
sewardj | 909c06d | 2005-02-19 22:47:41 +0000 | [diff] [blame] | 660 | vpanic("ppIRExpr"); |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 661 | } |
| 662 | } |
| 663 | |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 664 | void ppIREffect ( IREffect fx ) |
| 665 | { |
| 666 | switch (fx) { |
| 667 | case Ifx_None: vex_printf("noFX"); return; |
| 668 | case Ifx_Read: vex_printf("RdFX"); return; |
| 669 | case Ifx_Write: vex_printf("WrFX"); return; |
| 670 | case Ifx_Modify: vex_printf("MoFX"); return; |
| 671 | default: vpanic("ppIREffect"); |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | void ppIRDirty ( IRDirty* d ) |
| 676 | { |
| 677 | Int i; |
sewardj | 92d168d | 2004-11-15 14:22:12 +0000 | [diff] [blame] | 678 | if (d->tmp != IRTemp_INVALID) { |
sewardj | 4b861de | 2004-11-03 15:24:42 +0000 | [diff] [blame] | 679 | ppIRTemp(d->tmp); |
| 680 | vex_printf(" = "); |
| 681 | } |
sewardj | b8385d8 | 2004-11-02 01:34:15 +0000 | [diff] [blame] | 682 | vex_printf("DIRTY "); |
| 683 | ppIRExpr(d->guard); |
sewardj | c5fc7aa | 2004-10-27 23:00:55 +0000 | [diff] [blame] | 684 | if (d->needsBBP) |
| 685 | vex_printf(" NeedsBBP"); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 686 | if (d->mFx != Ifx_None) { |
sewardj | 49651f4 | 2004-10-28 22:11:04 +0000 | [diff] [blame] | 687 | vex_printf(" "); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 688 | ppIREffect(d->mFx); |
| 689 | vex_printf("-mem("); |
| 690 | ppIRExpr(d->mAddr); |
sewardj | 49651f4 | 2004-10-28 22:11:04 +0000 | [diff] [blame] | 691 | vex_printf(",%d)", d->mSize); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 692 | } |
| 693 | for (i = 0; i < d->nFxState; i++) { |
sewardj | 49651f4 | 2004-10-28 22:11:04 +0000 | [diff] [blame] | 694 | vex_printf(" "); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 695 | ppIREffect(d->fxState[i].fx); |
sewardj | 49651f4 | 2004-10-28 22:11:04 +0000 | [diff] [blame] | 696 | vex_printf("-gst(%d,%d)", d->fxState[i].offset, d->fxState[i].size); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 697 | } |
sewardj | c5fc7aa | 2004-10-27 23:00:55 +0000 | [diff] [blame] | 698 | vex_printf(" ::: "); |
sewardj | 8ea867b | 2004-10-30 19:03:02 +0000 | [diff] [blame] | 699 | ppIRCallee(d->cee); |
| 700 | vex_printf("("); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 701 | for (i = 0; d->args[i] != NULL; i++) { |
| 702 | ppIRExpr(d->args[i]); |
| 703 | if (d->args[i+1] != NULL) { |
| 704 | vex_printf(","); |
| 705 | } |
| 706 | } |
| 707 | vex_printf(")"); |
| 708 | } |
| 709 | |
sewardj | 893aada | 2004-11-29 19:57:54 +0000 | [diff] [blame] | 710 | void ppIRJumpKind ( IRJumpKind kind ) |
| 711 | { |
| 712 | switch (kind) { |
sewardj | 4fa325a | 2005-11-03 13:27:24 +0000 | [diff] [blame] | 713 | case Ijk_Boring: vex_printf("Boring"); break; |
| 714 | case Ijk_Call: vex_printf("Call"); break; |
| 715 | case Ijk_Ret: vex_printf("Return"); break; |
| 716 | case Ijk_ClientReq: vex_printf("ClientReq"); break; |
| 717 | case Ijk_Yield: vex_printf("Yield"); break; |
| 718 | case Ijk_EmWarn: vex_printf("EmWarn"); break; |
sewardj | 9dd9cf1 | 2006-01-20 14:13:55 +0000 | [diff] [blame] | 719 | case Ijk_EmFail: vex_printf("EmFail"); break; |
sewardj | 4fa325a | 2005-11-03 13:27:24 +0000 | [diff] [blame] | 720 | case Ijk_NoDecode: vex_printf("NoDecode"); break; |
| 721 | case Ijk_MapFail: vex_printf("MapFail"); break; |
| 722 | case Ijk_TInval: vex_printf("Invalidate"); break; |
sewardj | ce02aa7 | 2006-01-12 12:27:58 +0000 | [diff] [blame] | 723 | case Ijk_NoRedir: vex_printf("NoRedir"); break; |
sewardj | 334870d | 2006-02-07 16:42:39 +0000 | [diff] [blame] | 724 | case Ijk_Trap: vex_printf("Trap"); break; |
sewardj | 4fa325a | 2005-11-03 13:27:24 +0000 | [diff] [blame] | 725 | case Ijk_Sys_syscall: vex_printf("Sys_syscall"); break; |
| 726 | case Ijk_Sys_int32: vex_printf("Sys_int32"); break; |
| 727 | case Ijk_Sys_int128: vex_printf("Sys_int128"); break; |
| 728 | case Ijk_Sys_sysenter: vex_printf("Sys_sysenter"); break; |
| 729 | default: vpanic("ppIRJumpKind"); |
sewardj | 893aada | 2004-11-29 19:57:54 +0000 | [diff] [blame] | 730 | } |
| 731 | } |
| 732 | |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 733 | void ppIRStmt ( IRStmt* s ) |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 734 | { |
sewardj | d2445f6 | 2005-03-21 00:15:53 +0000 | [diff] [blame] | 735 | if (!s) { |
| 736 | vex_printf("!!! IRStmt* which is NULL !!!"); |
| 737 | return; |
| 738 | } |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 739 | switch (s->tag) { |
sewardj | d2445f6 | 2005-03-21 00:15:53 +0000 | [diff] [blame] | 740 | case Ist_NoOp: |
| 741 | vex_printf("IR-NoOp"); |
| 742 | break; |
sewardj | f168931 | 2005-03-16 18:19:10 +0000 | [diff] [blame] | 743 | case Ist_IMark: |
sewardj | 0c12a27 | 2005-03-17 09:57:03 +0000 | [diff] [blame] | 744 | vex_printf( "------ IMark(0x%llx, %d) ------", |
| 745 | s->Ist.IMark.addr, s->Ist.IMark.len); |
sewardj | f168931 | 2005-03-16 18:19:10 +0000 | [diff] [blame] | 746 | break; |
sewardj | 5a9ffab | 2005-05-12 17:55:01 +0000 | [diff] [blame] | 747 | case Ist_AbiHint: |
| 748 | vex_printf("====== AbiHint("); |
| 749 | ppIRExpr(s->Ist.AbiHint.base); |
| 750 | vex_printf(", %d) ======", s->Ist.AbiHint.len); |
| 751 | break; |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 752 | case Ist_Put: |
| 753 | vex_printf( "PUT(%d) = ", s->Ist.Put.offset); |
sewardj | 6d07636 | 2004-09-23 11:06:17 +0000 | [diff] [blame] | 754 | ppIRExpr(s->Ist.Put.data); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 755 | break; |
| 756 | case Ist_PutI: |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 757 | vex_printf( "PUTI" ); |
| 758 | ppIRArray(s->Ist.PutI.descr); |
| 759 | vex_printf("["); |
sewardj | eeac841 | 2004-11-02 00:26:55 +0000 | [diff] [blame] | 760 | ppIRExpr(s->Ist.PutI.ix); |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 761 | vex_printf(",%d] = ", s->Ist.PutI.bias); |
| 762 | ppIRExpr(s->Ist.PutI.data); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 763 | break; |
| 764 | case Ist_Tmp: |
| 765 | ppIRTemp(s->Ist.Tmp.tmp); |
| 766 | vex_printf( " = " ); |
sewardj | 6d07636 | 2004-09-23 11:06:17 +0000 | [diff] [blame] | 767 | ppIRExpr(s->Ist.Tmp.data); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 768 | break; |
sewardj | af1ceca | 2005-06-30 23:31:27 +0000 | [diff] [blame] | 769 | case Ist_Store: |
| 770 | vex_printf( "ST%s(", s->Ist.Store.end==Iend_LE ? "le" : "be" ); |
| 771 | ppIRExpr(s->Ist.Store.addr); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 772 | vex_printf( ") = "); |
sewardj | af1ceca | 2005-06-30 23:31:27 +0000 | [diff] [blame] | 773 | ppIRExpr(s->Ist.Store.data); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 774 | break; |
| 775 | case Ist_Dirty: |
| 776 | ppIRDirty(s->Ist.Dirty.details); |
| 777 | break; |
sewardj | 3e83893 | 2005-01-07 12:09:15 +0000 | [diff] [blame] | 778 | case Ist_MFence: |
sewardj | d2445f6 | 2005-03-21 00:15:53 +0000 | [diff] [blame] | 779 | vex_printf("IR-MFence"); |
sewardj | 3e83893 | 2005-01-07 12:09:15 +0000 | [diff] [blame] | 780 | break; |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 781 | case Ist_Exit: |
| 782 | vex_printf( "if (" ); |
sewardj | 0276d4b | 2004-11-15 15:30:21 +0000 | [diff] [blame] | 783 | ppIRExpr(s->Ist.Exit.guard); |
sewardj | 893aada | 2004-11-29 19:57:54 +0000 | [diff] [blame] | 784 | vex_printf( ") goto {"); |
| 785 | ppIRJumpKind(s->Ist.Exit.jk); |
| 786 | vex_printf("} "); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 787 | ppIRConst(s->Ist.Exit.dst); |
| 788 | break; |
| 789 | default: |
| 790 | vpanic("ppIRStmt"); |
| 791 | } |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 792 | } |
| 793 | |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 794 | void ppIRTypeEnv ( IRTypeEnv* env ) { |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 795 | UInt i; |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 796 | for (i = 0; i < env->types_used; i++) { |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 797 | if (i % 8 == 0) |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 798 | vex_printf( " "); |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 799 | ppIRTemp(i); |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 800 | vex_printf( ":"); |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 801 | ppIRType(env->types[i]); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 802 | if (i % 8 == 7) |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 803 | vex_printf( "\n"); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 804 | else |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 805 | vex_printf( " "); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 806 | } |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 807 | if (env->types_used > 0 && env->types_used % 8 != 7) |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 808 | vex_printf( "\n"); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 809 | } |
| 810 | |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 811 | void ppIRBB ( IRBB* bb ) |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 812 | { |
sewardj | d7cb853 | 2004-08-17 23:59:23 +0000 | [diff] [blame] | 813 | Int i; |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 814 | vex_printf("IRBB {\n"); |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 815 | ppIRTypeEnv(bb->tyenv); |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 816 | vex_printf("\n"); |
sewardj | d7cb853 | 2004-08-17 23:59:23 +0000 | [diff] [blame] | 817 | for (i = 0; i < bb->stmts_used; i++) { |
sewardj | d2445f6 | 2005-03-21 00:15:53 +0000 | [diff] [blame] | 818 | vex_printf( " "); |
| 819 | ppIRStmt(bb->stmts[i]); |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 820 | vex_printf( "\n"); |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 821 | } |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 822 | vex_printf( " goto {"); |
| 823 | ppIRJumpKind(bb->jumpkind); |
| 824 | vex_printf( "} "); |
| 825 | ppIRExpr( bb->next ); |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 826 | vex_printf( "\n}\n"); |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 827 | } |
| 828 | |
| 829 | |
| 830 | /*---------------------------------------------------------------*/ |
| 831 | /*--- Constructors ---*/ |
| 832 | /*---------------------------------------------------------------*/ |
| 833 | |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 834 | |
| 835 | /* Constructors -- IRConst */ |
| 836 | |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 837 | IRConst* IRConst_U1 ( Bool bit ) |
sewardj | b8e7586 | 2004-08-19 17:58:45 +0000 | [diff] [blame] | 838 | { |
| 839 | IRConst* c = LibVEX_Alloc(sizeof(IRConst)); |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 840 | c->tag = Ico_U1; |
| 841 | c->Ico.U1 = bit; |
sewardj | 4b861de | 2004-11-03 15:24:42 +0000 | [diff] [blame] | 842 | /* call me paranoid; I don't care :-) */ |
| 843 | vassert(bit == False || bit == True); |
sewardj | b8e7586 | 2004-08-19 17:58:45 +0000 | [diff] [blame] | 844 | return c; |
| 845 | } |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 846 | IRConst* IRConst_U8 ( UChar u8 ) |
| 847 | { |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 848 | IRConst* c = LibVEX_Alloc(sizeof(IRConst)); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 849 | c->tag = Ico_U8; |
| 850 | c->Ico.U8 = u8; |
| 851 | return c; |
| 852 | } |
| 853 | IRConst* IRConst_U16 ( UShort u16 ) |
| 854 | { |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 855 | IRConst* c = LibVEX_Alloc(sizeof(IRConst)); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 856 | c->tag = Ico_U16; |
| 857 | c->Ico.U16 = u16; |
| 858 | return c; |
| 859 | } |
| 860 | IRConst* IRConst_U32 ( UInt u32 ) |
| 861 | { |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 862 | IRConst* c = LibVEX_Alloc(sizeof(IRConst)); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 863 | c->tag = Ico_U32; |
| 864 | c->Ico.U32 = u32; |
| 865 | return c; |
| 866 | } |
| 867 | IRConst* IRConst_U64 ( ULong u64 ) |
| 868 | { |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 869 | IRConst* c = LibVEX_Alloc(sizeof(IRConst)); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 870 | c->tag = Ico_U64; |
| 871 | c->Ico.U64 = u64; |
| 872 | return c; |
| 873 | } |
sewardj | a58ea66 | 2004-08-15 03:12:41 +0000 | [diff] [blame] | 874 | IRConst* IRConst_F64 ( Double f64 ) |
| 875 | { |
| 876 | IRConst* c = LibVEX_Alloc(sizeof(IRConst)); |
| 877 | c->tag = Ico_F64; |
| 878 | c->Ico.F64 = f64; |
| 879 | return c; |
| 880 | } |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 881 | IRConst* IRConst_F64i ( ULong f64i ) |
sewardj | 207557a | 2004-08-27 12:00:18 +0000 | [diff] [blame] | 882 | { |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 883 | IRConst* c = LibVEX_Alloc(sizeof(IRConst)); |
| 884 | c->tag = Ico_F64i; |
| 885 | c->Ico.F64i = f64i; |
sewardj | 207557a | 2004-08-27 12:00:18 +0000 | [diff] [blame] | 886 | return c; |
| 887 | } |
sewardj | 1e6ad74 | 2004-12-02 16:16:11 +0000 | [diff] [blame] | 888 | IRConst* IRConst_V128 ( UShort con ) |
| 889 | { |
| 890 | IRConst* c = LibVEX_Alloc(sizeof(IRConst)); |
| 891 | c->tag = Ico_V128; |
| 892 | c->Ico.V128 = con; |
| 893 | return c; |
| 894 | } |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 895 | |
sewardj | 8ea867b | 2004-10-30 19:03:02 +0000 | [diff] [blame] | 896 | /* Constructors -- IRCallee */ |
| 897 | |
sewardj | 2d49b43 | 2005-02-01 00:37:06 +0000 | [diff] [blame] | 898 | IRCallee* mkIRCallee ( Int regparms, HChar* name, void* addr ) |
sewardj | 8ea867b | 2004-10-30 19:03:02 +0000 | [diff] [blame] | 899 | { |
| 900 | IRCallee* ce = LibVEX_Alloc(sizeof(IRCallee)); |
sewardj | 7735254 | 2004-10-30 20:39:01 +0000 | [diff] [blame] | 901 | ce->regparms = regparms; |
| 902 | ce->name = name; |
| 903 | ce->addr = addr; |
sewardj | 43c5646 | 2004-11-06 12:17:57 +0000 | [diff] [blame] | 904 | ce->mcx_mask = 0; |
sewardj | 7735254 | 2004-10-30 20:39:01 +0000 | [diff] [blame] | 905 | vassert(regparms >= 0 && regparms <= 3); |
sewardj | 8ea867b | 2004-10-30 19:03:02 +0000 | [diff] [blame] | 906 | vassert(name != NULL); |
| 907 | vassert(addr != 0); |
| 908 | return ce; |
| 909 | } |
| 910 | |
| 911 | |
| 912 | /* Constructors -- IRArray */ |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 913 | |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 914 | IRArray* mkIRArray ( Int base, IRType elemTy, Int nElems ) |
| 915 | { |
| 916 | IRArray* arr = LibVEX_Alloc(sizeof(IRArray)); |
| 917 | arr->base = base; |
| 918 | arr->elemTy = elemTy; |
| 919 | arr->nElems = nElems; |
| 920 | vassert(!(arr->base < 0 || arr->base > 10000 /* somewhat arbitrary */)); |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 921 | vassert(!(arr->elemTy == Ity_I1)); |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 922 | vassert(!(arr->nElems <= 0 || arr->nElems > 500 /* somewhat arbitrary */)); |
| 923 | return arr; |
| 924 | } |
| 925 | |
| 926 | |
| 927 | /* Constructors -- IRExpr */ |
| 928 | |
sewardj | 443cd9d | 2004-07-18 23:06:45 +0000 | [diff] [blame] | 929 | IRExpr* IRExpr_Binder ( Int binder ) { |
| 930 | IRExpr* e = LibVEX_Alloc(sizeof(IRExpr)); |
| 931 | e->tag = Iex_Binder; |
| 932 | e->Iex.Binder.binder = binder; |
| 933 | return e; |
| 934 | } |
sewardj | fbcaf33 | 2004-07-08 01:46:01 +0000 | [diff] [blame] | 935 | IRExpr* IRExpr_Get ( Int off, IRType ty ) { |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 936 | IRExpr* e = LibVEX_Alloc(sizeof(IRExpr)); |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 937 | e->tag = Iex_Get; |
| 938 | e->Iex.Get.offset = off; |
sewardj | fbcaf33 | 2004-07-08 01:46:01 +0000 | [diff] [blame] | 939 | e->Iex.Get.ty = ty; |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 940 | return e; |
| 941 | } |
sewardj | eeac841 | 2004-11-02 00:26:55 +0000 | [diff] [blame] | 942 | IRExpr* IRExpr_GetI ( IRArray* descr, IRExpr* ix, Int bias ) { |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 943 | IRExpr* e = LibVEX_Alloc(sizeof(IRExpr)); |
| 944 | e->tag = Iex_GetI; |
| 945 | e->Iex.GetI.descr = descr; |
sewardj | eeac841 | 2004-11-02 00:26:55 +0000 | [diff] [blame] | 946 | e->Iex.GetI.ix = ix; |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 947 | e->Iex.GetI.bias = bias; |
sewardj | d1725d1 | 2004-08-12 20:46:53 +0000 | [diff] [blame] | 948 | return e; |
| 949 | } |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 950 | IRExpr* IRExpr_Tmp ( IRTemp tmp ) { |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 951 | IRExpr* e = LibVEX_Alloc(sizeof(IRExpr)); |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 952 | e->tag = Iex_Tmp; |
| 953 | e->Iex.Tmp.tmp = tmp; |
| 954 | return e; |
| 955 | } |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 956 | IRExpr* IRExpr_Qop ( IROp op, IRExpr* arg1, IRExpr* arg2, |
| 957 | IRExpr* arg3, IRExpr* arg4 ) { |
| 958 | IRExpr* e = LibVEX_Alloc(sizeof(IRExpr)); |
| 959 | e->tag = Iex_Qop; |
| 960 | e->Iex.Qop.op = op; |
| 961 | e->Iex.Qop.arg1 = arg1; |
| 962 | e->Iex.Qop.arg2 = arg2; |
| 963 | e->Iex.Qop.arg3 = arg3; |
| 964 | e->Iex.Qop.arg4 = arg4; |
| 965 | return e; |
| 966 | } |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 967 | IRExpr* IRExpr_Triop ( IROp op, IRExpr* arg1, |
| 968 | IRExpr* arg2, IRExpr* arg3 ) { |
| 969 | IRExpr* e = LibVEX_Alloc(sizeof(IRExpr)); |
| 970 | e->tag = Iex_Triop; |
| 971 | e->Iex.Triop.op = op; |
| 972 | e->Iex.Triop.arg1 = arg1; |
| 973 | e->Iex.Triop.arg2 = arg2; |
| 974 | e->Iex.Triop.arg3 = arg3; |
| 975 | return e; |
| 976 | } |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 977 | IRExpr* IRExpr_Binop ( IROp op, IRExpr* arg1, IRExpr* arg2 ) { |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 978 | IRExpr* e = LibVEX_Alloc(sizeof(IRExpr)); |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 979 | e->tag = Iex_Binop; |
| 980 | e->Iex.Binop.op = op; |
| 981 | e->Iex.Binop.arg1 = arg1; |
| 982 | e->Iex.Binop.arg2 = arg2; |
| 983 | return e; |
| 984 | } |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 985 | IRExpr* IRExpr_Unop ( IROp op, IRExpr* arg ) { |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 986 | IRExpr* e = LibVEX_Alloc(sizeof(IRExpr)); |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 987 | e->tag = Iex_Unop; |
| 988 | e->Iex.Unop.op = op; |
| 989 | e->Iex.Unop.arg = arg; |
| 990 | return e; |
| 991 | } |
sewardj | af1ceca | 2005-06-30 23:31:27 +0000 | [diff] [blame] | 992 | IRExpr* IRExpr_Load ( IREndness end, IRType ty, IRExpr* addr ) { |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 993 | IRExpr* e = LibVEX_Alloc(sizeof(IRExpr)); |
sewardj | af1ceca | 2005-06-30 23:31:27 +0000 | [diff] [blame] | 994 | e->tag = Iex_Load; |
| 995 | e->Iex.Load.end = end; |
| 996 | e->Iex.Load.ty = ty; |
| 997 | e->Iex.Load.addr = addr; |
| 998 | vassert(end == Iend_LE || end == Iend_BE); |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 999 | return e; |
| 1000 | } |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 1001 | IRExpr* IRExpr_Const ( IRConst* con ) { |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 1002 | IRExpr* e = LibVEX_Alloc(sizeof(IRExpr)); |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 1003 | e->tag = Iex_Const; |
| 1004 | e->Iex.Const.con = con; |
| 1005 | return e; |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 1006 | } |
sewardj | 8ea867b | 2004-10-30 19:03:02 +0000 | [diff] [blame] | 1007 | IRExpr* IRExpr_CCall ( IRCallee* cee, IRType retty, IRExpr** args ) { |
sewardj | e87b484 | 2004-07-10 12:23:30 +0000 | [diff] [blame] | 1008 | IRExpr* e = LibVEX_Alloc(sizeof(IRExpr)); |
| 1009 | e->tag = Iex_CCall; |
sewardj | 8ea867b | 2004-10-30 19:03:02 +0000 | [diff] [blame] | 1010 | e->Iex.CCall.cee = cee; |
sewardj | e87b484 | 2004-07-10 12:23:30 +0000 | [diff] [blame] | 1011 | e->Iex.CCall.retty = retty; |
| 1012 | e->Iex.CCall.args = args; |
| 1013 | return e; |
| 1014 | } |
sewardj | 4042c7e | 2004-07-18 01:28:30 +0000 | [diff] [blame] | 1015 | IRExpr* IRExpr_Mux0X ( IRExpr* cond, IRExpr* expr0, IRExpr* exprX ) { |
sewardj | eeb9ef8 | 2004-07-15 12:39:03 +0000 | [diff] [blame] | 1016 | IRExpr* e = LibVEX_Alloc(sizeof(IRExpr)); |
sewardj | 4042c7e | 2004-07-18 01:28:30 +0000 | [diff] [blame] | 1017 | e->tag = Iex_Mux0X; |
| 1018 | e->Iex.Mux0X.cond = cond; |
| 1019 | e->Iex.Mux0X.expr0 = expr0; |
| 1020 | e->Iex.Mux0X.exprX = exprX; |
sewardj | eeb9ef8 | 2004-07-15 12:39:03 +0000 | [diff] [blame] | 1021 | return e; |
| 1022 | } |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 1023 | |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 1024 | |
sewardj | c5fc7aa | 2004-10-27 23:00:55 +0000 | [diff] [blame] | 1025 | /* Constructors for NULL-terminated IRExpr expression vectors, |
| 1026 | suitable for use as arg lists in clean/dirty helper calls. */ |
| 1027 | |
| 1028 | IRExpr** mkIRExprVec_0 ( void ) { |
| 1029 | IRExpr** vec = LibVEX_Alloc(1 * sizeof(IRExpr*)); |
| 1030 | vec[0] = NULL; |
| 1031 | return vec; |
| 1032 | } |
| 1033 | IRExpr** mkIRExprVec_1 ( IRExpr* arg1 ) { |
| 1034 | IRExpr** vec = LibVEX_Alloc(2 * sizeof(IRExpr*)); |
| 1035 | vec[0] = arg1; |
| 1036 | vec[1] = NULL; |
| 1037 | return vec; |
| 1038 | } |
| 1039 | IRExpr** mkIRExprVec_2 ( IRExpr* arg1, IRExpr* arg2 ) { |
| 1040 | IRExpr** vec = LibVEX_Alloc(3 * sizeof(IRExpr*)); |
| 1041 | vec[0] = arg1; |
| 1042 | vec[1] = arg2; |
| 1043 | vec[2] = NULL; |
| 1044 | return vec; |
| 1045 | } |
sewardj | f965526 | 2004-10-31 20:02:16 +0000 | [diff] [blame] | 1046 | IRExpr** mkIRExprVec_3 ( IRExpr* arg1, IRExpr* arg2, IRExpr* arg3 ) { |
| 1047 | IRExpr** vec = LibVEX_Alloc(4 * sizeof(IRExpr*)); |
| 1048 | vec[0] = arg1; |
| 1049 | vec[1] = arg2; |
| 1050 | vec[2] = arg3; |
| 1051 | vec[3] = NULL; |
| 1052 | return vec; |
| 1053 | } |
| 1054 | IRExpr** mkIRExprVec_4 ( IRExpr* arg1, IRExpr* arg2, |
| 1055 | IRExpr* arg3, IRExpr* arg4 ) { |
| 1056 | IRExpr** vec = LibVEX_Alloc(5 * sizeof(IRExpr*)); |
| 1057 | vec[0] = arg1; |
| 1058 | vec[1] = arg2; |
| 1059 | vec[2] = arg3; |
| 1060 | vec[3] = arg4; |
| 1061 | vec[4] = NULL; |
| 1062 | return vec; |
| 1063 | } |
sewardj | f32c67d | 2004-11-08 13:10:44 +0000 | [diff] [blame] | 1064 | IRExpr** mkIRExprVec_5 ( IRExpr* arg1, IRExpr* arg2, |
| 1065 | IRExpr* arg3, IRExpr* arg4, IRExpr* arg5 ) { |
| 1066 | IRExpr** vec = LibVEX_Alloc(6 * sizeof(IRExpr*)); |
| 1067 | vec[0] = arg1; |
| 1068 | vec[1] = arg2; |
| 1069 | vec[2] = arg3; |
| 1070 | vec[3] = arg4; |
| 1071 | vec[4] = arg5; |
| 1072 | vec[5] = NULL; |
| 1073 | return vec; |
| 1074 | } |
sewardj | c5fc7aa | 2004-10-27 23:00:55 +0000 | [diff] [blame] | 1075 | |
| 1076 | |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1077 | /* Constructors -- IRDirty */ |
| 1078 | |
sewardj | c5fc7aa | 2004-10-27 23:00:55 +0000 | [diff] [blame] | 1079 | IRDirty* emptyIRDirty ( void ) { |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1080 | IRDirty* d = LibVEX_Alloc(sizeof(IRDirty)); |
sewardj | 8ea867b | 2004-10-30 19:03:02 +0000 | [diff] [blame] | 1081 | d->cee = NULL; |
sewardj | b8385d8 | 2004-11-02 01:34:15 +0000 | [diff] [blame] | 1082 | d->guard = NULL; |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1083 | d->args = NULL; |
sewardj | 92d168d | 2004-11-15 14:22:12 +0000 | [diff] [blame] | 1084 | d->tmp = IRTemp_INVALID; |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1085 | d->mFx = Ifx_None; |
| 1086 | d->mAddr = NULL; |
| 1087 | d->mSize = 0; |
sewardj | c5fc7aa | 2004-10-27 23:00:55 +0000 | [diff] [blame] | 1088 | d->needsBBP = False; |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1089 | d->nFxState = 0; |
| 1090 | return d; |
| 1091 | } |
| 1092 | |
| 1093 | |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 1094 | /* Constructors -- IRStmt */ |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 1095 | |
sewardj | d2445f6 | 2005-03-21 00:15:53 +0000 | [diff] [blame] | 1096 | IRStmt* IRStmt_NoOp ( void ) |
| 1097 | { |
| 1098 | /* Just use a single static closure. */ |
| 1099 | static IRStmt static_closure; |
| 1100 | static_closure.tag = Ist_NoOp; |
| 1101 | return &static_closure; |
| 1102 | } |
sewardj | f168931 | 2005-03-16 18:19:10 +0000 | [diff] [blame] | 1103 | IRStmt* IRStmt_IMark ( Addr64 addr, Int len ) { |
| 1104 | IRStmt* s = LibVEX_Alloc(sizeof(IRStmt)); |
| 1105 | s->tag = Ist_IMark; |
| 1106 | s->Ist.IMark.addr = addr; |
| 1107 | s->Ist.IMark.len = len; |
| 1108 | return s; |
| 1109 | } |
sewardj | 5a9ffab | 2005-05-12 17:55:01 +0000 | [diff] [blame] | 1110 | IRStmt* IRStmt_AbiHint ( IRExpr* base, Int len ) { |
| 1111 | IRStmt* s = LibVEX_Alloc(sizeof(IRStmt)); |
| 1112 | s->tag = Ist_AbiHint; |
| 1113 | s->Ist.AbiHint.base = base; |
| 1114 | s->Ist.AbiHint.len = len; |
| 1115 | return s; |
| 1116 | } |
sewardj | 6d07636 | 2004-09-23 11:06:17 +0000 | [diff] [blame] | 1117 | IRStmt* IRStmt_Put ( Int off, IRExpr* data ) { |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 1118 | IRStmt* s = LibVEX_Alloc(sizeof(IRStmt)); |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 1119 | s->tag = Ist_Put; |
| 1120 | s->Ist.Put.offset = off; |
sewardj | 6d07636 | 2004-09-23 11:06:17 +0000 | [diff] [blame] | 1121 | s->Ist.Put.data = data; |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 1122 | return s; |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 1123 | } |
sewardj | eeac841 | 2004-11-02 00:26:55 +0000 | [diff] [blame] | 1124 | IRStmt* IRStmt_PutI ( IRArray* descr, IRExpr* ix, |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 1125 | Int bias, IRExpr* data ) { |
| 1126 | IRStmt* s = LibVEX_Alloc(sizeof(IRStmt)); |
| 1127 | s->tag = Ist_PutI; |
| 1128 | s->Ist.PutI.descr = descr; |
sewardj | eeac841 | 2004-11-02 00:26:55 +0000 | [diff] [blame] | 1129 | s->Ist.PutI.ix = ix; |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 1130 | s->Ist.PutI.bias = bias; |
| 1131 | s->Ist.PutI.data = data; |
sewardj | d1725d1 | 2004-08-12 20:46:53 +0000 | [diff] [blame] | 1132 | return s; |
| 1133 | } |
sewardj | 6d07636 | 2004-09-23 11:06:17 +0000 | [diff] [blame] | 1134 | IRStmt* IRStmt_Tmp ( IRTemp tmp, IRExpr* data ) { |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 1135 | IRStmt* s = LibVEX_Alloc(sizeof(IRStmt)); |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 1136 | s->tag = Ist_Tmp; |
| 1137 | s->Ist.Tmp.tmp = tmp; |
sewardj | 6d07636 | 2004-09-23 11:06:17 +0000 | [diff] [blame] | 1138 | s->Ist.Tmp.data = data; |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 1139 | return s; |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 1140 | } |
sewardj | af1ceca | 2005-06-30 23:31:27 +0000 | [diff] [blame] | 1141 | IRStmt* IRStmt_Store ( IREndness end, IRExpr* addr, IRExpr* data ) { |
| 1142 | IRStmt* s = LibVEX_Alloc(sizeof(IRStmt)); |
| 1143 | s->tag = Ist_Store; |
| 1144 | s->Ist.Store.end = end; |
| 1145 | s->Ist.Store.addr = addr; |
| 1146 | s->Ist.Store.data = data; |
| 1147 | vassert(end == Iend_LE || end == Iend_BE); |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 1148 | return s; |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 1149 | } |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1150 | IRStmt* IRStmt_Dirty ( IRDirty* d ) |
| 1151 | { |
| 1152 | IRStmt* s = LibVEX_Alloc(sizeof(IRStmt)); |
| 1153 | s->tag = Ist_Dirty; |
| 1154 | s->Ist.Dirty.details = d; |
| 1155 | return s; |
| 1156 | } |
sewardj | 3e83893 | 2005-01-07 12:09:15 +0000 | [diff] [blame] | 1157 | IRStmt* IRStmt_MFence ( void ) |
| 1158 | { |
sewardj | d2445f6 | 2005-03-21 00:15:53 +0000 | [diff] [blame] | 1159 | /* Just use a single static closure. */ |
| 1160 | static IRStmt static_closure; |
| 1161 | static_closure.tag = Ist_MFence; |
| 1162 | return &static_closure; |
sewardj | 3e83893 | 2005-01-07 12:09:15 +0000 | [diff] [blame] | 1163 | } |
sewardj | 893aada | 2004-11-29 19:57:54 +0000 | [diff] [blame] | 1164 | IRStmt* IRStmt_Exit ( IRExpr* guard, IRJumpKind jk, IRConst* dst ) { |
sewardj | 0276d4b | 2004-11-15 15:30:21 +0000 | [diff] [blame] | 1165 | IRStmt* s = LibVEX_Alloc(sizeof(IRStmt)); |
| 1166 | s->tag = Ist_Exit; |
| 1167 | s->Ist.Exit.guard = guard; |
sewardj | 893aada | 2004-11-29 19:57:54 +0000 | [diff] [blame] | 1168 | s->Ist.Exit.jk = jk; |
sewardj | 0276d4b | 2004-11-15 15:30:21 +0000 | [diff] [blame] | 1169 | s->Ist.Exit.dst = dst; |
sewardj | 64e1d65 | 2004-07-12 14:00:46 +0000 | [diff] [blame] | 1170 | return s; |
| 1171 | } |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 1172 | |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1173 | |
| 1174 | /* Constructors -- IRTypeEnv */ |
| 1175 | |
| 1176 | IRTypeEnv* emptyIRTypeEnv ( void ) |
| 1177 | { |
| 1178 | IRTypeEnv* env = LibVEX_Alloc(sizeof(IRTypeEnv)); |
| 1179 | env->types = LibVEX_Alloc(8 * sizeof(IRType)); |
| 1180 | env->types_size = 8; |
| 1181 | env->types_used = 0; |
| 1182 | return env; |
| 1183 | } |
| 1184 | |
| 1185 | |
| 1186 | /* Constructors -- IRBB */ |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 1187 | |
sewardj | d7cb853 | 2004-08-17 23:59:23 +0000 | [diff] [blame] | 1188 | IRBB* emptyIRBB ( void ) |
| 1189 | { |
| 1190 | IRBB* bb = LibVEX_Alloc(sizeof(IRBB)); |
| 1191 | bb->tyenv = emptyIRTypeEnv(); |
| 1192 | bb->stmts_used = 0; |
| 1193 | bb->stmts_size = 8; |
| 1194 | bb->stmts = LibVEX_Alloc(bb->stmts_size * sizeof(IRStmt*)); |
| 1195 | bb->next = NULL; |
| 1196 | bb->jumpkind = Ijk_Boring; |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 1197 | return bb; |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 1198 | } |
| 1199 | |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1200 | |
| 1201 | /*---------------------------------------------------------------*/ |
| 1202 | /*--- (Deep) copy constructors. These make complete copies ---*/ |
| 1203 | /*--- the original, which can be modified without affecting ---*/ |
| 1204 | /*--- the original. ---*/ |
| 1205 | /*---------------------------------------------------------------*/ |
| 1206 | |
| 1207 | /* Copying IR Expr vectors (for call args). */ |
| 1208 | |
| 1209 | /* Shallow copy of an IRExpr vector */ |
| 1210 | |
| 1211 | IRExpr** sopyIRExprVec ( IRExpr** vec ) |
sewardj | d7cb853 | 2004-08-17 23:59:23 +0000 | [diff] [blame] | 1212 | { |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1213 | Int i; |
| 1214 | IRExpr** newvec; |
| 1215 | for (i = 0; vec[i]; i++) |
| 1216 | ; |
| 1217 | newvec = LibVEX_Alloc((i+1)*sizeof(IRExpr*)); |
| 1218 | for (i = 0; vec[i]; i++) |
| 1219 | newvec[i] = vec[i]; |
| 1220 | newvec[i] = NULL; |
| 1221 | return newvec; |
| 1222 | } |
| 1223 | |
| 1224 | /* Deep copy of an IRExpr vector */ |
| 1225 | |
| 1226 | IRExpr** dopyIRExprVec ( IRExpr** vec ) |
| 1227 | { |
| 1228 | Int i; |
| 1229 | IRExpr** newvec = sopyIRExprVec( vec ); |
| 1230 | for (i = 0; newvec[i]; i++) |
| 1231 | newvec[i] = dopyIRExpr(newvec[i]); |
| 1232 | return newvec; |
| 1233 | } |
| 1234 | |
| 1235 | /* Deep copy constructors for all heap-allocated IR types follow. */ |
| 1236 | |
| 1237 | IRConst* dopyIRConst ( IRConst* c ) |
| 1238 | { |
| 1239 | switch (c->tag) { |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 1240 | case Ico_U1: return IRConst_U1(c->Ico.U1); |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1241 | case Ico_U8: return IRConst_U8(c->Ico.U8); |
| 1242 | case Ico_U16: return IRConst_U16(c->Ico.U16); |
| 1243 | case Ico_U32: return IRConst_U32(c->Ico.U32); |
| 1244 | case Ico_U64: return IRConst_U64(c->Ico.U64); |
| 1245 | case Ico_F64: return IRConst_F64(c->Ico.F64); |
| 1246 | case Ico_F64i: return IRConst_F64i(c->Ico.F64i); |
sewardj | 1e6ad74 | 2004-12-02 16:16:11 +0000 | [diff] [blame] | 1247 | case Ico_V128: return IRConst_V128(c->Ico.V128); |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1248 | default: vpanic("dopyIRConst"); |
sewardj | d7cb853 | 2004-08-17 23:59:23 +0000 | [diff] [blame] | 1249 | } |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1250 | } |
| 1251 | |
sewardj | 8ea867b | 2004-10-30 19:03:02 +0000 | [diff] [blame] | 1252 | IRCallee* dopyIRCallee ( IRCallee* ce ) |
| 1253 | { |
sewardj | 43c5646 | 2004-11-06 12:17:57 +0000 | [diff] [blame] | 1254 | IRCallee* ce2 = mkIRCallee(ce->regparms, ce->name, ce->addr); |
| 1255 | ce2->mcx_mask = ce->mcx_mask; |
| 1256 | return ce2; |
sewardj | 8ea867b | 2004-10-30 19:03:02 +0000 | [diff] [blame] | 1257 | } |
| 1258 | |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1259 | IRArray* dopyIRArray ( IRArray* d ) |
| 1260 | { |
| 1261 | return mkIRArray(d->base, d->elemTy, d->nElems); |
| 1262 | } |
| 1263 | |
| 1264 | IRExpr* dopyIRExpr ( IRExpr* e ) |
| 1265 | { |
| 1266 | switch (e->tag) { |
| 1267 | case Iex_Get: |
| 1268 | return IRExpr_Get(e->Iex.Get.offset, e->Iex.Get.ty); |
| 1269 | case Iex_GetI: |
| 1270 | return IRExpr_GetI(dopyIRArray(e->Iex.GetI.descr), |
sewardj | eeac841 | 2004-11-02 00:26:55 +0000 | [diff] [blame] | 1271 | dopyIRExpr(e->Iex.GetI.ix), |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1272 | e->Iex.GetI.bias); |
| 1273 | case Iex_Tmp: |
| 1274 | return IRExpr_Tmp(e->Iex.Tmp.tmp); |
sewardj | 1a866b4 | 2006-02-09 02:54:03 +0000 | [diff] [blame^] | 1275 | case Iex_Qop: |
| 1276 | return IRExpr_Qop(e->Iex.Qop.op, |
| 1277 | dopyIRExpr(e->Iex.Qop.arg1), |
| 1278 | dopyIRExpr(e->Iex.Qop.arg2), |
| 1279 | dopyIRExpr(e->Iex.Qop.arg3), |
| 1280 | dopyIRExpr(e->Iex.Qop.arg4)); |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1281 | case Iex_Triop: |
| 1282 | return IRExpr_Triop(e->Iex.Triop.op, |
| 1283 | dopyIRExpr(e->Iex.Triop.arg1), |
| 1284 | dopyIRExpr(e->Iex.Triop.arg2), |
| 1285 | dopyIRExpr(e->Iex.Triop.arg3)); |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1286 | case Iex_Binop: |
| 1287 | return IRExpr_Binop(e->Iex.Binop.op, |
| 1288 | dopyIRExpr(e->Iex.Binop.arg1), |
| 1289 | dopyIRExpr(e->Iex.Binop.arg2)); |
| 1290 | case Iex_Unop: |
| 1291 | return IRExpr_Unop(e->Iex.Unop.op, |
| 1292 | dopyIRExpr(e->Iex.Unop.arg)); |
sewardj | af1ceca | 2005-06-30 23:31:27 +0000 | [diff] [blame] | 1293 | case Iex_Load: |
| 1294 | return IRExpr_Load(e->Iex.Load.end, |
| 1295 | e->Iex.Load.ty, |
| 1296 | dopyIRExpr(e->Iex.Load.addr)); |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1297 | case Iex_Const: |
| 1298 | return IRExpr_Const(dopyIRConst(e->Iex.Const.con)); |
| 1299 | case Iex_CCall: |
sewardj | 8ea867b | 2004-10-30 19:03:02 +0000 | [diff] [blame] | 1300 | return IRExpr_CCall(dopyIRCallee(e->Iex.CCall.cee), |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1301 | e->Iex.CCall.retty, |
| 1302 | dopyIRExprVec(e->Iex.CCall.args)); |
| 1303 | |
| 1304 | case Iex_Mux0X: |
| 1305 | return IRExpr_Mux0X(dopyIRExpr(e->Iex.Mux0X.cond), |
| 1306 | dopyIRExpr(e->Iex.Mux0X.expr0), |
| 1307 | dopyIRExpr(e->Iex.Mux0X.exprX)); |
| 1308 | default: |
| 1309 | vpanic("dopyIRExpr"); |
| 1310 | } |
| 1311 | } |
| 1312 | |
| 1313 | IRDirty* dopyIRDirty ( IRDirty* d ) |
| 1314 | { |
| 1315 | Int i; |
| 1316 | IRDirty* d2 = emptyIRDirty(); |
sewardj | 8ea867b | 2004-10-30 19:03:02 +0000 | [diff] [blame] | 1317 | d2->cee = dopyIRCallee(d->cee); |
sewardj | b8385d8 | 2004-11-02 01:34:15 +0000 | [diff] [blame] | 1318 | d2->guard = dopyIRExpr(d->guard); |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1319 | d2->args = dopyIRExprVec(d->args); |
| 1320 | d2->tmp = d->tmp; |
| 1321 | d2->mFx = d->mFx; |
| 1322 | d2->mAddr = d->mAddr==NULL ? NULL : dopyIRExpr(d->mAddr); |
| 1323 | d2->mSize = d->mSize; |
sewardj | c5fc7aa | 2004-10-27 23:00:55 +0000 | [diff] [blame] | 1324 | d2->needsBBP = d->needsBBP; |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1325 | d2->nFxState = d->nFxState; |
| 1326 | for (i = 0; i < d2->nFxState; i++) |
| 1327 | d2->fxState[i] = d->fxState[i]; |
| 1328 | return d2; |
| 1329 | } |
| 1330 | |
| 1331 | IRStmt* dopyIRStmt ( IRStmt* s ) |
| 1332 | { |
| 1333 | switch (s->tag) { |
sewardj | d2445f6 | 2005-03-21 00:15:53 +0000 | [diff] [blame] | 1334 | case Ist_NoOp: |
| 1335 | return IRStmt_NoOp(); |
sewardj | 5a9ffab | 2005-05-12 17:55:01 +0000 | [diff] [blame] | 1336 | case Ist_AbiHint: |
| 1337 | return IRStmt_AbiHint(dopyIRExpr(s->Ist.AbiHint.base), |
| 1338 | s->Ist.AbiHint.len); |
sewardj | f168931 | 2005-03-16 18:19:10 +0000 | [diff] [blame] | 1339 | case Ist_IMark: |
| 1340 | return IRStmt_IMark(s->Ist.IMark.addr, s->Ist.IMark.len); |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1341 | case Ist_Put: |
| 1342 | return IRStmt_Put(s->Ist.Put.offset, |
| 1343 | dopyIRExpr(s->Ist.Put.data)); |
| 1344 | case Ist_PutI: |
| 1345 | return IRStmt_PutI(dopyIRArray(s->Ist.PutI.descr), |
sewardj | eeac841 | 2004-11-02 00:26:55 +0000 | [diff] [blame] | 1346 | dopyIRExpr(s->Ist.PutI.ix), |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1347 | s->Ist.PutI.bias, |
| 1348 | dopyIRExpr(s->Ist.PutI.data)); |
| 1349 | case Ist_Tmp: |
| 1350 | return IRStmt_Tmp(s->Ist.Tmp.tmp, |
| 1351 | dopyIRExpr(s->Ist.Tmp.data)); |
sewardj | af1ceca | 2005-06-30 23:31:27 +0000 | [diff] [blame] | 1352 | case Ist_Store: |
| 1353 | return IRStmt_Store(s->Ist.Store.end, |
| 1354 | dopyIRExpr(s->Ist.Store.addr), |
| 1355 | dopyIRExpr(s->Ist.Store.data)); |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1356 | case Ist_Dirty: |
| 1357 | return IRStmt_Dirty(dopyIRDirty(s->Ist.Dirty.details)); |
sewardj | d2445f6 | 2005-03-21 00:15:53 +0000 | [diff] [blame] | 1358 | case Ist_MFence: |
| 1359 | return IRStmt_MFence(); |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1360 | case Ist_Exit: |
sewardj | 893aada | 2004-11-29 19:57:54 +0000 | [diff] [blame] | 1361 | return IRStmt_Exit(dopyIRExpr(s->Ist.Exit.guard), |
| 1362 | s->Ist.Exit.jk, |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1363 | dopyIRConst(s->Ist.Exit.dst)); |
| 1364 | default: |
| 1365 | vpanic("dopyIRStmt"); |
| 1366 | } |
| 1367 | } |
| 1368 | |
| 1369 | IRTypeEnv* dopyIRTypeEnv ( IRTypeEnv* src ) |
| 1370 | { |
| 1371 | Int i; |
| 1372 | IRTypeEnv* dst = LibVEX_Alloc(sizeof(IRTypeEnv)); |
| 1373 | dst->types_size = src->types_size; |
| 1374 | dst->types_used = src->types_used; |
| 1375 | dst->types = LibVEX_Alloc(dst->types_size * sizeof(IRType)); |
| 1376 | for (i = 0; i < src->types_used; i++) |
| 1377 | dst->types[i] = src->types[i]; |
| 1378 | return dst; |
| 1379 | } |
| 1380 | |
| 1381 | IRBB* dopyIRBB ( IRBB* bb ) |
| 1382 | { |
| 1383 | Int i; |
| 1384 | IRStmt** sts2; |
| 1385 | IRBB* bb2 = emptyIRBB(); |
| 1386 | bb2->tyenv = dopyIRTypeEnv(bb->tyenv); |
| 1387 | bb2->stmts_used = bb2->stmts_size = bb->stmts_used; |
| 1388 | sts2 = LibVEX_Alloc(bb2->stmts_used * sizeof(IRStmt*)); |
| 1389 | for (i = 0; i < bb2->stmts_used; i++) |
sewardj | d2445f6 | 2005-03-21 00:15:53 +0000 | [diff] [blame] | 1390 | sts2[i] = dopyIRStmt(bb->stmts[i]); |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1391 | bb2->stmts = sts2; |
| 1392 | bb2->next = dopyIRExpr(bb->next); |
| 1393 | bb2->jumpkind = bb->jumpkind; |
| 1394 | return bb2; |
sewardj | d7cb853 | 2004-08-17 23:59:23 +0000 | [diff] [blame] | 1395 | } |
| 1396 | |
sewardj | ec6ad59 | 2004-06-20 12:26:53 +0000 | [diff] [blame] | 1397 | |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 1398 | /*---------------------------------------------------------------*/ |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1399 | /*--- Primop types ---*/ |
| 1400 | /*---------------------------------------------------------------*/ |
| 1401 | |
| 1402 | static |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1403 | void typeOfPrimop ( IROp op, |
| 1404 | /*OUTs*/ |
| 1405 | IRType* t_dst, |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 1406 | IRType* t_arg1, IRType* t_arg2, |
| 1407 | IRType* t_arg3, IRType* t_arg4 ) |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1408 | { |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1409 | # define UNARY(_ta1,_td) \ |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1410 | *t_dst = (_td); *t_arg1 = (_ta1); break |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1411 | # define BINARY(_ta1,_ta2,_td) \ |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1412 | *t_dst = (_td); *t_arg1 = (_ta1); *t_arg2 = (_ta2); break |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1413 | # define TERNARY(_ta1,_ta2,_ta3,_td) \ |
| 1414 | *t_dst = (_td); *t_arg1 = (_ta1); \ |
| 1415 | *t_arg2 = (_ta2); *t_arg3 = (_ta3); break |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 1416 | # define QUATERNARY(_ta1,_ta2,_ta3,_ta4,_td) \ |
| 1417 | *t_dst = (_td); *t_arg1 = (_ta1); \ |
| 1418 | *t_arg2 = (_ta2); *t_arg3 = (_ta3); \ |
| 1419 | *t_arg4 = (_ta4); break |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1420 | # define COMPARISON(_ta) \ |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 1421 | *t_dst = Ity_I1; *t_arg1 = *t_arg2 = (_ta); break; |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1422 | # define UNARY_COMPARISON(_ta) \ |
sewardj | 0033ddc | 2005-04-26 23:34:34 +0000 | [diff] [blame] | 1423 | *t_dst = Ity_I1; *t_arg1 = (_ta); break; |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1424 | |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1425 | /* Rounding mode values are always Ity_I32, encoded as per |
| 1426 | IRRoundingMode */ |
| 1427 | const IRType ity_RMode = Ity_I32; |
| 1428 | |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1429 | *t_dst = Ity_INVALID; |
| 1430 | *t_arg1 = Ity_INVALID; |
| 1431 | *t_arg2 = Ity_INVALID; |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1432 | *t_arg3 = Ity_INVALID; |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 1433 | *t_arg4 = Ity_INVALID; |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1434 | switch (op) { |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1435 | case Iop_Add8: case Iop_Sub8: case Iop_Mul8: |
| 1436 | case Iop_Or8: case Iop_And8: case Iop_Xor8: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1437 | BINARY(Ity_I8,Ity_I8, Ity_I8); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1438 | |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1439 | case Iop_Add16: case Iop_Sub16: case Iop_Mul16: |
| 1440 | case Iop_Or16: case Iop_And16: case Iop_Xor16: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1441 | BINARY(Ity_I16,Ity_I16, Ity_I16); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1442 | |
sewardj | b51f0f4 | 2005-07-18 11:38:02 +0000 | [diff] [blame] | 1443 | case Iop_CmpORD32U: |
| 1444 | case Iop_CmpORD32S: |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1445 | case Iop_Add32: case Iop_Sub32: case Iop_Mul32: |
| 1446 | case Iop_Or32: case Iop_And32: case Iop_Xor32: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1447 | BINARY(Ity_I32,Ity_I32, Ity_I32); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1448 | |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1449 | case Iop_Add64: case Iop_Sub64: case Iop_Mul64: |
| 1450 | case Iop_Or64: case Iop_And64: case Iop_Xor64: |
cerion | 2831b00 | 2005-11-30 19:55:22 +0000 | [diff] [blame] | 1451 | case Iop_CmpORD64U: |
| 1452 | case Iop_CmpORD64S: |
sewardj | 38a3f86 | 2005-01-13 15:06:51 +0000 | [diff] [blame] | 1453 | case Iop_Avg8Ux8: case Iop_Avg16Ux4: |
| 1454 | case Iop_Add8x8: case Iop_Add16x4: case Iop_Add32x2: |
| 1455 | case Iop_CmpEQ8x8: case Iop_CmpEQ16x4: case Iop_CmpEQ32x2: |
| 1456 | case Iop_CmpGT8Sx8: case Iop_CmpGT16Sx4: case Iop_CmpGT32Sx2: |
| 1457 | case Iop_InterleaveHI8x8: case Iop_InterleaveLO8x8: |
| 1458 | case Iop_InterleaveHI16x4: case Iop_InterleaveLO16x4: |
| 1459 | case Iop_InterleaveHI32x2: case Iop_InterleaveLO32x2: |
| 1460 | case Iop_Max8Ux8: case Iop_Max16Sx4: |
| 1461 | case Iop_Min8Ux8: case Iop_Min16Sx4: |
| 1462 | case Iop_Mul16x4: case Iop_MulHi16Sx4: case Iop_MulHi16Ux4: |
| 1463 | case Iop_QAdd8Sx8: case Iop_QAdd16Sx4: |
| 1464 | case Iop_QAdd8Ux8: case Iop_QAdd16Ux4: |
| 1465 | case Iop_QNarrow32Sx2: |
| 1466 | case Iop_QNarrow16Sx4: case Iop_QNarrow16Ux4: |
| 1467 | case Iop_Sub8x8: case Iop_Sub16x4: case Iop_Sub32x2: |
| 1468 | case Iop_QSub8Sx8: case Iop_QSub16Sx4: |
| 1469 | case Iop_QSub8Ux8: case Iop_QSub16Ux4: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1470 | BINARY(Ity_I64,Ity_I64, Ity_I64); |
sewardj | 38a3f86 | 2005-01-13 15:06:51 +0000 | [diff] [blame] | 1471 | |
| 1472 | case Iop_ShlN32x2: case Iop_ShlN16x4: |
| 1473 | case Iop_ShrN32x2: case Iop_ShrN16x4: |
| 1474 | case Iop_SarN32x2: case Iop_SarN16x4: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1475 | BINARY(Ity_I64,Ity_I8, Ity_I64); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1476 | |
| 1477 | case Iop_Shl8: case Iop_Shr8: case Iop_Sar8: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1478 | BINARY(Ity_I8,Ity_I8, Ity_I8); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1479 | case Iop_Shl16: case Iop_Shr16: case Iop_Sar16: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1480 | BINARY(Ity_I16,Ity_I8, Ity_I16); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1481 | case Iop_Shl32: case Iop_Shr32: case Iop_Sar32: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1482 | BINARY(Ity_I32,Ity_I8, Ity_I32); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1483 | case Iop_Shl64: case Iop_Shr64: case Iop_Sar64: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1484 | BINARY(Ity_I64,Ity_I8, Ity_I64); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1485 | |
sewardj | 0033ddc | 2005-04-26 23:34:34 +0000 | [diff] [blame] | 1486 | case Iop_Not8: case Iop_Neg8: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1487 | UNARY(Ity_I8, Ity_I8); |
sewardj | 0033ddc | 2005-04-26 23:34:34 +0000 | [diff] [blame] | 1488 | case Iop_Not16: case Iop_Neg16: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1489 | UNARY(Ity_I16, Ity_I16); |
sewardj | 0033ddc | 2005-04-26 23:34:34 +0000 | [diff] [blame] | 1490 | case Iop_Not32: case Iop_Neg32: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1491 | UNARY(Ity_I32, Ity_I32); |
sewardj | 1806918 | 2005-01-13 19:16:04 +0000 | [diff] [blame] | 1492 | |
sewardj | 0033ddc | 2005-04-26 23:34:34 +0000 | [diff] [blame] | 1493 | case Iop_Neg64: |
| 1494 | case Iop_Not64: |
sewardj | 1806918 | 2005-01-13 19:16:04 +0000 | [diff] [blame] | 1495 | case Iop_CmpNEZ32x2: case Iop_CmpNEZ16x4: case Iop_CmpNEZ8x8: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1496 | UNARY(Ity_I64, Ity_I64); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1497 | |
| 1498 | case Iop_CmpEQ8: case Iop_CmpNE8: |
| 1499 | COMPARISON(Ity_I8); |
| 1500 | case Iop_CmpEQ16: case Iop_CmpNE16: |
| 1501 | COMPARISON(Ity_I16); |
| 1502 | case Iop_CmpEQ32: case Iop_CmpNE32: |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1503 | case Iop_CmpLT32S: case Iop_CmpLE32S: |
| 1504 | case Iop_CmpLT32U: case Iop_CmpLE32U: |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1505 | COMPARISON(Ity_I32); |
| 1506 | case Iop_CmpEQ64: case Iop_CmpNE64: |
sewardj | 9854007 | 2005-04-26 01:52:01 +0000 | [diff] [blame] | 1507 | case Iop_CmpLT64S: case Iop_CmpLE64S: |
| 1508 | case Iop_CmpLT64U: case Iop_CmpLE64U: |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1509 | COMPARISON(Ity_I64); |
| 1510 | |
sewardj | 0033ddc | 2005-04-26 23:34:34 +0000 | [diff] [blame] | 1511 | case Iop_CmpNEZ8: UNARY_COMPARISON(Ity_I8); |
| 1512 | case Iop_CmpNEZ16: UNARY_COMPARISON(Ity_I16); |
| 1513 | case Iop_CmpNEZ32: UNARY_COMPARISON(Ity_I32); |
| 1514 | case Iop_CmpNEZ64: UNARY_COMPARISON(Ity_I64); |
| 1515 | |
sewardj | b81f8b3 | 2004-07-30 10:17:50 +0000 | [diff] [blame] | 1516 | case Iop_MullU8: case Iop_MullS8: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1517 | BINARY(Ity_I8,Ity_I8, Ity_I16); |
sewardj | b81f8b3 | 2004-07-30 10:17:50 +0000 | [diff] [blame] | 1518 | case Iop_MullU16: case Iop_MullS16: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1519 | BINARY(Ity_I16,Ity_I16, Ity_I32); |
sewardj | 6d2638e | 2004-07-15 09:38:27 +0000 | [diff] [blame] | 1520 | case Iop_MullU32: case Iop_MullS32: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1521 | BINARY(Ity_I32,Ity_I32, Ity_I64); |
sewardj | 9b96767 | 2005-02-08 11:13:09 +0000 | [diff] [blame] | 1522 | case Iop_MullU64: case Iop_MullS64: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1523 | BINARY(Ity_I64,Ity_I64, Ity_I128); |
sewardj | 6d2638e | 2004-07-15 09:38:27 +0000 | [diff] [blame] | 1524 | |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1525 | case Iop_Clz32: case Iop_Ctz32: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1526 | UNARY(Ity_I32, Ity_I32); |
sewardj | ce646f2 | 2004-08-31 23:55:54 +0000 | [diff] [blame] | 1527 | |
sewardj | f53b735 | 2005-04-06 20:01:56 +0000 | [diff] [blame] | 1528 | case Iop_Clz64: case Iop_Ctz64: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1529 | UNARY(Ity_I64, Ity_I64); |
sewardj | f53b735 | 2005-04-06 20:01:56 +0000 | [diff] [blame] | 1530 | |
cerion | 5c8a0cb | 2005-02-03 13:59:46 +0000 | [diff] [blame] | 1531 | case Iop_DivU32: case Iop_DivS32: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1532 | BINARY(Ity_I32,Ity_I32, Ity_I32); |
cerion | 5c8a0cb | 2005-02-03 13:59:46 +0000 | [diff] [blame] | 1533 | |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 1534 | case Iop_DivU64: case Iop_DivS64: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1535 | BINARY(Ity_I64,Ity_I64, Ity_I64); |
cerion | f0de28c | 2005-12-13 20:21:11 +0000 | [diff] [blame] | 1536 | |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1537 | case Iop_DivModU64to32: case Iop_DivModS64to32: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1538 | BINARY(Ity_I64,Ity_I32, Ity_I64); |
sewardj | 6d2638e | 2004-07-15 09:38:27 +0000 | [diff] [blame] | 1539 | |
sewardj | 343b9d0 | 2005-01-31 18:08:45 +0000 | [diff] [blame] | 1540 | case Iop_DivModU128to64: case Iop_DivModS128to64: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1541 | BINARY(Ity_I128,Ity_I64, Ity_I128); |
sewardj | 343b9d0 | 2005-01-31 18:08:45 +0000 | [diff] [blame] | 1542 | |
sewardj | b81f8b3 | 2004-07-30 10:17:50 +0000 | [diff] [blame] | 1543 | case Iop_16HIto8: case Iop_16to8: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1544 | UNARY(Ity_I16, Ity_I8); |
sewardj | b81f8b3 | 2004-07-30 10:17:50 +0000 | [diff] [blame] | 1545 | case Iop_8HLto16: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1546 | BINARY(Ity_I8,Ity_I8, Ity_I16); |
sewardj | b81f8b3 | 2004-07-30 10:17:50 +0000 | [diff] [blame] | 1547 | |
sewardj | 8c7f1ab | 2004-07-29 20:31:09 +0000 | [diff] [blame] | 1548 | case Iop_32HIto16: case Iop_32to16: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1549 | UNARY(Ity_I32, Ity_I16); |
sewardj | 8c7f1ab | 2004-07-29 20:31:09 +0000 | [diff] [blame] | 1550 | case Iop_16HLto32: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1551 | BINARY(Ity_I16,Ity_I16, Ity_I32); |
sewardj | 8c7f1ab | 2004-07-29 20:31:09 +0000 | [diff] [blame] | 1552 | |
| 1553 | case Iop_64HIto32: case Iop_64to32: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1554 | UNARY(Ity_I64, Ity_I32); |
sewardj | 6d2638e | 2004-07-15 09:38:27 +0000 | [diff] [blame] | 1555 | case Iop_32HLto64: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1556 | BINARY(Ity_I32,Ity_I32, Ity_I64); |
sewardj | 6d2638e | 2004-07-15 09:38:27 +0000 | [diff] [blame] | 1557 | |
sewardj | 9b96767 | 2005-02-08 11:13:09 +0000 | [diff] [blame] | 1558 | case Iop_128HIto64: case Iop_128to64: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1559 | UNARY(Ity_I128, Ity_I64); |
sewardj | 9b96767 | 2005-02-08 11:13:09 +0000 | [diff] [blame] | 1560 | case Iop_64HLto128: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1561 | BINARY(Ity_I64,Ity_I64, Ity_I128); |
sewardj | 9b96767 | 2005-02-08 11:13:09 +0000 | [diff] [blame] | 1562 | |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1563 | case Iop_Not1: UNARY(Ity_I1, Ity_I1); |
| 1564 | case Iop_1Uto8: UNARY(Ity_I1, Ity_I8); |
| 1565 | case Iop_1Sto8: UNARY(Ity_I1, Ity_I8); |
| 1566 | case Iop_1Sto16: UNARY(Ity_I1, Ity_I16); |
| 1567 | case Iop_1Uto32: case Iop_1Sto32: UNARY(Ity_I1, Ity_I32); |
| 1568 | case Iop_1Sto64: case Iop_1Uto64: UNARY(Ity_I1, Ity_I64); |
| 1569 | case Iop_32to1: UNARY(Ity_I32, Ity_I1); |
| 1570 | case Iop_64to1: UNARY(Ity_I64, Ity_I1); |
sewardj | 4734104 | 2004-09-19 11:55:46 +0000 | [diff] [blame] | 1571 | |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1572 | case Iop_8Uto32: case Iop_8Sto32: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1573 | UNARY(Ity_I8, Ity_I32); |
sewardj | 4734104 | 2004-09-19 11:55:46 +0000 | [diff] [blame] | 1574 | |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1575 | case Iop_8Uto16: case Iop_8Sto16: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1576 | UNARY(Ity_I8, Ity_I16); |
sewardj | 4734104 | 2004-09-19 11:55:46 +0000 | [diff] [blame] | 1577 | |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1578 | case Iop_16Uto32: case Iop_16Sto32: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1579 | UNARY(Ity_I16, Ity_I32); |
sewardj | 6d2638e | 2004-07-15 09:38:27 +0000 | [diff] [blame] | 1580 | |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1581 | case Iop_32Sto64: case Iop_32Uto64: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1582 | UNARY(Ity_I32, Ity_I64); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1583 | |
sewardj | 291a7e8 | 2005-04-27 11:42:44 +0000 | [diff] [blame] | 1584 | case Iop_8Uto64: case Iop_8Sto64: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1585 | UNARY(Ity_I8, Ity_I64); |
sewardj | 291a7e8 | 2005-04-27 11:42:44 +0000 | [diff] [blame] | 1586 | |
| 1587 | case Iop_16Uto64: case Iop_16Sto64: |
sewardj | 291a7e8 | 2005-04-27 11:42:44 +0000 | [diff] [blame] | 1588 | UNARY(Ity_I16, Ity_I64); |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1589 | case Iop_64to16: |
| 1590 | UNARY(Ity_I64, Ity_I16); |
sewardj | 291a7e8 | 2005-04-27 11:42:44 +0000 | [diff] [blame] | 1591 | |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1592 | case Iop_32to8: UNARY(Ity_I32, Ity_I8); |
| 1593 | case Iop_64to8: UNARY(Ity_I64, Ity_I8); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1594 | |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1595 | case Iop_AddF64: case Iop_SubF64: |
| 1596 | case Iop_MulF64: case Iop_DivF64: |
| 1597 | case Iop_AddF64r32: case Iop_SubF64r32: |
| 1598 | case Iop_MulF64r32: case Iop_DivF64r32: |
| 1599 | TERNARY(ity_RMode,Ity_F64,Ity_F64, Ity_F64); |
| 1600 | |
| 1601 | case Iop_NegF64: case Iop_AbsF64: |
| 1602 | UNARY(Ity_F64, Ity_F64); |
| 1603 | |
| 1604 | case Iop_SqrtF64: |
| 1605 | case Iop_SqrtF64r32: |
| 1606 | BINARY(ity_RMode,Ity_F64, Ity_F64); |
| 1607 | |
sewardj | bdc7d21 | 2004-09-09 02:46:40 +0000 | [diff] [blame] | 1608 | case Iop_CmpF64: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1609 | BINARY(Ity_F64,Ity_F64, Ity_I32); |
sewardj | 8f3debf | 2004-09-08 23:42:23 +0000 | [diff] [blame] | 1610 | |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1611 | case Iop_F64toI16: BINARY(ity_RMode,Ity_F64, Ity_I16); |
| 1612 | case Iop_F64toI32: BINARY(ity_RMode,Ity_F64, Ity_I32); |
| 1613 | case Iop_F64toI64: BINARY(ity_RMode,Ity_F64, Ity_I64); |
sewardj | 8f3debf | 2004-09-08 23:42:23 +0000 | [diff] [blame] | 1614 | |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1615 | case Iop_I16toF64: UNARY(Ity_I16, Ity_F64); |
| 1616 | case Iop_I32toF64: UNARY(Ity_I32, Ity_F64); |
| 1617 | case Iop_I64toF64: BINARY(ity_RMode,Ity_I64, Ity_F64); |
sewardj | 3bca906 | 2004-12-04 14:36:09 +0000 | [diff] [blame] | 1618 | |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1619 | case Iop_F32toF64: UNARY(Ity_F32, Ity_F64); |
| 1620 | case Iop_F64toF32: BINARY(ity_RMode,Ity_F64, Ity_F32); |
sewardj | 4cb918d | 2004-12-03 19:43:31 +0000 | [diff] [blame] | 1621 | |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1622 | case Iop_ReinterpI64asF64: UNARY(Ity_I64, Ity_F64); |
| 1623 | case Iop_ReinterpF64asI64: UNARY(Ity_F64, Ity_I64); |
| 1624 | case Iop_ReinterpI32asF32: UNARY(Ity_I32, Ity_F32); |
sewardj | 8f3debf | 2004-09-08 23:42:23 +0000 | [diff] [blame] | 1625 | |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1626 | case Iop_AtanF64: case Iop_Yl2xF64: case Iop_Yl2xp1F64: |
| 1627 | case Iop_ScaleF64: case Iop_PRemF64: case Iop_PRem1F64: |
| 1628 | TERNARY(ity_RMode,Ity_F64,Ity_F64, Ity_F64); |
| 1629 | |
| 1630 | case Iop_PRemC3210F64: case Iop_PRem1C3210F64: |
| 1631 | TERNARY(ity_RMode,Ity_F64,Ity_F64, Ity_I32); |
| 1632 | |
| 1633 | case Iop_SinF64: case Iop_CosF64: case Iop_TanF64: |
| 1634 | case Iop_2xm1F64: |
| 1635 | case Iop_RoundF64toInt: BINARY(ity_RMode,Ity_F64, Ity_F64); |
| 1636 | |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 1637 | case Iop_MAddF64: case Iop_MSubF64: |
| 1638 | case Iop_MAddF64r32: case Iop_MSubF64r32: |
| 1639 | QUATERNARY(ity_RMode,Ity_F64,Ity_F64,Ity_F64, Ity_F64); |
| 1640 | |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1641 | case Iop_Est5FRSqrt: |
| 1642 | UNARY(Ity_F64, Ity_F64); |
| 1643 | case Iop_RoundF64toF32: |
| 1644 | BINARY(ity_RMode,Ity_F64, Ity_F64); |
| 1645 | case Iop_CalcFPRF: |
| 1646 | UNARY(Ity_F64, Ity_I32); |
| 1647 | case Iop_TruncF64asF32: |
| 1648 | UNARY(Ity_F64, Ity_F32); |
sewardj | bb53f8c | 2004-08-14 11:50:01 +0000 | [diff] [blame] | 1649 | |
cerion | f294eb3 | 2005-11-16 17:21:10 +0000 | [diff] [blame] | 1650 | case Iop_I32UtoFx4: |
| 1651 | case Iop_I32StoFx4: |
| 1652 | case Iop_QFtoI32Ux4_RZ: |
| 1653 | case Iop_QFtoI32Sx4_RZ: |
| 1654 | case Iop_RoundF32x4_RM: |
| 1655 | case Iop_RoundF32x4_RP: |
| 1656 | case Iop_RoundF32x4_RN: |
| 1657 | case Iop_RoundF32x4_RZ: |
| 1658 | UNARY(Ity_V128, Ity_V128); |
| 1659 | |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1660 | case Iop_64HLtoV128: BINARY(Ity_I64,Ity_I64, Ity_V128); |
sewardj | f0c1c58 | 2005-02-07 23:47:38 +0000 | [diff] [blame] | 1661 | case Iop_V128to64: case Iop_V128HIto64: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1662 | UNARY(Ity_V128, Ity_I64); |
sewardj | c9a4366 | 2004-11-30 18:51:59 +0000 | [diff] [blame] | 1663 | |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1664 | case Iop_V128to32: UNARY(Ity_V128, Ity_I32); |
| 1665 | case Iop_32UtoV128: UNARY(Ity_I32, Ity_V128); |
| 1666 | case Iop_64UtoV128: UNARY(Ity_I64, Ity_V128); |
| 1667 | case Iop_SetV128lo32: BINARY(Ity_V128,Ity_I32, Ity_V128); |
| 1668 | case Iop_SetV128lo64: BINARY(Ity_V128,Ity_I64, Ity_V128); |
sewardj | 129b3d9 | 2004-12-05 15:42:05 +0000 | [diff] [blame] | 1669 | |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1670 | case Iop_Dup8x16: UNARY(Ity_I8, Ity_V128); |
| 1671 | case Iop_Dup16x8: UNARY(Ity_I16, Ity_V128); |
| 1672 | case Iop_Dup32x4: UNARY(Ity_I32, Ity_V128); |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 1673 | |
sewardj | 1e6ad74 | 2004-12-02 16:16:11 +0000 | [diff] [blame] | 1674 | case Iop_CmpEQ32Fx4: case Iop_CmpLT32Fx4: |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 1675 | case Iop_CmpEQ64Fx2: case Iop_CmpLT64Fx2: |
sewardj | 1e6ad74 | 2004-12-02 16:16:11 +0000 | [diff] [blame] | 1676 | case Iop_CmpLE32Fx4: case Iop_CmpUN32Fx4: |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 1677 | case Iop_CmpLE64Fx2: case Iop_CmpUN64Fx2: |
cerion | 206c364 | 2005-11-14 00:35:59 +0000 | [diff] [blame] | 1678 | case Iop_CmpGT32Fx4: case Iop_CmpGE32Fx4: |
sewardj | 1e6ad74 | 2004-12-02 16:16:11 +0000 | [diff] [blame] | 1679 | case Iop_CmpEQ32F0x4: case Iop_CmpLT32F0x4: |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 1680 | case Iop_CmpEQ64F0x2: case Iop_CmpLT64F0x2: |
sewardj | 1e6ad74 | 2004-12-02 16:16:11 +0000 | [diff] [blame] | 1681 | case Iop_CmpLE32F0x4: case Iop_CmpUN32F0x4: |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 1682 | case Iop_CmpLE64F0x2: case Iop_CmpUN64F0x2: |
sewardj | 1e6ad74 | 2004-12-02 16:16:11 +0000 | [diff] [blame] | 1683 | case Iop_Add32Fx4: case Iop_Add32F0x4: |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 1684 | case Iop_Add64Fx2: case Iop_Add64F0x2: |
sewardj | 176a59c | 2004-12-03 20:08:31 +0000 | [diff] [blame] | 1685 | case Iop_Div32Fx4: case Iop_Div32F0x4: |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 1686 | case Iop_Div64Fx2: case Iop_Div64F0x2: |
sewardj | 176a59c | 2004-12-03 20:08:31 +0000 | [diff] [blame] | 1687 | case Iop_Max32Fx4: case Iop_Max32F0x4: |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 1688 | case Iop_Max64Fx2: case Iop_Max64F0x2: |
sewardj | 176a59c | 2004-12-03 20:08:31 +0000 | [diff] [blame] | 1689 | case Iop_Min32Fx4: case Iop_Min32F0x4: |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 1690 | case Iop_Min64Fx2: case Iop_Min64F0x2: |
sewardj | 9636b44 | 2004-12-04 01:38:37 +0000 | [diff] [blame] | 1691 | case Iop_Mul32Fx4: case Iop_Mul32F0x4: |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 1692 | case Iop_Mul64Fx2: case Iop_Mul64F0x2: |
sewardj | c1e7dfc | 2004-12-05 19:29:45 +0000 | [diff] [blame] | 1693 | case Iop_Sub32Fx4: case Iop_Sub32F0x4: |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 1694 | case Iop_Sub64Fx2: case Iop_Sub64F0x2: |
sewardj | f0c1c58 | 2005-02-07 23:47:38 +0000 | [diff] [blame] | 1695 | case Iop_AndV128: case Iop_OrV128: case Iop_XorV128: |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 1696 | case Iop_Add8x16: case Iop_Add16x8: |
| 1697 | case Iop_Add32x4: case Iop_Add64x2: |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 1698 | case Iop_QAdd8Ux16: case Iop_QAdd16Ux8: case Iop_QAdd32Ux4: |
| 1699 | case Iop_QAdd8Sx16: case Iop_QAdd16Sx8: case Iop_QAdd32Sx4: |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 1700 | case Iop_Sub8x16: case Iop_Sub16x8: |
| 1701 | case Iop_Sub32x4: case Iop_Sub64x2: |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 1702 | case Iop_QSub8Ux16: case Iop_QSub16Ux8: case Iop_QSub32Ux4: |
| 1703 | case Iop_QSub8Sx16: case Iop_QSub16Sx8: case Iop_QSub32Sx4: |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 1704 | case Iop_Mul16x8: |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 1705 | case Iop_MulHi16Ux8: case Iop_MulHi32Ux4: |
| 1706 | case Iop_MulHi16Sx8: case Iop_MulHi32Sx4: |
cerion | 1ac656a | 2005-11-04 19:44:48 +0000 | [diff] [blame] | 1707 | case Iop_MullEven8Ux16: case Iop_MullEven16Ux8: |
| 1708 | case Iop_MullEven8Sx16: case Iop_MullEven16Sx8: |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 1709 | case Iop_Avg8Ux16: case Iop_Avg16Ux8: case Iop_Avg32Ux4: |
| 1710 | case Iop_Avg8Sx16: case Iop_Avg16Sx8: case Iop_Avg32Sx4: |
| 1711 | case Iop_Max8Sx16: case Iop_Max16Sx8: case Iop_Max32Sx4: |
| 1712 | case Iop_Max8Ux16: case Iop_Max16Ux8: case Iop_Max32Ux4: |
| 1713 | case Iop_Min8Sx16: case Iop_Min16Sx8: case Iop_Min32Sx4: |
| 1714 | case Iop_Min8Ux16: case Iop_Min16Ux8: case Iop_Min32Ux4: |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 1715 | case Iop_CmpEQ8x16: case Iop_CmpEQ16x8: case Iop_CmpEQ32x4: |
| 1716 | case Iop_CmpGT8Sx16: case Iop_CmpGT16Sx8: case Iop_CmpGT32Sx4: |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 1717 | case Iop_CmpGT8Ux16: case Iop_CmpGT16Ux8: case Iop_CmpGT32Ux4: |
| 1718 | case Iop_Shl8x16: case Iop_Shl16x8: case Iop_Shl32x4: |
| 1719 | case Iop_Shr8x16: case Iop_Shr16x8: case Iop_Shr32x4: |
| 1720 | case Iop_Sar8x16: case Iop_Sar16x8: case Iop_Sar32x4: |
sewardj | 1bee561 | 2005-11-10 18:10:58 +0000 | [diff] [blame] | 1721 | case Iop_Rol8x16: case Iop_Rol16x8: case Iop_Rol32x4: |
cerion | 9e7677b | 2005-09-13 17:25:41 +0000 | [diff] [blame] | 1722 | case Iop_QNarrow16Ux8: case Iop_QNarrow32Ux4: |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 1723 | case Iop_QNarrow16Sx8: case Iop_QNarrow32Sx4: |
sewardj | 1bee561 | 2005-11-10 18:10:58 +0000 | [diff] [blame] | 1724 | case Iop_Narrow16x8: case Iop_Narrow32x4: |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 1725 | case Iop_InterleaveHI8x16: case Iop_InterleaveHI16x8: |
| 1726 | case Iop_InterleaveHI32x4: case Iop_InterleaveHI64x2: |
| 1727 | case Iop_InterleaveLO8x16: case Iop_InterleaveLO16x8: |
| 1728 | case Iop_InterleaveLO32x4: case Iop_InterleaveLO64x2: |
sewardj | dc1f913 | 2005-10-22 12:49:49 +0000 | [diff] [blame] | 1729 | case Iop_Perm8x16: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1730 | BINARY(Ity_V128,Ity_V128, Ity_V128); |
sewardj | c9a4366 | 2004-11-30 18:51:59 +0000 | [diff] [blame] | 1731 | |
sewardj | f0c1c58 | 2005-02-07 23:47:38 +0000 | [diff] [blame] | 1732 | case Iop_NotV128: |
sewardj | 0bd7ce6 | 2004-12-05 02:47:40 +0000 | [diff] [blame] | 1733 | case Iop_Recip32Fx4: case Iop_Recip32F0x4: |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 1734 | case Iop_Recip64Fx2: case Iop_Recip64F0x2: |
sewardj | c1e7dfc | 2004-12-05 19:29:45 +0000 | [diff] [blame] | 1735 | case Iop_RSqrt32Fx4: case Iop_RSqrt32F0x4: |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 1736 | case Iop_RSqrt64Fx2: case Iop_RSqrt64F0x2: |
sewardj | c1e7dfc | 2004-12-05 19:29:45 +0000 | [diff] [blame] | 1737 | case Iop_Sqrt32Fx4: case Iop_Sqrt32F0x4: |
sewardj | 636ad76 | 2004-12-07 11:16:04 +0000 | [diff] [blame] | 1738 | case Iop_Sqrt64Fx2: case Iop_Sqrt64F0x2: |
sewardj | 2e38386 | 2004-12-12 16:46:47 +0000 | [diff] [blame] | 1739 | case Iop_CmpNEZ8x16: case Iop_CmpNEZ16x8: |
sewardj | 109ffdb | 2004-12-10 21:45:38 +0000 | [diff] [blame] | 1740 | case Iop_CmpNEZ32x4: case Iop_CmpNEZ64x2: |
sewardj | 0bd7ce6 | 2004-12-05 02:47:40 +0000 | [diff] [blame] | 1741 | UNARY(Ity_V128, Ity_V128); |
| 1742 | |
cerion | f887b3e | 2005-09-13 16:34:28 +0000 | [diff] [blame] | 1743 | case Iop_ShlV128: case Iop_ShrV128: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1744 | case Iop_ShlN8x16: case Iop_ShlN16x8: |
| 1745 | case Iop_ShlN32x4: case Iop_ShlN64x2: |
| 1746 | case Iop_ShrN8x16: case Iop_ShrN16x8: |
| 1747 | case Iop_ShrN32x4: case Iop_ShrN64x2: |
cerion | 2a4b845 | 2005-09-15 16:28:36 +0000 | [diff] [blame] | 1748 | case Iop_SarN8x16: case Iop_SarN16x8: case Iop_SarN32x4: |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1749 | BINARY(Ity_V128,Ity_I8, Ity_V128); |
sewardj | 164f927 | 2004-12-09 00:39:32 +0000 | [diff] [blame] | 1750 | |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1751 | default: |
| 1752 | ppIROp(op); |
| 1753 | vpanic("typeOfPrimop"); |
| 1754 | } |
| 1755 | # undef UNARY |
| 1756 | # undef BINARY |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1757 | # undef TERNARY |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1758 | # undef COMPARISON |
sewardj | 0033ddc | 2005-04-26 23:34:34 +0000 | [diff] [blame] | 1759 | # undef UNARY_COMPARISON |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1760 | } |
| 1761 | |
| 1762 | |
| 1763 | /*---------------------------------------------------------------*/ |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1764 | /*--- Helper functions for the IR -- IR Basic Blocks ---*/ |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 1765 | /*---------------------------------------------------------------*/ |
| 1766 | |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1767 | void addStmtToIRBB ( IRBB* bb, IRStmt* st ) |
sewardj | d7cb853 | 2004-08-17 23:59:23 +0000 | [diff] [blame] | 1768 | { |
| 1769 | Int i; |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1770 | if (bb->stmts_used == bb->stmts_size) { |
| 1771 | IRStmt** stmts2 = LibVEX_Alloc(2 * bb->stmts_size * sizeof(IRStmt*)); |
| 1772 | for (i = 0; i < bb->stmts_size; i++) |
| 1773 | stmts2[i] = bb->stmts[i]; |
| 1774 | bb->stmts = stmts2; |
| 1775 | bb->stmts_size *= 2; |
| 1776 | } |
| 1777 | vassert(bb->stmts_used < bb->stmts_size); |
| 1778 | bb->stmts[bb->stmts_used] = st; |
| 1779 | bb->stmts_used++; |
sewardj | d7cb853 | 2004-08-17 23:59:23 +0000 | [diff] [blame] | 1780 | } |
| 1781 | |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1782 | |
| 1783 | /*---------------------------------------------------------------*/ |
| 1784 | /*--- Helper functions for the IR -- IR Type Environments ---*/ |
| 1785 | /*---------------------------------------------------------------*/ |
| 1786 | |
sewardj | d7cb853 | 2004-08-17 23:59:23 +0000 | [diff] [blame] | 1787 | /* Allocate a new IRTemp, given its type. */ |
sewardj | e3d0d2e | 2004-06-27 10:42:44 +0000 | [diff] [blame] | 1788 | |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 1789 | IRTemp newIRTemp ( IRTypeEnv* env, IRType ty ) |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 1790 | { |
sewardj | 35421a3 | 2004-07-05 13:12:34 +0000 | [diff] [blame] | 1791 | vassert(env); |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 1792 | vassert(env->types_used >= 0); |
| 1793 | vassert(env->types_size >= 0); |
| 1794 | vassert(env->types_used <= env->types_size); |
| 1795 | if (env->types_used < env->types_size) { |
| 1796 | env->types[env->types_used] = ty; |
| 1797 | return env->types_used++; |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 1798 | } else { |
| 1799 | Int i; |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 1800 | Int new_size = env->types_size==0 ? 8 : 2*env->types_size; |
| 1801 | IRType* new_types |
| 1802 | = LibVEX_Alloc(new_size * sizeof(IRType)); |
| 1803 | for (i = 0; i < env->types_used; i++) |
| 1804 | new_types[i] = env->types[i]; |
| 1805 | env->types = new_types; |
| 1806 | env->types_size = new_size; |
| 1807 | return newIRTemp(env, ty); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 1808 | } |
| 1809 | } |
| 1810 | |
| 1811 | |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1812 | /*---------------------------------------------------------------*/ |
| 1813 | /*--- Helper functions for the IR -- finding types of exprs ---*/ |
| 1814 | /*---------------------------------------------------------------*/ |
| 1815 | |
sewardj | edeb4c4 | 2004-09-21 23:39:25 +0000 | [diff] [blame] | 1816 | inline |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1817 | IRType typeOfIRTemp ( IRTypeEnv* env, IRTemp tmp ) |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 1818 | { |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 1819 | vassert(tmp >= 0); |
| 1820 | vassert(tmp < env->types_used); |
| 1821 | return env->types[tmp]; |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 1822 | } |
| 1823 | |
| 1824 | |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1825 | IRType typeOfIRConst ( IRConst* con ) |
| 1826 | { |
| 1827 | switch (con->tag) { |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 1828 | case Ico_U1: return Ity_I1; |
sewardj | 207557a | 2004-08-27 12:00:18 +0000 | [diff] [blame] | 1829 | case Ico_U8: return Ity_I8; |
| 1830 | case Ico_U16: return Ity_I16; |
| 1831 | case Ico_U32: return Ity_I32; |
| 1832 | case Ico_U64: return Ity_I64; |
| 1833 | case Ico_F64: return Ity_F64; |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1834 | case Ico_F64i: return Ity_F64; |
sewardj | 1e6ad74 | 2004-12-02 16:16:11 +0000 | [diff] [blame] | 1835 | case Ico_V128: return Ity_V128; |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1836 | default: vpanic("typeOfIRConst"); |
| 1837 | } |
| 1838 | } |
| 1839 | |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 1840 | IRType typeOfIRExpr ( IRTypeEnv* tyenv, IRExpr* e ) |
| 1841 | { |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 1842 | IRType t_dst, t_arg1, t_arg2, t_arg3, t_arg4; |
sewardj | edeb4c4 | 2004-09-21 23:39:25 +0000 | [diff] [blame] | 1843 | start: |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 1844 | switch (e->tag) { |
sewardj | af1ceca | 2005-06-30 23:31:27 +0000 | [diff] [blame] | 1845 | case Iex_Load: |
| 1846 | return e->Iex.Load.ty; |
sewardj | fbcaf33 | 2004-07-08 01:46:01 +0000 | [diff] [blame] | 1847 | case Iex_Get: |
| 1848 | return e->Iex.Get.ty; |
sewardj | bb53f8c | 2004-08-14 11:50:01 +0000 | [diff] [blame] | 1849 | case Iex_GetI: |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 1850 | return e->Iex.GetI.descr->elemTy; |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 1851 | case Iex_Tmp: |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 1852 | return typeOfIRTemp(tyenv, e->Iex.Tmp.tmp); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 1853 | case Iex_Const: |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 1854 | return typeOfIRConst(e->Iex.Const.con); |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 1855 | case Iex_Qop: |
| 1856 | typeOfPrimop(e->Iex.Qop.op, |
| 1857 | &t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4); |
| 1858 | return t_dst; |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1859 | case Iex_Triop: |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 1860 | typeOfPrimop(e->Iex.Triop.op, |
| 1861 | &t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4); |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1862 | return t_dst; |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 1863 | case Iex_Binop: |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 1864 | typeOfPrimop(e->Iex.Binop.op, |
| 1865 | &t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1866 | return t_dst; |
| 1867 | case Iex_Unop: |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 1868 | typeOfPrimop(e->Iex.Unop.op, |
| 1869 | &t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1870 | return t_dst; |
| 1871 | case Iex_CCall: |
| 1872 | return e->Iex.CCall.retty; |
sewardj | 4042c7e | 2004-07-18 01:28:30 +0000 | [diff] [blame] | 1873 | case Iex_Mux0X: |
sewardj | edeb4c4 | 2004-09-21 23:39:25 +0000 | [diff] [blame] | 1874 | e = e->Iex.Mux0X.expr0; |
| 1875 | goto start; |
| 1876 | /* return typeOfIRExpr(tyenv, e->Iex.Mux0X.expr0); */ |
sewardj | 443cd9d | 2004-07-18 23:06:45 +0000 | [diff] [blame] | 1877 | case Iex_Binder: |
| 1878 | vpanic("typeOfIRExpr: Binder is not a valid expression"); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 1879 | default: |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1880 | ppIRExpr(e); |
| 1881 | vpanic("typeOfIRExpr"); |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 1882 | } |
sewardj | c97096c | 2004-06-30 09:28:04 +0000 | [diff] [blame] | 1883 | } |
sewardj | 887a11a | 2004-07-05 17:26:47 +0000 | [diff] [blame] | 1884 | |
sewardj | 6d2638e | 2004-07-15 09:38:27 +0000 | [diff] [blame] | 1885 | /* Is this any value actually in the enumeration 'IRType' ? */ |
sewardj | 496a58d | 2005-03-20 18:44:44 +0000 | [diff] [blame] | 1886 | Bool isPlausibleIRType ( IRType ty ) |
sewardj | 6d2638e | 2004-07-15 09:38:27 +0000 | [diff] [blame] | 1887 | { |
| 1888 | switch (ty) { |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 1889 | case Ity_INVALID: case Ity_I1: |
sewardj | 9b96767 | 2005-02-08 11:13:09 +0000 | [diff] [blame] | 1890 | case Ity_I8: case Ity_I16: case Ity_I32: |
| 1891 | case Ity_I64: case Ity_I128: |
sewardj | bb53f8c | 2004-08-14 11:50:01 +0000 | [diff] [blame] | 1892 | case Ity_F32: case Ity_F64: |
sewardj | c9a4366 | 2004-11-30 18:51:59 +0000 | [diff] [blame] | 1893 | case Ity_V128: |
sewardj | 6d2638e | 2004-07-15 09:38:27 +0000 | [diff] [blame] | 1894 | return True; |
| 1895 | default: |
| 1896 | return False; |
| 1897 | } |
| 1898 | } |
| 1899 | |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 1900 | |
sewardj | 887a11a | 2004-07-05 17:26:47 +0000 | [diff] [blame] | 1901 | /*---------------------------------------------------------------*/ |
sewardj | cf78790 | 2004-11-03 09:08:33 +0000 | [diff] [blame] | 1902 | /*--- Sanity checking -- FLATNESS ---*/ |
| 1903 | /*---------------------------------------------------------------*/ |
| 1904 | |
| 1905 | /* Check that the canonical flatness constraints hold on an |
| 1906 | IRStmt. The only place where any expression is allowed to be |
| 1907 | non-atomic is the RHS of IRStmt_Tmp. */ |
| 1908 | |
| 1909 | /* Relies on: |
| 1910 | inline static Bool isAtom ( IRExpr* e ) { |
| 1911 | return e->tag == Iex_Tmp || e->tag == Iex_Const; |
| 1912 | } |
| 1913 | */ |
| 1914 | |
| 1915 | Bool isFlatIRStmt ( IRStmt* st ) |
| 1916 | { |
| 1917 | Int i; |
| 1918 | IRExpr* e; |
| 1919 | IRDirty* di; |
| 1920 | |
| 1921 | switch (st->tag) { |
sewardj | 5a9ffab | 2005-05-12 17:55:01 +0000 | [diff] [blame] | 1922 | case Ist_AbiHint: |
| 1923 | return isIRAtom(st->Ist.AbiHint.base); |
sewardj | cf78790 | 2004-11-03 09:08:33 +0000 | [diff] [blame] | 1924 | case Ist_Put: |
sewardj | 496a58d | 2005-03-20 18:44:44 +0000 | [diff] [blame] | 1925 | return isIRAtom(st->Ist.Put.data); |
sewardj | cf78790 | 2004-11-03 09:08:33 +0000 | [diff] [blame] | 1926 | case Ist_PutI: |
sewardj | 496a58d | 2005-03-20 18:44:44 +0000 | [diff] [blame] | 1927 | return toBool( isIRAtom(st->Ist.PutI.ix) |
| 1928 | && isIRAtom(st->Ist.PutI.data) ); |
sewardj | cf78790 | 2004-11-03 09:08:33 +0000 | [diff] [blame] | 1929 | case Ist_Tmp: |
| 1930 | /* This is the only interesting case. The RHS can be any |
| 1931 | expression, *but* all its subexpressions *must* be |
| 1932 | atoms. */ |
| 1933 | e = st->Ist.Tmp.data; |
| 1934 | switch (e->tag) { |
| 1935 | case Iex_Binder: return True; |
| 1936 | case Iex_Get: return True; |
sewardj | 496a58d | 2005-03-20 18:44:44 +0000 | [diff] [blame] | 1937 | case Iex_GetI: return isIRAtom(e->Iex.GetI.ix); |
sewardj | cf78790 | 2004-11-03 09:08:33 +0000 | [diff] [blame] | 1938 | case Iex_Tmp: return True; |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 1939 | case Iex_Qop: return toBool( |
| 1940 | isIRAtom(e->Iex.Qop.arg1) |
| 1941 | && isIRAtom(e->Iex.Qop.arg2) |
| 1942 | && isIRAtom(e->Iex.Qop.arg3) |
| 1943 | && isIRAtom(e->Iex.Qop.arg4)); |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 1944 | case Iex_Triop: return toBool( |
| 1945 | isIRAtom(e->Iex.Triop.arg1) |
| 1946 | && isIRAtom(e->Iex.Triop.arg2) |
| 1947 | && isIRAtom(e->Iex.Triop.arg3)); |
sewardj | a98bf49 | 2005-02-07 01:39:17 +0000 | [diff] [blame] | 1948 | case Iex_Binop: return toBool( |
sewardj | 496a58d | 2005-03-20 18:44:44 +0000 | [diff] [blame] | 1949 | isIRAtom(e->Iex.Binop.arg1) |
| 1950 | && isIRAtom(e->Iex.Binop.arg2)); |
| 1951 | case Iex_Unop: return isIRAtom(e->Iex.Unop.arg); |
sewardj | af1ceca | 2005-06-30 23:31:27 +0000 | [diff] [blame] | 1952 | case Iex_Load: return isIRAtom(e->Iex.Load.addr); |
sewardj | cf78790 | 2004-11-03 09:08:33 +0000 | [diff] [blame] | 1953 | case Iex_Const: return True; |
| 1954 | case Iex_CCall: for (i = 0; e->Iex.CCall.args[i]; i++) |
sewardj | 496a58d | 2005-03-20 18:44:44 +0000 | [diff] [blame] | 1955 | if (!isIRAtom(e->Iex.CCall.args[i])) |
sewardj | cf78790 | 2004-11-03 09:08:33 +0000 | [diff] [blame] | 1956 | return False; |
| 1957 | return True; |
sewardj | a98bf49 | 2005-02-07 01:39:17 +0000 | [diff] [blame] | 1958 | case Iex_Mux0X: return toBool ( |
sewardj | 496a58d | 2005-03-20 18:44:44 +0000 | [diff] [blame] | 1959 | isIRAtom(e->Iex.Mux0X.cond) |
| 1960 | && isIRAtom(e->Iex.Mux0X.expr0) |
| 1961 | && isIRAtom(e->Iex.Mux0X.exprX)); |
sewardj | cf78790 | 2004-11-03 09:08:33 +0000 | [diff] [blame] | 1962 | default: vpanic("isFlatIRStmt(e)"); |
| 1963 | } |
| 1964 | /*notreached*/ |
| 1965 | vassert(0); |
sewardj | af1ceca | 2005-06-30 23:31:27 +0000 | [diff] [blame] | 1966 | case Ist_Store: |
| 1967 | return toBool( isIRAtom(st->Ist.Store.addr) |
| 1968 | && isIRAtom(st->Ist.Store.data) ); |
sewardj | cf78790 | 2004-11-03 09:08:33 +0000 | [diff] [blame] | 1969 | case Ist_Dirty: |
| 1970 | di = st->Ist.Dirty.details; |
sewardj | 496a58d | 2005-03-20 18:44:44 +0000 | [diff] [blame] | 1971 | if (!isIRAtom(di->guard)) |
sewardj | cf78790 | 2004-11-03 09:08:33 +0000 | [diff] [blame] | 1972 | return False; |
| 1973 | for (i = 0; di->args[i]; i++) |
sewardj | 496a58d | 2005-03-20 18:44:44 +0000 | [diff] [blame] | 1974 | if (!isIRAtom(di->args[i])) |
sewardj | cf78790 | 2004-11-03 09:08:33 +0000 | [diff] [blame] | 1975 | return False; |
sewardj | 496a58d | 2005-03-20 18:44:44 +0000 | [diff] [blame] | 1976 | if (di->mAddr && !isIRAtom(di->mAddr)) |
sewardj | cf78790 | 2004-11-03 09:08:33 +0000 | [diff] [blame] | 1977 | return False; |
| 1978 | return True; |
sewardj | d2445f6 | 2005-03-21 00:15:53 +0000 | [diff] [blame] | 1979 | case Ist_NoOp: |
sewardj | f168931 | 2005-03-16 18:19:10 +0000 | [diff] [blame] | 1980 | case Ist_IMark: |
sewardj | 3e83893 | 2005-01-07 12:09:15 +0000 | [diff] [blame] | 1981 | case Ist_MFence: |
| 1982 | return True; |
sewardj | cf78790 | 2004-11-03 09:08:33 +0000 | [diff] [blame] | 1983 | case Ist_Exit: |
sewardj | 496a58d | 2005-03-20 18:44:44 +0000 | [diff] [blame] | 1984 | return isIRAtom(st->Ist.Exit.guard); |
sewardj | cf78790 | 2004-11-03 09:08:33 +0000 | [diff] [blame] | 1985 | default: |
| 1986 | vpanic("isFlatIRStmt(st)"); |
| 1987 | } |
| 1988 | } |
| 1989 | |
| 1990 | |
| 1991 | /*---------------------------------------------------------------*/ |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 1992 | /*--- Sanity checking ---*/ |
| 1993 | /*---------------------------------------------------------------*/ |
| 1994 | |
| 1995 | /* Checks: |
| 1996 | |
| 1997 | Everything is type-consistent. No ill-typed anything. |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 1998 | The target address at the end of the BB is a 32- or 64- |
| 1999 | bit expression, depending on the guest's word size. |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 2000 | |
| 2001 | Each temp is assigned only once, before its uses. |
sewardj | c13e2ed | 2004-10-31 21:44:54 +0000 | [diff] [blame] | 2002 | */ |
| 2003 | |
| 2004 | static inline Int countArgs ( IRExpr** args ) |
| 2005 | { |
| 2006 | Int i; |
| 2007 | for (i = 0; args[i]; i++) |
| 2008 | ; |
| 2009 | return i; |
| 2010 | } |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 2011 | |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2012 | static |
| 2013 | __attribute((noreturn)) |
sewardj | a98bf49 | 2005-02-07 01:39:17 +0000 | [diff] [blame] | 2014 | void sanityCheckFail ( IRBB* bb, IRStmt* stmt, HChar* what ) |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 2015 | { |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2016 | vex_printf("\nIR SANITY CHECK FAILURE\n\n"); |
| 2017 | ppIRBB(bb); |
| 2018 | if (stmt) { |
| 2019 | vex_printf("\nIN STATEMENT:\n\n"); |
| 2020 | ppIRStmt(stmt); |
| 2021 | } |
| 2022 | vex_printf("\n\nERROR = %s\n\n", what ); |
| 2023 | vpanic("sanityCheckFail: exiting due to bad IR"); |
| 2024 | } |
| 2025 | |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 2026 | static Bool saneIRArray ( IRArray* arr ) |
| 2027 | { |
| 2028 | if (arr->base < 0 || arr->base > 10000 /* somewhat arbitrary */) |
| 2029 | return False; |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 2030 | if (arr->elemTy == Ity_I1) |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 2031 | return False; |
| 2032 | if (arr->nElems <= 0 || arr->nElems > 500 /* somewhat arbitrary */) |
| 2033 | return False; |
| 2034 | return True; |
| 2035 | } |
| 2036 | |
sewardj | 8ea867b | 2004-10-30 19:03:02 +0000 | [diff] [blame] | 2037 | static Bool saneIRCallee ( IRCallee* cee ) |
| 2038 | { |
| 2039 | if (cee->name == NULL) |
| 2040 | return False; |
| 2041 | if (cee->addr == 0) |
| 2042 | return False; |
sewardj | 7735254 | 2004-10-30 20:39:01 +0000 | [diff] [blame] | 2043 | if (cee->regparms < 0 || cee->regparms > 3) |
sewardj | 8ea867b | 2004-10-30 19:03:02 +0000 | [diff] [blame] | 2044 | return False; |
| 2045 | return True; |
| 2046 | } |
| 2047 | |
sewardj | 49bfe67 | 2004-11-15 15:46:26 +0000 | [diff] [blame] | 2048 | static Bool saneIRConst ( IRConst* con ) |
| 2049 | { |
| 2050 | switch (con->tag) { |
| 2051 | case Ico_U1: |
sewardj | a98bf49 | 2005-02-07 01:39:17 +0000 | [diff] [blame] | 2052 | return toBool( con->Ico.U1 == True || con->Ico.U1 == False ); |
sewardj | 49bfe67 | 2004-11-15 15:46:26 +0000 | [diff] [blame] | 2053 | default: |
| 2054 | /* Is there anything we can meaningfully check? I don't |
| 2055 | think so. */ |
| 2056 | return True; |
| 2057 | } |
| 2058 | } |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2059 | |
| 2060 | /* Traverse a Stmt/Expr, inspecting IRTemp uses. Report any out of |
| 2061 | range ones. Report any which are read and for which the current |
| 2062 | def_count is zero. */ |
| 2063 | |
| 2064 | static |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 2065 | void useBeforeDef_Temp ( IRBB* bb, IRStmt* stmt, IRTemp tmp, Int* def_counts ) |
| 2066 | { |
| 2067 | if (tmp < 0 || tmp >= bb->tyenv->types_used) |
| 2068 | sanityCheckFail(bb,stmt, "out of range Temp in IRExpr"); |
| 2069 | if (def_counts[tmp] < 1) |
| 2070 | sanityCheckFail(bb,stmt, "IRTemp use before def in IRExpr"); |
| 2071 | } |
| 2072 | |
| 2073 | static |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2074 | void useBeforeDef_Expr ( IRBB* bb, IRStmt* stmt, IRExpr* expr, Int* def_counts ) |
| 2075 | { |
| 2076 | Int i; |
| 2077 | switch (expr->tag) { |
| 2078 | case Iex_Get: |
| 2079 | break; |
sewardj | bb53f8c | 2004-08-14 11:50:01 +0000 | [diff] [blame] | 2080 | case Iex_GetI: |
sewardj | eeac841 | 2004-11-02 00:26:55 +0000 | [diff] [blame] | 2081 | useBeforeDef_Expr(bb,stmt,expr->Iex.GetI.ix,def_counts); |
sewardj | bb53f8c | 2004-08-14 11:50:01 +0000 | [diff] [blame] | 2082 | break; |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 2083 | case Iex_Tmp: |
| 2084 | useBeforeDef_Temp(bb,stmt,expr->Iex.Tmp.tmp,def_counts); |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2085 | break; |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 2086 | case Iex_Qop: |
| 2087 | useBeforeDef_Expr(bb,stmt,expr->Iex.Qop.arg1,def_counts); |
| 2088 | useBeforeDef_Expr(bb,stmt,expr->Iex.Qop.arg2,def_counts); |
| 2089 | useBeforeDef_Expr(bb,stmt,expr->Iex.Qop.arg3,def_counts); |
| 2090 | useBeforeDef_Expr(bb,stmt,expr->Iex.Qop.arg4,def_counts); |
| 2091 | break; |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 2092 | case Iex_Triop: |
| 2093 | useBeforeDef_Expr(bb,stmt,expr->Iex.Triop.arg1,def_counts); |
| 2094 | useBeforeDef_Expr(bb,stmt,expr->Iex.Triop.arg2,def_counts); |
| 2095 | useBeforeDef_Expr(bb,stmt,expr->Iex.Triop.arg3,def_counts); |
| 2096 | break; |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2097 | case Iex_Binop: |
| 2098 | useBeforeDef_Expr(bb,stmt,expr->Iex.Binop.arg1,def_counts); |
| 2099 | useBeforeDef_Expr(bb,stmt,expr->Iex.Binop.arg2,def_counts); |
| 2100 | break; |
| 2101 | case Iex_Unop: |
| 2102 | useBeforeDef_Expr(bb,stmt,expr->Iex.Unop.arg,def_counts); |
| 2103 | break; |
sewardj | af1ceca | 2005-06-30 23:31:27 +0000 | [diff] [blame] | 2104 | case Iex_Load: |
| 2105 | useBeforeDef_Expr(bb,stmt,expr->Iex.Load.addr,def_counts); |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2106 | break; |
| 2107 | case Iex_Const: |
| 2108 | break; |
| 2109 | case Iex_CCall: |
| 2110 | for (i = 0; expr->Iex.CCall.args[i]; i++) |
| 2111 | useBeforeDef_Expr(bb,stmt,expr->Iex.CCall.args[i],def_counts); |
| 2112 | break; |
sewardj | 4042c7e | 2004-07-18 01:28:30 +0000 | [diff] [blame] | 2113 | case Iex_Mux0X: |
| 2114 | useBeforeDef_Expr(bb,stmt,expr->Iex.Mux0X.cond,def_counts); |
| 2115 | useBeforeDef_Expr(bb,stmt,expr->Iex.Mux0X.expr0,def_counts); |
| 2116 | useBeforeDef_Expr(bb,stmt,expr->Iex.Mux0X.exprX,def_counts); |
sewardj | eeb9ef8 | 2004-07-15 12:39:03 +0000 | [diff] [blame] | 2117 | break; |
| 2118 | default: |
| 2119 | vpanic("useBeforeDef_Expr"); |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2120 | } |
| 2121 | } |
| 2122 | |
| 2123 | static |
| 2124 | void useBeforeDef_Stmt ( IRBB* bb, IRStmt* stmt, Int* def_counts ) |
| 2125 | { |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 2126 | Int i; |
| 2127 | IRDirty* d; |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2128 | switch (stmt->tag) { |
sewardj | f168931 | 2005-03-16 18:19:10 +0000 | [diff] [blame] | 2129 | case Ist_IMark: |
| 2130 | break; |
sewardj | 5a9ffab | 2005-05-12 17:55:01 +0000 | [diff] [blame] | 2131 | case Ist_AbiHint: |
| 2132 | useBeforeDef_Expr(bb,stmt,stmt->Ist.AbiHint.base,def_counts); |
| 2133 | break; |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2134 | case Ist_Put: |
sewardj | 6d07636 | 2004-09-23 11:06:17 +0000 | [diff] [blame] | 2135 | useBeforeDef_Expr(bb,stmt,stmt->Ist.Put.data,def_counts); |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2136 | break; |
sewardj | d1725d1 | 2004-08-12 20:46:53 +0000 | [diff] [blame] | 2137 | case Ist_PutI: |
sewardj | eeac841 | 2004-11-02 00:26:55 +0000 | [diff] [blame] | 2138 | useBeforeDef_Expr(bb,stmt,stmt->Ist.PutI.ix,def_counts); |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 2139 | useBeforeDef_Expr(bb,stmt,stmt->Ist.PutI.data,def_counts); |
sewardj | d1725d1 | 2004-08-12 20:46:53 +0000 | [diff] [blame] | 2140 | break; |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2141 | case Ist_Tmp: |
sewardj | 6d07636 | 2004-09-23 11:06:17 +0000 | [diff] [blame] | 2142 | useBeforeDef_Expr(bb,stmt,stmt->Ist.Tmp.data,def_counts); |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2143 | break; |
sewardj | af1ceca | 2005-06-30 23:31:27 +0000 | [diff] [blame] | 2144 | case Ist_Store: |
| 2145 | useBeforeDef_Expr(bb,stmt,stmt->Ist.Store.addr,def_counts); |
| 2146 | useBeforeDef_Expr(bb,stmt,stmt->Ist.Store.data,def_counts); |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2147 | break; |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 2148 | case Ist_Dirty: |
| 2149 | d = stmt->Ist.Dirty.details; |
| 2150 | for (i = 0; d->args[i] != NULL; i++) |
| 2151 | useBeforeDef_Expr(bb,stmt,d->args[i],def_counts); |
| 2152 | if (d->mFx != Ifx_None) |
| 2153 | useBeforeDef_Expr(bb,stmt,d->mAddr,def_counts); |
| 2154 | break; |
sewardj | d2445f6 | 2005-03-21 00:15:53 +0000 | [diff] [blame] | 2155 | case Ist_NoOp: |
sewardj | 3e83893 | 2005-01-07 12:09:15 +0000 | [diff] [blame] | 2156 | case Ist_MFence: |
| 2157 | break; |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2158 | case Ist_Exit: |
sewardj | 0276d4b | 2004-11-15 15:30:21 +0000 | [diff] [blame] | 2159 | useBeforeDef_Expr(bb,stmt,stmt->Ist.Exit.guard,def_counts); |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2160 | break; |
| 2161 | default: |
| 2162 | vpanic("useBeforeDef_Stmt"); |
| 2163 | } |
| 2164 | } |
| 2165 | |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2166 | static |
| 2167 | void tcExpr ( IRBB* bb, IRStmt* stmt, IRExpr* expr, IRType gWordTy ) |
| 2168 | { |
| 2169 | Int i; |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 2170 | IRType t_dst, t_arg1, t_arg2, t_arg3, t_arg4; |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2171 | IRTypeEnv* tyenv = bb->tyenv; |
| 2172 | switch (expr->tag) { |
| 2173 | case Iex_Get: |
| 2174 | case Iex_Tmp: |
| 2175 | break; |
sewardj | bb53f8c | 2004-08-14 11:50:01 +0000 | [diff] [blame] | 2176 | case Iex_GetI: |
sewardj | eeac841 | 2004-11-02 00:26:55 +0000 | [diff] [blame] | 2177 | tcExpr(bb,stmt, expr->Iex.GetI.ix, gWordTy ); |
| 2178 | if (typeOfIRExpr(tyenv,expr->Iex.GetI.ix) != Ity_I32) |
| 2179 | sanityCheckFail(bb,stmt,"IRExpr.GetI.ix: not :: Ity_I32"); |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 2180 | if (!saneIRArray(expr->Iex.GetI.descr)) |
| 2181 | sanityCheckFail(bb,stmt,"IRExpr.GetI.descr: invalid descr"); |
sewardj | bb53f8c | 2004-08-14 11:50:01 +0000 | [diff] [blame] | 2182 | break; |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 2183 | case Iex_Qop: { |
| 2184 | IRType ttarg1, ttarg2, ttarg3, ttarg4; |
| 2185 | tcExpr(bb,stmt, expr->Iex.Qop.arg1, gWordTy ); |
| 2186 | tcExpr(bb,stmt, expr->Iex.Qop.arg2, gWordTy ); |
| 2187 | tcExpr(bb,stmt, expr->Iex.Qop.arg3, gWordTy ); |
| 2188 | tcExpr(bb,stmt, expr->Iex.Qop.arg4, gWordTy ); |
| 2189 | typeOfPrimop(expr->Iex.Qop.op, |
| 2190 | &t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4); |
| 2191 | if (t_arg1 == Ity_INVALID || t_arg2 == Ity_INVALID |
| 2192 | || t_arg3 == Ity_INVALID || t_arg4 == Ity_INVALID) { |
| 2193 | vex_printf(" op name: " ); |
| 2194 | ppIROp(expr->Iex.Qop.op); |
| 2195 | vex_printf("\n"); |
| 2196 | sanityCheckFail(bb,stmt, |
| 2197 | "Iex.Qop: wrong arity op\n" |
| 2198 | "... name of op precedes BB printout\n"); |
| 2199 | } |
| 2200 | ttarg1 = typeOfIRExpr(tyenv, expr->Iex.Qop.arg1); |
| 2201 | ttarg2 = typeOfIRExpr(tyenv, expr->Iex.Qop.arg2); |
| 2202 | ttarg3 = typeOfIRExpr(tyenv, expr->Iex.Qop.arg3); |
| 2203 | ttarg4 = typeOfIRExpr(tyenv, expr->Iex.Qop.arg4); |
| 2204 | if (t_arg1 != ttarg1 || t_arg2 != ttarg2 |
| 2205 | || t_arg3 != ttarg3 || t_arg4 != ttarg4) { |
| 2206 | vex_printf(" op name: "); |
| 2207 | ppIROp(expr->Iex.Qop.op); |
| 2208 | vex_printf("\n"); |
| 2209 | vex_printf(" op type is ("); |
| 2210 | ppIRType(t_arg1); |
| 2211 | vex_printf(","); |
| 2212 | ppIRType(t_arg2); |
| 2213 | vex_printf(","); |
| 2214 | ppIRType(t_arg3); |
| 2215 | vex_printf(","); |
| 2216 | ppIRType(t_arg4); |
| 2217 | vex_printf(") -> "); |
| 2218 | ppIRType (t_dst); |
| 2219 | vex_printf("\narg tys are ("); |
| 2220 | ppIRType(ttarg1); |
| 2221 | vex_printf(","); |
| 2222 | ppIRType(ttarg2); |
| 2223 | vex_printf(","); |
| 2224 | ppIRType(ttarg3); |
| 2225 | vex_printf(","); |
| 2226 | ppIRType(ttarg4); |
| 2227 | vex_printf(")\n"); |
| 2228 | sanityCheckFail(bb,stmt, |
| 2229 | "Iex.Qop: arg tys don't match op tys\n" |
| 2230 | "... additional details precede BB printout\n"); |
| 2231 | } |
| 2232 | break; |
| 2233 | } |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 2234 | case Iex_Triop: { |
| 2235 | IRType ttarg1, ttarg2, ttarg3; |
| 2236 | tcExpr(bb,stmt, expr->Iex.Triop.arg1, gWordTy ); |
| 2237 | tcExpr(bb,stmt, expr->Iex.Triop.arg2, gWordTy ); |
| 2238 | tcExpr(bb,stmt, expr->Iex.Triop.arg3, gWordTy ); |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 2239 | typeOfPrimop(expr->Iex.Triop.op, |
| 2240 | &t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4); |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 2241 | if (t_arg1 == Ity_INVALID || t_arg2 == Ity_INVALID |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 2242 | || t_arg3 == Ity_INVALID || t_arg4 != Ity_INVALID) { |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 2243 | vex_printf(" op name: " ); |
| 2244 | ppIROp(expr->Iex.Triop.op); |
| 2245 | vex_printf("\n"); |
| 2246 | sanityCheckFail(bb,stmt, |
| 2247 | "Iex.Triop: wrong arity op\n" |
| 2248 | "... name of op precedes BB printout\n"); |
| 2249 | } |
| 2250 | ttarg1 = typeOfIRExpr(tyenv, expr->Iex.Triop.arg1); |
| 2251 | ttarg2 = typeOfIRExpr(tyenv, expr->Iex.Triop.arg2); |
| 2252 | ttarg3 = typeOfIRExpr(tyenv, expr->Iex.Triop.arg3); |
| 2253 | if (t_arg1 != ttarg1 || t_arg2 != ttarg2 || t_arg3 != ttarg3) { |
| 2254 | vex_printf(" op name: "); |
| 2255 | ppIROp(expr->Iex.Triop.op); |
| 2256 | vex_printf("\n"); |
| 2257 | vex_printf(" op type is ("); |
| 2258 | ppIRType(t_arg1); |
| 2259 | vex_printf(","); |
| 2260 | ppIRType(t_arg2); |
| 2261 | vex_printf(","); |
| 2262 | ppIRType(t_arg3); |
| 2263 | vex_printf(") -> "); |
| 2264 | ppIRType (t_dst); |
| 2265 | vex_printf("\narg tys are ("); |
| 2266 | ppIRType(ttarg1); |
| 2267 | vex_printf(","); |
| 2268 | ppIRType(ttarg2); |
| 2269 | vex_printf(","); |
| 2270 | ppIRType(ttarg3); |
| 2271 | vex_printf(")\n"); |
| 2272 | sanityCheckFail(bb,stmt, |
| 2273 | "Iex.Triop: arg tys don't match op tys\n" |
| 2274 | "... additional details precede BB printout\n"); |
| 2275 | } |
| 2276 | break; |
| 2277 | } |
sewardj | 6d2638e | 2004-07-15 09:38:27 +0000 | [diff] [blame] | 2278 | case Iex_Binop: { |
| 2279 | IRType ttarg1, ttarg2; |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2280 | tcExpr(bb,stmt, expr->Iex.Binop.arg1, gWordTy ); |
| 2281 | tcExpr(bb,stmt, expr->Iex.Binop.arg2, gWordTy ); |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 2282 | typeOfPrimop(expr->Iex.Binop.op, |
| 2283 | &t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4); |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 2284 | if (t_arg1 == Ity_INVALID || t_arg2 == Ity_INVALID |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 2285 | || t_arg3 != Ity_INVALID || t_arg4 != Ity_INVALID) { |
sewardj | 8f3debf | 2004-09-08 23:42:23 +0000 | [diff] [blame] | 2286 | vex_printf(" op name: " ); |
| 2287 | ppIROp(expr->Iex.Binop.op); |
| 2288 | vex_printf("\n"); |
| 2289 | sanityCheckFail(bb,stmt, |
| 2290 | "Iex.Binop: wrong arity op\n" |
| 2291 | "... name of op precedes BB printout\n"); |
| 2292 | } |
sewardj | 6d2638e | 2004-07-15 09:38:27 +0000 | [diff] [blame] | 2293 | ttarg1 = typeOfIRExpr(tyenv, expr->Iex.Binop.arg1); |
| 2294 | ttarg2 = typeOfIRExpr(tyenv, expr->Iex.Binop.arg2); |
| 2295 | if (t_arg1 != ttarg1 || t_arg2 != ttarg2) { |
| 2296 | vex_printf(" op name: "); |
| 2297 | ppIROp(expr->Iex.Binop.op); |
| 2298 | vex_printf("\n"); |
| 2299 | vex_printf(" op type is ("); |
| 2300 | ppIRType(t_arg1); |
| 2301 | vex_printf(","); |
| 2302 | ppIRType(t_arg2); |
| 2303 | vex_printf(") -> "); |
| 2304 | ppIRType (t_dst); |
| 2305 | vex_printf("\narg tys are ("); |
| 2306 | ppIRType(ttarg1); |
| 2307 | vex_printf(","); |
| 2308 | ppIRType(ttarg2); |
| 2309 | vex_printf(")\n"); |
| 2310 | sanityCheckFail(bb,stmt, |
| 2311 | "Iex.Binop: arg tys don't match op tys\n" |
| 2312 | "... additional details precede BB printout\n"); |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 2313 | } |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2314 | break; |
sewardj | 6d2638e | 2004-07-15 09:38:27 +0000 | [diff] [blame] | 2315 | } |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2316 | case Iex_Unop: |
| 2317 | tcExpr(bb,stmt, expr->Iex.Unop.arg, gWordTy ); |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 2318 | typeOfPrimop(expr->Iex.Binop.op, |
| 2319 | &t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4); |
sewardj | b183b85 | 2006-02-03 16:08:03 +0000 | [diff] [blame] | 2320 | if (t_arg1 == Ity_INVALID || t_arg2 != Ity_INVALID |
sewardj | 40c8026 | 2006-02-08 19:30:46 +0000 | [diff] [blame] | 2321 | || t_arg3 != Ity_INVALID || t_arg4 != Ity_INVALID) |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2322 | sanityCheckFail(bb,stmt,"Iex.Unop: wrong arity op"); |
| 2323 | if (t_arg1 != typeOfIRExpr(tyenv, expr->Iex.Unop.arg)) |
| 2324 | sanityCheckFail(bb,stmt,"Iex.Unop: arg ty doesn't match op ty"); |
| 2325 | break; |
sewardj | af1ceca | 2005-06-30 23:31:27 +0000 | [diff] [blame] | 2326 | case Iex_Load: |
| 2327 | tcExpr(bb,stmt, expr->Iex.Load.addr, gWordTy); |
| 2328 | if (typeOfIRExpr(tyenv, expr->Iex.Load.addr) != gWordTy) |
| 2329 | sanityCheckFail(bb,stmt,"Iex.Load.addr: not :: guest word type"); |
| 2330 | if (expr->Iex.Load.end != Iend_LE && expr->Iex.Load.end != Iend_BE) |
| 2331 | sanityCheckFail(bb,stmt,"Iex.Load.end: bogus endianness"); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2332 | break; |
| 2333 | case Iex_CCall: |
sewardj | c13e2ed | 2004-10-31 21:44:54 +0000 | [diff] [blame] | 2334 | if (!saneIRCallee(expr->Iex.CCall.cee)) |
| 2335 | sanityCheckFail(bb,stmt,"Iex.CCall.cee: bad IRCallee"); |
sewardj | cf78790 | 2004-11-03 09:08:33 +0000 | [diff] [blame] | 2336 | if (expr->Iex.CCall.cee->regparms > countArgs(expr->Iex.CCall.args)) |
sewardj | c13e2ed | 2004-10-31 21:44:54 +0000 | [diff] [blame] | 2337 | sanityCheckFail(bb,stmt,"Iex.CCall.cee: #regparms > #args"); |
sewardj | 43c5646 | 2004-11-06 12:17:57 +0000 | [diff] [blame] | 2338 | for (i = 0; expr->Iex.CCall.args[i]; i++) { |
| 2339 | if (i >= 32) |
| 2340 | sanityCheckFail(bb,stmt,"Iex.CCall: > 32 args"); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2341 | tcExpr(bb,stmt, expr->Iex.CCall.args[i], gWordTy); |
sewardj | 43c5646 | 2004-11-06 12:17:57 +0000 | [diff] [blame] | 2342 | } |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 2343 | if (expr->Iex.CCall.retty == Ity_I1) |
| 2344 | sanityCheckFail(bb,stmt,"Iex.CCall.retty: cannot return :: Ity_I1"); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2345 | for (i = 0; expr->Iex.CCall.args[i]; i++) |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 2346 | if (typeOfIRExpr(tyenv, expr->Iex.CCall.args[i]) == Ity_I1) |
| 2347 | sanityCheckFail(bb,stmt,"Iex.CCall.arg: arg :: Ity_I1"); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2348 | break; |
| 2349 | case Iex_Const: |
sewardj | 49bfe67 | 2004-11-15 15:46:26 +0000 | [diff] [blame] | 2350 | if (!saneIRConst(expr->Iex.Const.con)) |
| 2351 | sanityCheckFail(bb,stmt,"Iex.Const.con: invalid const"); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2352 | break; |
sewardj | 4042c7e | 2004-07-18 01:28:30 +0000 | [diff] [blame] | 2353 | case Iex_Mux0X: |
| 2354 | tcExpr(bb,stmt, expr->Iex.Mux0X.cond, gWordTy); |
| 2355 | tcExpr(bb,stmt, expr->Iex.Mux0X.expr0, gWordTy); |
| 2356 | tcExpr(bb,stmt, expr->Iex.Mux0X.exprX, gWordTy); |
| 2357 | if (typeOfIRExpr(tyenv, expr->Iex.Mux0X.cond) != Ity_I8) |
| 2358 | sanityCheckFail(bb,stmt,"Iex.Mux0X.cond: cond :: Ity_I8"); |
| 2359 | if (typeOfIRExpr(tyenv, expr->Iex.Mux0X.expr0) |
| 2360 | != typeOfIRExpr(tyenv, expr->Iex.Mux0X.exprX)) |
| 2361 | sanityCheckFail(bb,stmt,"Iex.Mux0X: expr0/exprX mismatch"); |
sewardj | eeb9ef8 | 2004-07-15 12:39:03 +0000 | [diff] [blame] | 2362 | break; |
| 2363 | default: |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2364 | vpanic("tcExpr"); |
| 2365 | } |
| 2366 | } |
| 2367 | |
| 2368 | |
| 2369 | static |
| 2370 | void tcStmt ( IRBB* bb, IRStmt* stmt, IRType gWordTy ) |
| 2371 | { |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 2372 | Int i; |
| 2373 | IRDirty* d; |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2374 | IRTypeEnv* tyenv = bb->tyenv; |
| 2375 | switch (stmt->tag) { |
sewardj | f168931 | 2005-03-16 18:19:10 +0000 | [diff] [blame] | 2376 | case Ist_IMark: |
| 2377 | /* Somewhat heuristic, but rule out totally implausible |
| 2378 | instruction sizes. */ |
| 2379 | if (stmt->Ist.IMark.len < 0 || stmt->Ist.IMark.len > 20) |
| 2380 | sanityCheckFail(bb,stmt,"IRStmt.IMark.len: implausible"); |
| 2381 | break; |
sewardj | 5a9ffab | 2005-05-12 17:55:01 +0000 | [diff] [blame] | 2382 | case Ist_AbiHint: |
| 2383 | if (typeOfIRExpr(tyenv, stmt->Ist.AbiHint.base) != gWordTy) |
| 2384 | sanityCheckFail(bb,stmt,"IRStmt.AbiHint.base: " |
| 2385 | "not :: guest word type"); |
| 2386 | break; |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2387 | case Ist_Put: |
sewardj | 6d07636 | 2004-09-23 11:06:17 +0000 | [diff] [blame] | 2388 | tcExpr( bb, stmt, stmt->Ist.Put.data, gWordTy ); |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 2389 | if (typeOfIRExpr(tyenv,stmt->Ist.Put.data) == Ity_I1) |
| 2390 | sanityCheckFail(bb,stmt,"IRStmt.Put.data: cannot Put :: Ity_I1"); |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 2391 | break; |
sewardj | d1725d1 | 2004-08-12 20:46:53 +0000 | [diff] [blame] | 2392 | case Ist_PutI: |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 2393 | tcExpr( bb, stmt, stmt->Ist.PutI.data, gWordTy ); |
sewardj | eeac841 | 2004-11-02 00:26:55 +0000 | [diff] [blame] | 2394 | tcExpr( bb, stmt, stmt->Ist.PutI.ix, gWordTy ); |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 2395 | if (typeOfIRExpr(tyenv,stmt->Ist.PutI.data) == Ity_I1) |
| 2396 | sanityCheckFail(bb,stmt,"IRStmt.PutI.data: cannot PutI :: Ity_I1"); |
sewardj | 6d07636 | 2004-09-23 11:06:17 +0000 | [diff] [blame] | 2397 | if (typeOfIRExpr(tyenv,stmt->Ist.PutI.data) |
| 2398 | != stmt->Ist.PutI.descr->elemTy) |
| 2399 | sanityCheckFail(bb,stmt,"IRStmt.PutI.data: data ty != elem ty"); |
sewardj | eeac841 | 2004-11-02 00:26:55 +0000 | [diff] [blame] | 2400 | if (typeOfIRExpr(tyenv,stmt->Ist.PutI.ix) != Ity_I32) |
| 2401 | sanityCheckFail(bb,stmt,"IRStmt.PutI.ix: not :: Ity_I32"); |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 2402 | if (!saneIRArray(stmt->Ist.PutI.descr)) |
| 2403 | sanityCheckFail(bb,stmt,"IRStmt.PutI.descr: invalid descr"); |
| 2404 | break; |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2405 | case Ist_Tmp: |
sewardj | 6d07636 | 2004-09-23 11:06:17 +0000 | [diff] [blame] | 2406 | tcExpr( bb, stmt, stmt->Ist.Tmp.data, gWordTy ); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 2407 | if (typeOfIRTemp(tyenv, stmt->Ist.Tmp.tmp) |
sewardj | 6d07636 | 2004-09-23 11:06:17 +0000 | [diff] [blame] | 2408 | != typeOfIRExpr(tyenv, stmt->Ist.Tmp.data)) |
sewardj | 6d2638e | 2004-07-15 09:38:27 +0000 | [diff] [blame] | 2409 | sanityCheckFail(bb,stmt,"IRStmt.Put.Tmp: tmp and expr do not match"); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2410 | break; |
sewardj | af1ceca | 2005-06-30 23:31:27 +0000 | [diff] [blame] | 2411 | case Ist_Store: |
| 2412 | tcExpr( bb, stmt, stmt->Ist.Store.addr, gWordTy ); |
| 2413 | tcExpr( bb, stmt, stmt->Ist.Store.data, gWordTy ); |
| 2414 | if (typeOfIRExpr(tyenv, stmt->Ist.Store.addr) != gWordTy) |
| 2415 | sanityCheckFail(bb,stmt,"IRStmt.Store.addr: not :: guest word type"); |
| 2416 | if (typeOfIRExpr(tyenv, stmt->Ist.Store.data) == Ity_I1) |
| 2417 | sanityCheckFail(bb,stmt,"IRStmt.Store.data: cannot Store :: Ity_I1"); |
| 2418 | if (stmt->Ist.Store.end != Iend_LE && stmt->Ist.Store.end != Iend_BE) |
| 2419 | sanityCheckFail(bb,stmt,"Ist.Store.end: bogus endianness"); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2420 | break; |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 2421 | case Ist_Dirty: |
| 2422 | /* Mostly check for various kinds of ill-formed dirty calls. */ |
| 2423 | d = stmt->Ist.Dirty.details; |
sewardj | 8ea867b | 2004-10-30 19:03:02 +0000 | [diff] [blame] | 2424 | if (d->cee == NULL) goto bad_dirty; |
| 2425 | if (!saneIRCallee(d->cee)) goto bad_dirty; |
sewardj | cf78790 | 2004-11-03 09:08:33 +0000 | [diff] [blame] | 2426 | if (d->cee->regparms > countArgs(d->args)) goto bad_dirty; |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 2427 | if (d->mFx == Ifx_None) { |
| 2428 | if (d->mAddr != NULL || d->mSize != 0) |
| 2429 | goto bad_dirty; |
| 2430 | } else { |
| 2431 | if (d->mAddr == NULL || d->mSize == 0) |
| 2432 | goto bad_dirty; |
| 2433 | } |
| 2434 | if (d->nFxState < 0 || d->nFxState > VEX_N_FXSTATE) |
| 2435 | goto bad_dirty; |
sewardj | c5fc7aa | 2004-10-27 23:00:55 +0000 | [diff] [blame] | 2436 | if (d->nFxState == 0 && d->needsBBP) |
| 2437 | goto bad_dirty; |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 2438 | for (i = 0; i < d->nFxState; i++) { |
| 2439 | if (d->fxState[i].fx == Ifx_None) goto bad_dirty; |
| 2440 | if (d->fxState[i].size <= 0) goto bad_dirty; |
| 2441 | } |
| 2442 | /* check types, minimally */ |
sewardj | b8385d8 | 2004-11-02 01:34:15 +0000 | [diff] [blame] | 2443 | if (d->guard == NULL) goto bad_dirty; |
sewardj | 49bfe67 | 2004-11-15 15:46:26 +0000 | [diff] [blame] | 2444 | tcExpr( bb, stmt, d->guard, gWordTy ); |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 2445 | if (typeOfIRExpr(tyenv, d->guard) != Ity_I1) |
| 2446 | sanityCheckFail(bb,stmt,"IRStmt.Dirty.guard not :: Ity_I1"); |
sewardj | 92d168d | 2004-11-15 14:22:12 +0000 | [diff] [blame] | 2447 | if (d->tmp != IRTemp_INVALID |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 2448 | && typeOfIRTemp(tyenv, d->tmp) == Ity_I1) |
| 2449 | sanityCheckFail(bb,stmt,"IRStmt.Dirty.dst :: Ity_I1"); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 2450 | for (i = 0; d->args[i] != NULL; i++) { |
sewardj | 43c5646 | 2004-11-06 12:17:57 +0000 | [diff] [blame] | 2451 | if (i >= 32) |
| 2452 | sanityCheckFail(bb,stmt,"IRStmt.Dirty: > 32 args"); |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 2453 | if (typeOfIRExpr(tyenv, d->args[i]) == Ity_I1) |
| 2454 | sanityCheckFail(bb,stmt,"IRStmt.Dirty.arg[i] :: Ity_I1"); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 2455 | } |
| 2456 | break; |
| 2457 | bad_dirty: |
| 2458 | sanityCheckFail(bb,stmt,"IRStmt.Dirty: ill-formed"); |
sewardj | d2445f6 | 2005-03-21 00:15:53 +0000 | [diff] [blame] | 2459 | case Ist_NoOp: |
sewardj | 3e83893 | 2005-01-07 12:09:15 +0000 | [diff] [blame] | 2460 | case Ist_MFence: |
| 2461 | break; |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2462 | case Ist_Exit: |
sewardj | 0276d4b | 2004-11-15 15:30:21 +0000 | [diff] [blame] | 2463 | tcExpr( bb, stmt, stmt->Ist.Exit.guard, gWordTy ); |
| 2464 | if (typeOfIRExpr(tyenv,stmt->Ist.Exit.guard) != Ity_I1) |
| 2465 | sanityCheckFail(bb,stmt,"IRStmt.Exit.guard: not :: Ity_I1"); |
sewardj | 49bfe67 | 2004-11-15 15:46:26 +0000 | [diff] [blame] | 2466 | if (!saneIRConst(stmt->Ist.Exit.dst)) |
| 2467 | sanityCheckFail(bb,stmt,"IRStmt.Exit.dst: bad dst"); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2468 | if (typeOfIRConst(stmt->Ist.Exit.dst) != gWordTy) |
| 2469 | sanityCheckFail(bb,stmt,"IRStmt.Exit.dst: not :: guest word type"); |
| 2470 | break; |
| 2471 | default: |
| 2472 | vpanic("tcStmt"); |
| 2473 | } |
| 2474 | } |
| 2475 | |
sewardj | b923075 | 2004-12-29 19:25:06 +0000 | [diff] [blame] | 2476 | void sanityCheckIRBB ( IRBB* bb, HChar* caller, |
| 2477 | Bool require_flat, IRType guest_word_size ) |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2478 | { |
| 2479 | Int i; |
| 2480 | IRStmt* stmt; |
| 2481 | Int n_temps = bb->tyenv->types_used; |
| 2482 | Int* def_counts = LibVEX_Alloc(n_temps * sizeof(Int)); |
| 2483 | |
sewardj | b923075 | 2004-12-29 19:25:06 +0000 | [diff] [blame] | 2484 | if (0) |
| 2485 | vex_printf("sanityCheck: %s\n", caller); |
| 2486 | |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2487 | vassert(guest_word_size == Ity_I32 |
sewardj | 695cff9 | 2004-10-13 14:50:14 +0000 | [diff] [blame] | 2488 | || guest_word_size == Ity_I64); |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2489 | |
sewardj | d7cb853 | 2004-08-17 23:59:23 +0000 | [diff] [blame] | 2490 | if (bb->stmts_used < 0 || bb->stmts_size < 8 |
| 2491 | || bb->stmts_used > bb->stmts_size) |
| 2492 | /* this BB is so strange we can't even print it */ |
| 2493 | vpanic("sanityCheckIRBB: stmts array limits wierd"); |
| 2494 | |
sewardj | 6d2638e | 2004-07-15 09:38:27 +0000 | [diff] [blame] | 2495 | /* Ensure each temp has a plausible type. */ |
| 2496 | for (i = 0; i < n_temps; i++) { |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 2497 | IRType ty = typeOfIRTemp(bb->tyenv,(IRTemp)i); |
sewardj | 496a58d | 2005-03-20 18:44:44 +0000 | [diff] [blame] | 2498 | if (!isPlausibleIRType(ty)) { |
sewardj | 6d2638e | 2004-07-15 09:38:27 +0000 | [diff] [blame] | 2499 | vex_printf("Temp t%d declared with implausible type 0x%x\n", |
| 2500 | i, (UInt)ty); |
| 2501 | sanityCheckFail(bb,NULL,"Temp declared with implausible type"); |
| 2502 | } |
| 2503 | } |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2504 | |
sewardj | b923075 | 2004-12-29 19:25:06 +0000 | [diff] [blame] | 2505 | /* Check for flatness, if required. */ |
| 2506 | if (require_flat) { |
| 2507 | for (i = 0; i < bb->stmts_used; i++) { |
| 2508 | stmt = bb->stmts[i]; |
| 2509 | if (!stmt) |
sewardj | d2445f6 | 2005-03-21 00:15:53 +0000 | [diff] [blame] | 2510 | sanityCheckFail(bb, stmt, "IRStmt: is NULL"); |
sewardj | b923075 | 2004-12-29 19:25:06 +0000 | [diff] [blame] | 2511 | if (!isFlatIRStmt(stmt)) |
| 2512 | sanityCheckFail(bb, stmt, "IRStmt: is not flat"); |
| 2513 | } |
sewardj | 496a58d | 2005-03-20 18:44:44 +0000 | [diff] [blame] | 2514 | if (!isIRAtom(bb->next)) |
sewardj | b923075 | 2004-12-29 19:25:06 +0000 | [diff] [blame] | 2515 | sanityCheckFail(bb, NULL, "bb->next is not an atom"); |
| 2516 | } |
| 2517 | |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2518 | /* Count the defs of each temp. Only one def is allowed. |
| 2519 | Also, check that each used temp has already been defd. */ |
sewardj | 6d2638e | 2004-07-15 09:38:27 +0000 | [diff] [blame] | 2520 | |
| 2521 | for (i = 0; i < n_temps; i++) |
| 2522 | def_counts[i] = 0; |
| 2523 | |
sewardj | d7cb853 | 2004-08-17 23:59:23 +0000 | [diff] [blame] | 2524 | for (i = 0; i < bb->stmts_used; i++) { |
| 2525 | stmt = bb->stmts[i]; |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2526 | useBeforeDef_Stmt(bb,stmt,def_counts); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 2527 | |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2528 | if (stmt->tag == Ist_Tmp) { |
| 2529 | if (stmt->Ist.Tmp.tmp < 0 || stmt->Ist.Tmp.tmp >= n_temps) |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 2530 | sanityCheckFail(bb, stmt, |
| 2531 | "IRStmt.Tmp: destination tmp is out of range"); |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2532 | def_counts[stmt->Ist.Tmp.tmp]++; |
| 2533 | if (def_counts[stmt->Ist.Tmp.tmp] > 1) |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 2534 | sanityCheckFail(bb, stmt, |
sewardj | cf78790 | 2004-11-03 09:08:33 +0000 | [diff] [blame] | 2535 | "IRStmt.Tmp: destination tmp is assigned more than once"); |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 2536 | } |
| 2537 | else |
| 2538 | if (stmt->tag == Ist_Dirty |
sewardj | 92d168d | 2004-11-15 14:22:12 +0000 | [diff] [blame] | 2539 | && stmt->Ist.Dirty.details->tmp != IRTemp_INVALID) { |
sewardj | 17442fe | 2004-09-20 14:54:28 +0000 | [diff] [blame] | 2540 | IRDirty* d = stmt->Ist.Dirty.details; |
| 2541 | if (d->tmp < 0 || d->tmp >= n_temps) |
| 2542 | sanityCheckFail(bb, stmt, |
| 2543 | "IRStmt.Dirty: destination tmp is out of range"); |
| 2544 | def_counts[d->tmp]++; |
| 2545 | if (def_counts[d->tmp] > 1) |
| 2546 | sanityCheckFail(bb, stmt, |
| 2547 | "IRStmt.Dirty: destination tmp is assigned more than once"); |
sewardj | 3543921 | 2004-07-14 22:36:10 +0000 | [diff] [blame] | 2548 | } |
| 2549 | } |
| 2550 | |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2551 | /* Typecheck everything. */ |
sewardj | d7cb853 | 2004-08-17 23:59:23 +0000 | [diff] [blame] | 2552 | for (i = 0; i < bb->stmts_used; i++) |
sewardj | 39e3f24 | 2004-08-18 16:54:52 +0000 | [diff] [blame] | 2553 | if (bb->stmts[i]) |
| 2554 | tcStmt( bb, bb->stmts[i], guest_word_size ); |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2555 | if (typeOfIRExpr(bb->tyenv,bb->next) != guest_word_size) |
| 2556 | sanityCheckFail(bb, NULL, "bb->next field has wrong type"); |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 2557 | } |
| 2558 | |
sewardj | 4345f7a | 2004-09-22 19:49:27 +0000 | [diff] [blame] | 2559 | /*---------------------------------------------------------------*/ |
| 2560 | /*--- Misc helper functions ---*/ |
| 2561 | /*---------------------------------------------------------------*/ |
| 2562 | |
| 2563 | Bool eqIRConst ( IRConst* c1, IRConst* c2 ) |
| 2564 | { |
| 2565 | if (c1->tag != c2->tag) |
| 2566 | return False; |
| 2567 | |
| 2568 | switch (c1->tag) { |
sewardj | a98bf49 | 2005-02-07 01:39:17 +0000 | [diff] [blame] | 2569 | case Ico_U1: return toBool( (1 & c1->Ico.U1) == (1 & c2->Ico.U1) ); |
| 2570 | case Ico_U8: return toBool( c1->Ico.U8 == c2->Ico.U8 ); |
| 2571 | case Ico_U16: return toBool( c1->Ico.U16 == c2->Ico.U16 ); |
| 2572 | case Ico_U32: return toBool( c1->Ico.U32 == c2->Ico.U32 ); |
| 2573 | case Ico_U64: return toBool( c1->Ico.U64 == c2->Ico.U64 ); |
| 2574 | case Ico_F64: return toBool( c1->Ico.F64 == c2->Ico.F64 ); |
sewardj | 4345f7a | 2004-09-22 19:49:27 +0000 | [diff] [blame] | 2575 | default: vpanic("eqIRConst"); |
| 2576 | } |
| 2577 | } |
| 2578 | |
sewardj | e98dcf2 | 2004-10-04 09:15:11 +0000 | [diff] [blame] | 2579 | Bool eqIRArray ( IRArray* descr1, IRArray* descr2 ) |
| 2580 | { |
sewardj | a98bf49 | 2005-02-07 01:39:17 +0000 | [diff] [blame] | 2581 | return toBool( descr1->base == descr2->base |
| 2582 | && descr1->elemTy == descr2->elemTy |
| 2583 | && descr1->nElems == descr2->nElems ); |
sewardj | e98dcf2 | 2004-10-04 09:15:11 +0000 | [diff] [blame] | 2584 | } |
| 2585 | |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 2586 | Int sizeofIRType ( IRType ty ) |
| 2587 | { |
| 2588 | switch (ty) { |
sewardj | c9a4366 | 2004-11-30 18:51:59 +0000 | [diff] [blame] | 2589 | case Ity_I8: return 1; |
| 2590 | case Ity_I16: return 2; |
| 2591 | case Ity_I32: return 4; |
| 2592 | case Ity_I64: return 8; |
| 2593 | case Ity_F32: return 4; |
| 2594 | case Ity_F64: return 8; |
| 2595 | case Ity_V128: return 16; |
sewardj | 2d3f77c | 2004-09-22 23:49:09 +0000 | [diff] [blame] | 2596 | default: vex_printf("\n"); ppIRType(ty); vex_printf("\n"); |
| 2597 | vpanic("sizeofIRType"); |
| 2598 | } |
| 2599 | } |
| 2600 | |
sewardj | 49651f4 | 2004-10-28 22:11:04 +0000 | [diff] [blame] | 2601 | IRExpr* mkIRExpr_HWord ( HWord hw ) |
| 2602 | { |
sewardj | f965526 | 2004-10-31 20:02:16 +0000 | [diff] [blame] | 2603 | vassert(sizeof(void*) == sizeof(HWord)); |
sewardj | 49651f4 | 2004-10-28 22:11:04 +0000 | [diff] [blame] | 2604 | if (sizeof(HWord) == 4) |
| 2605 | return IRExpr_Const(IRConst_U32((UInt)hw)); |
| 2606 | if (sizeof(HWord) == 8) |
sewardj | f965526 | 2004-10-31 20:02:16 +0000 | [diff] [blame] | 2607 | return IRExpr_Const(IRConst_U64((ULong)hw)); |
sewardj | 49651f4 | 2004-10-28 22:11:04 +0000 | [diff] [blame] | 2608 | vpanic("mkIRExpr_HWord"); |
| 2609 | } |
sewardj | 6efd4a1 | 2004-07-15 03:54:23 +0000 | [diff] [blame] | 2610 | |
sewardj | 2d49b43 | 2005-02-01 00:37:06 +0000 | [diff] [blame] | 2611 | IRDirty* unsafeIRDirty_0_N ( Int regparms, HChar* name, void* addr, |
sewardj | f965526 | 2004-10-31 20:02:16 +0000 | [diff] [blame] | 2612 | IRExpr** args ) |
| 2613 | { |
| 2614 | IRDirty* d = emptyIRDirty(); |
sewardj | b8385d8 | 2004-11-02 01:34:15 +0000 | [diff] [blame] | 2615 | d->cee = mkIRCallee ( regparms, name, addr ); |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 2616 | d->guard = IRExpr_Const(IRConst_U1(True)); |
sewardj | b8385d8 | 2004-11-02 01:34:15 +0000 | [diff] [blame] | 2617 | d->args = args; |
sewardj | f965526 | 2004-10-31 20:02:16 +0000 | [diff] [blame] | 2618 | return d; |
| 2619 | } |
| 2620 | |
| 2621 | IRDirty* unsafeIRDirty_1_N ( IRTemp dst, |
sewardj | 2d49b43 | 2005-02-01 00:37:06 +0000 | [diff] [blame] | 2622 | Int regparms, HChar* name, void* addr, |
sewardj | f965526 | 2004-10-31 20:02:16 +0000 | [diff] [blame] | 2623 | IRExpr** args ) |
| 2624 | { |
| 2625 | IRDirty* d = emptyIRDirty(); |
sewardj | b8385d8 | 2004-11-02 01:34:15 +0000 | [diff] [blame] | 2626 | d->cee = mkIRCallee ( regparms, name, addr ); |
sewardj | ba99931 | 2004-11-15 15:21:17 +0000 | [diff] [blame] | 2627 | d->guard = IRExpr_Const(IRConst_U1(True)); |
sewardj | b8385d8 | 2004-11-02 01:34:15 +0000 | [diff] [blame] | 2628 | d->args = args; |
| 2629 | d->tmp = dst; |
sewardj | f965526 | 2004-10-31 20:02:16 +0000 | [diff] [blame] | 2630 | return d; |
| 2631 | } |
| 2632 | |
| 2633 | IRExpr* mkIRExprCCall ( IRType retty, |
sewardj | 2d49b43 | 2005-02-01 00:37:06 +0000 | [diff] [blame] | 2634 | Int regparms, HChar* name, void* addr, |
sewardj | f965526 | 2004-10-31 20:02:16 +0000 | [diff] [blame] | 2635 | IRExpr** args ) |
| 2636 | { |
| 2637 | return IRExpr_CCall ( mkIRCallee ( regparms, name, addr ), |
| 2638 | retty, args ); |
| 2639 | } |
| 2640 | |
sewardj | 496a58d | 2005-03-20 18:44:44 +0000 | [diff] [blame] | 2641 | Bool eqIRAtom ( IRExpr* a1, IRExpr* a2 ) |
| 2642 | { |
| 2643 | vassert(isIRAtom(a1)); |
| 2644 | vassert(isIRAtom(a2)); |
| 2645 | if (a1->tag == Iex_Tmp && a2->tag == Iex_Tmp) |
| 2646 | return toBool(a1->Iex.Tmp.tmp == a2->Iex.Tmp.tmp); |
| 2647 | if (a1->tag == Iex_Const && a2->tag == Iex_Const) |
| 2648 | return eqIRConst(a1->Iex.Const.con, a2->Iex.Const.con); |
| 2649 | return False; |
| 2650 | } |
| 2651 | |
sewardj | e539a40 | 2004-07-14 18:24:17 +0000 | [diff] [blame] | 2652 | /*---------------------------------------------------------------*/ |
sewardj | c0ee2ed | 2004-07-27 10:29:41 +0000 | [diff] [blame] | 2653 | /*--- end ir/irdefs.c ---*/ |
sewardj | 887a11a | 2004-07-05 17:26:47 +0000 | [diff] [blame] | 2654 | /*---------------------------------------------------------------*/ |