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