blob: b73348785ca982e66ffeaae13f33294eb2cda49f [file] [log] [blame]
sewardjec6ad592004-06-20 12:26:53 +00001
2/*---------------------------------------------------------------*/
sewardj752f9062010-05-03 21:38:49 +00003/*--- begin ir_defs.c ---*/
sewardjec6ad592004-06-20 12:26:53 +00004/*---------------------------------------------------------------*/
5
sewardjf8ed9d82004-11-12 17:40:23 +00006/*
sewardj752f9062010-05-03 21:38:49 +00007 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
sewardjf8ed9d82004-11-12 17:40:23 +00009
sewardj752f9062010-05-03 21:38:49 +000010 Copyright (C) 2004-2010 OpenWorks LLP
11 info@open-works.net
sewardjf8ed9d82004-11-12 17:40:23 +000012
sewardj752f9062010-05-03 21:38:49 +000013 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
sewardjf8ed9d82004-11-12 17:40:23 +000017
sewardj752f9062010-05-03 21:38:49 +000018 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
sewardj7bd6ffe2005-08-03 16:07:36 +000026 02110-1301, USA.
27
sewardj752f9062010-05-03 21:38:49 +000028 The GNU General Public License is contained in the file COPYING.
sewardjf8ed9d82004-11-12 17:40:23 +000029
30 Neither the names of the U.S. Department of Energy nor the
31 University of California nor the names of its contributors may be
32 used to endorse or promote products derived from this software
33 without prior written permission.
sewardjf8ed9d82004-11-12 17:40:23 +000034*/
35
sewardj887a11a2004-07-05 17:26:47 +000036#include "libvex_basictypes.h"
37#include "libvex_ir.h"
38#include "libvex.h"
sewardjec6ad592004-06-20 12:26:53 +000039
sewardjcef7d3e2009-07-02 12:21:59 +000040#include "main_util.h"
sewardjc0ee2ed2004-07-27 10:29:41 +000041
sewardjec6ad592004-06-20 12:26:53 +000042
43/*---------------------------------------------------------------*/
44/*--- Printing the IR ---*/
45/*---------------------------------------------------------------*/
46
sewardj35421a32004-07-05 13:12:34 +000047void ppIRType ( IRType ty )
sewardjec6ad592004-06-20 12:26:53 +000048{
sewardj3e838932005-01-07 12:09:15 +000049 switch (ty) {
50 case Ity_INVALID: vex_printf("Ity_INVALID"); break;
sewardj9b967672005-02-08 11:13:09 +000051 case Ity_I1: vex_printf( "I1"); break;
52 case Ity_I8: vex_printf( "I8"); break;
53 case Ity_I16: vex_printf( "I16"); break;
54 case Ity_I32: vex_printf( "I32"); break;
55 case Ity_I64: vex_printf( "I64"); break;
56 case Ity_I128: vex_printf( "I128"); break;
57 case Ity_F32: vex_printf( "F32"); break;
58 case Ity_F64: vex_printf( "F64"); break;
sewardj3e838932005-01-07 12:09:15 +000059 case Ity_V128: vex_printf( "V128"); break;
60 default: vex_printf("ty = 0x%x\n", (Int)ty);
61 vpanic("ppIRType");
62 }
sewardjec6ad592004-06-20 12:26:53 +000063}
64
sewardj35421a32004-07-05 13:12:34 +000065void ppIRConst ( IRConst* con )
sewardjec6ad592004-06-20 12:26:53 +000066{
sewardja162c2c2005-12-18 03:07:11 +000067 union { ULong i64; Double f64; } u;
sewardj63327402006-01-25 03:26:27 +000068 vassert(sizeof(ULong) == sizeof(Double));
sewardj2d3f77c2004-09-22 23:49:09 +000069 switch (con->tag) {
sewardjba999312004-11-15 15:21:17 +000070 case Ico_U1: vex_printf( "%d:I1", con->Ico.U1 ? 1 : 0); break;
sewardj2d3f77c2004-09-22 23:49:09 +000071 case Ico_U8: vex_printf( "0x%x:I8", (UInt)(con->Ico.U8)); break;
72 case Ico_U16: vex_printf( "0x%x:I16", (UInt)(con->Ico.U16)); break;
73 case Ico_U32: vex_printf( "0x%x:I32", (UInt)(con->Ico.U32)); break;
74 case Ico_U64: vex_printf( "0x%llx:I64", (ULong)(con->Ico.U64)); break;
sewardja162c2c2005-12-18 03:07:11 +000075 case Ico_F64: u.f64 = con->Ico.F64;
76 vex_printf( "F64{0x%llx}", u.i64);
sewardj695cff92004-10-13 14:50:14 +000077 break;
sewardj2d3f77c2004-09-22 23:49:09 +000078 case Ico_F64i: vex_printf( "F64i{0x%llx}", con->Ico.F64i); break;
sewardj1e6ad742004-12-02 16:16:11 +000079 case Ico_V128: vex_printf( "V128{0x%04x}", (UInt)(con->Ico.V128)); break;
sewardj2d3f77c2004-09-22 23:49:09 +000080 default: vpanic("ppIRConst");
81 }
82}
83
sewardj8ea867b2004-10-30 19:03:02 +000084void ppIRCallee ( IRCallee* ce )
85{
86 vex_printf("%s", ce->name);
sewardj77352542004-10-30 20:39:01 +000087 if (ce->regparms > 0)
sewardj43c56462004-11-06 12:17:57 +000088 vex_printf("[rp=%d]", ce->regparms);
89 if (ce->mcx_mask > 0)
90 vex_printf("[mcx=0x%x]", ce->mcx_mask);
sewardj8ea867b2004-10-30 19:03:02 +000091 vex_printf("{%p}", (void*)ce->addr);
92}
93
sewardjdd40fdf2006-12-24 02:20:24 +000094void ppIRRegArray ( IRRegArray* arr )
sewardj2d3f77c2004-09-22 23:49:09 +000095{
sewardj0bfea7f2004-10-04 07:15:48 +000096 vex_printf("(%d:%dx", arr->base, arr->nElems);
sewardj2d3f77c2004-09-22 23:49:09 +000097 ppIRType(arr->elemTy);
sewardj0bfea7f2004-10-04 07:15:48 +000098 vex_printf(")");
sewardje3d0d2e2004-06-27 10:42:44 +000099}
100
sewardj35421a32004-07-05 13:12:34 +0000101void ppIRTemp ( IRTemp tmp )
sewardje3d0d2e2004-06-27 10:42:44 +0000102{
sewardj92d168d2004-11-15 14:22:12 +0000103 if (tmp == IRTemp_INVALID)
104 vex_printf("IRTemp_INVALID");
sewardjfbcaf332004-07-08 01:46:01 +0000105 else
sewardj41f43bc2004-07-08 14:23:22 +0000106 vex_printf( "t%d", (Int)tmp);
sewardje3d0d2e2004-06-27 10:42:44 +0000107}
108
sewardj35421a32004-07-05 13:12:34 +0000109void ppIROp ( IROp op )
sewardje3d0d2e2004-06-27 10:42:44 +0000110{
sewardjecbaee72008-11-01 23:54:45 +0000111 HChar* str = NULL;
sewardja98bf492005-02-07 01:39:17 +0000112 IROp base;
sewardj41f43bc2004-07-08 14:23:22 +0000113 switch (op) {
114 case Iop_Add8 ... Iop_Add64:
115 str = "Add"; base = Iop_Add8; break;
116 case Iop_Sub8 ... Iop_Sub64:
117 str = "Sub"; base = Iop_Sub8; break;
118 case Iop_Mul8 ... Iop_Mul64:
119 str = "Mul"; base = Iop_Mul8; break;
120 case Iop_Or8 ... Iop_Or64:
121 str = "Or"; base = Iop_Or8; break;
122 case Iop_And8 ... Iop_And64:
123 str = "And"; base = Iop_And8; break;
124 case Iop_Xor8 ... Iop_Xor64:
125 str = "Xor"; base = Iop_Xor8; break;
126 case Iop_Shl8 ... Iop_Shl64:
127 str = "Shl"; base = Iop_Shl8; break;
128 case Iop_Shr8 ... Iop_Shr64:
129 str = "Shr"; base = Iop_Shr8; break;
130 case Iop_Sar8 ... Iop_Sar64:
131 str = "Sar"; base = Iop_Sar8; break;
sewardje90ad6a2004-07-10 19:02:10 +0000132 case Iop_CmpEQ8 ... Iop_CmpEQ64:
133 str = "CmpEQ"; base = Iop_CmpEQ8; break;
134 case Iop_CmpNE8 ... Iop_CmpNE64:
135 str = "CmpNE"; base = Iop_CmpNE8; break;
sewardj1fb8c922009-07-12 12:56:53 +0000136 case Iop_CasCmpEQ8 ... Iop_CasCmpEQ64:
137 str = "CasCmpEQ"; base = Iop_CasCmpEQ8; break;
138 case Iop_CasCmpNE8 ... Iop_CasCmpNE64:
139 str = "CasCmpNE"; base = Iop_CasCmpNE8; break;
sewardj41f43bc2004-07-08 14:23:22 +0000140 case Iop_Not8 ... Iop_Not64:
141 str = "Not"; base = Iop_Not8; break;
142 /* other cases must explicitly "return;" */
sewardj9690d922004-07-14 01:39:17 +0000143 case Iop_8Uto16: vex_printf("8Uto16"); return;
144 case Iop_8Uto32: vex_printf("8Uto32"); return;
145 case Iop_16Uto32: vex_printf("16Uto32"); return;
146 case Iop_8Sto16: vex_printf("8Sto16"); return;
147 case Iop_8Sto32: vex_printf("8Sto32"); return;
148 case Iop_16Sto32: vex_printf("16Sto32"); return;
sewardjbb53f8c2004-08-14 11:50:01 +0000149 case Iop_32Sto64: vex_printf("32Sto64"); return;
sewardje5427e82004-09-11 19:43:51 +0000150 case Iop_32Uto64: vex_printf("32Uto64"); return;
sewardja2384712004-07-29 14:36:40 +0000151 case Iop_32to8: vex_printf("32to8"); return;
sewardj291a7e82005-04-27 11:42:44 +0000152 case Iop_16Uto64: vex_printf("16Uto64"); return;
153 case Iop_16Sto64: vex_printf("16Sto64"); return;
154 case Iop_8Uto64: vex_printf("8Uto64"); return;
155 case Iop_8Sto64: vex_printf("8Sto64"); return;
156 case Iop_64to16: vex_printf("64to16"); return;
157 case Iop_64to8: vex_printf("64to8"); return;
sewardj6e797c52004-10-13 15:20:17 +0000158
159 case Iop_Not1: vex_printf("Not1"); return;
sewardj9690d922004-07-14 01:39:17 +0000160 case Iop_32to1: vex_printf("32to1"); return;
sewardj291a7e82005-04-27 11:42:44 +0000161 case Iop_64to1: vex_printf("64to1"); return;
sewardj9690d922004-07-14 01:39:17 +0000162 case Iop_1Uto8: vex_printf("1Uto8"); return;
sewardj84ff0652004-08-23 16:16:08 +0000163 case Iop_1Uto32: vex_printf("1Uto32"); return;
sewardj291a7e82005-04-27 11:42:44 +0000164 case Iop_1Uto64: vex_printf("1Uto64"); return;
sewardjfd332772004-11-09 16:01:40 +0000165 case Iop_1Sto8: vex_printf("1Sto8"); return;
sewardj8eda6302004-11-05 01:55:46 +0000166 case Iop_1Sto16: vex_printf("1Sto16"); return;
sewardj415d9352004-11-04 15:20:15 +0000167 case Iop_1Sto32: vex_printf("1Sto32"); return;
sewardjb5874aa2004-11-04 16:57:50 +0000168 case Iop_1Sto64: vex_printf("1Sto64"); return;
sewardj9690d922004-07-14 01:39:17 +0000169
170 case Iop_MullS8: vex_printf("MullS8"); return;
171 case Iop_MullS16: vex_printf("MullS16"); return;
172 case Iop_MullS32: vex_printf("MullS32"); return;
sewardj9b967672005-02-08 11:13:09 +0000173 case Iop_MullS64: vex_printf("MullS64"); return;
sewardj9690d922004-07-14 01:39:17 +0000174 case Iop_MullU8: vex_printf("MullU8"); return;
175 case Iop_MullU16: vex_printf("MullU16"); return;
176 case Iop_MullU32: vex_printf("MullU32"); return;
sewardj9b967672005-02-08 11:13:09 +0000177 case Iop_MullU64: vex_printf("MullU64"); return;
sewardj9690d922004-07-14 01:39:17 +0000178
sewardjf53b7352005-04-06 20:01:56 +0000179 case Iop_Clz64: vex_printf("Clz64"); return;
sewardjce646f22004-08-31 23:55:54 +0000180 case Iop_Clz32: vex_printf("Clz32"); return;
sewardjf53b7352005-04-06 20:01:56 +0000181 case Iop_Ctz64: vex_printf("Ctz64"); return;
sewardjce646f22004-08-31 23:55:54 +0000182 case Iop_Ctz32: vex_printf("Ctz32"); return;
183
sewardj84ff0652004-08-23 16:16:08 +0000184 case Iop_CmpLT32S: vex_printf("CmpLT32S"); return;
185 case Iop_CmpLE32S: vex_printf("CmpLE32S"); return;
186 case Iop_CmpLT32U: vex_printf("CmpLT32U"); return;
187 case Iop_CmpLE32U: vex_printf("CmpLE32U"); return;
188
sewardj98540072005-04-26 01:52:01 +0000189 case Iop_CmpLT64S: vex_printf("CmpLT64S"); return;
190 case Iop_CmpLE64S: vex_printf("CmpLE64S"); return;
191 case Iop_CmpLT64U: vex_printf("CmpLT64U"); return;
192 case Iop_CmpLE64U: vex_printf("CmpLE64U"); return;
193
sewardj0033ddc2005-04-26 23:34:34 +0000194 case Iop_CmpNEZ8: vex_printf("CmpNEZ8"); return;
195 case Iop_CmpNEZ16: vex_printf("CmpNEZ16"); return;
196 case Iop_CmpNEZ32: vex_printf("CmpNEZ32"); return;
197 case Iop_CmpNEZ64: vex_printf("CmpNEZ64"); return;
198
sewardjeb17e492007-08-25 23:07:44 +0000199 case Iop_CmpwNEZ32: vex_printf("CmpwNEZ32"); return;
200 case Iop_CmpwNEZ64: vex_printf("CmpwNEZ64"); return;
201
202 case Iop_Left8: vex_printf("Left8"); return;
203 case Iop_Left16: vex_printf("Left16"); return;
204 case Iop_Left32: vex_printf("Left32"); return;
205 case Iop_Left64: vex_printf("Left64"); return;
sewardj478646f2008-05-01 20:13:04 +0000206 case Iop_Max32U: vex_printf("Max32U"); return;
sewardjeb17e492007-08-25 23:07:44 +0000207
sewardjb51f0f42005-07-18 11:38:02 +0000208 case Iop_CmpORD32U: vex_printf("CmpORD32U"); return;
209 case Iop_CmpORD32S: vex_printf("CmpORD32S"); return;
210
cerion2831b002005-11-30 19:55:22 +0000211 case Iop_CmpORD64U: vex_printf("CmpORD64U"); return;
212 case Iop_CmpORD64S: vex_printf("CmpORD64S"); return;
213
cerion5c8a0cb2005-02-03 13:59:46 +0000214 case Iop_DivU32: vex_printf("DivU32"); return;
215 case Iop_DivS32: vex_printf("DivS32"); return;
cerionf0de28c2005-12-13 20:21:11 +0000216 case Iop_DivU64: vex_printf("DivU64"); return;
217 case Iop_DivS64: vex_printf("DivS64"); return;
cerion5c8a0cb2005-02-03 13:59:46 +0000218
sewardj9690d922004-07-14 01:39:17 +0000219 case Iop_DivModU64to32: vex_printf("DivModU64to32"); return;
220 case Iop_DivModS64to32: vex_printf("DivModS64to32"); return;
221
sewardj343b9d02005-01-31 18:08:45 +0000222 case Iop_DivModU128to64: vex_printf("DivModU128to64"); return;
223 case Iop_DivModS128to64: vex_printf("DivModS128to64"); return;
224
sewardjb81f8b32004-07-30 10:17:50 +0000225 case Iop_16HIto8: vex_printf("16HIto8"); return;
226 case Iop_16to8: vex_printf("16to8"); return;
227 case Iop_8HLto16: vex_printf("8HLto16"); return;
228
sewardj8c7f1ab2004-07-29 20:31:09 +0000229 case Iop_32HIto16: vex_printf("32HIto16"); return;
230 case Iop_32to16: vex_printf("32to16"); return;
231 case Iop_16HLto32: vex_printf("16HLto32"); return;
232
sewardj9690d922004-07-14 01:39:17 +0000233 case Iop_64HIto32: vex_printf("64HIto32"); return;
sewardj8c7f1ab2004-07-29 20:31:09 +0000234 case Iop_64to32: vex_printf("64to32"); return;
sewardj9690d922004-07-14 01:39:17 +0000235 case Iop_32HLto64: vex_printf("32HLto64"); return;
236
sewardj9b967672005-02-08 11:13:09 +0000237 case Iop_128HIto64: vex_printf("128HIto64"); return;
238 case Iop_128to64: vex_printf("128to64"); return;
239 case Iop_64HLto128: vex_printf("64HLto128"); return;
240
sewardjcfded9a2004-09-09 11:44:16 +0000241 case Iop_AddF64: vex_printf("AddF64"); return;
242 case Iop_SubF64: vex_printf("SubF64"); return;
243 case Iop_MulF64: vex_printf("MulF64"); return;
244 case Iop_DivF64: vex_printf("DivF64"); return;
sewardjb183b852006-02-03 16:08:03 +0000245 case Iop_AddF64r32: vex_printf("AddF64r32"); return;
246 case Iop_SubF64r32: vex_printf("SubF64r32"); return;
247 case Iop_MulF64r32: vex_printf("MulF64r32"); return;
248 case Iop_DivF64r32: vex_printf("DivF64r32"); return;
sewardj6c299f32009-12-31 18:00:12 +0000249 case Iop_AddF32: vex_printf("AddF32"); return;
250 case Iop_SubF32: vex_printf("SubF32"); return;
251 case Iop_MulF32: vex_printf("MulF32"); return;
252 case Iop_DivF32: vex_printf("DivF32"); return;
sewardj46de4072004-09-11 19:23:24 +0000253
sewardj442d0be2004-10-15 22:57:13 +0000254 case Iop_ScaleF64: vex_printf("ScaleF64"); return;
255 case Iop_AtanF64: vex_printf("AtanF64"); return;
256 case Iop_Yl2xF64: vex_printf("Yl2xF64"); return;
257 case Iop_Yl2xp1F64: vex_printf("Yl2xp1F64"); return;
258 case Iop_PRemF64: vex_printf("PRemF64"); return;
259 case Iop_PRemC3210F64: vex_printf("PRemC3210F64"); return;
260 case Iop_PRem1F64: vex_printf("PRem1F64"); return;
261 case Iop_PRem1C3210F64: vex_printf("PRem1C3210F64"); return;
262 case Iop_NegF64: vex_printf("NegF64"); return;
sewardj6c299f32009-12-31 18:00:12 +0000263 case Iop_AbsF64: vex_printf("AbsF64"); return;
264 case Iop_NegF32: vex_printf("NegF32"); return;
265 case Iop_AbsF32: vex_printf("AbsF32"); return;
sewardj442d0be2004-10-15 22:57:13 +0000266 case Iop_SqrtF64: vex_printf("SqrtF64"); return;
sewardj6c299f32009-12-31 18:00:12 +0000267 case Iop_SqrtF32: vex_printf("SqrtF32"); return;
sewardjcfded9a2004-09-09 11:44:16 +0000268 case Iop_SinF64: vex_printf("SinF64"); return;
269 case Iop_CosF64: vex_printf("CosF64"); return;
sewardj99016a72004-10-15 22:09:17 +0000270 case Iop_TanF64: vex_printf("TanF64"); return;
sewardj06c32a02004-09-12 12:07:34 +0000271 case Iop_2xm1F64: vex_printf("2xm1F64"); return;
sewardjbdc7d212004-09-09 02:46:40 +0000272
sewardj40c80262006-02-08 19:30:46 +0000273 case Iop_MAddF64: vex_printf("MAddF64"); return;
274 case Iop_MSubF64: vex_printf("MSubF64"); return;
275 case Iop_MAddF64r32: vex_printf("MAddF64r32"); return;
276 case Iop_MSubF64r32: vex_printf("MSubF64r32"); return;
277
278 case Iop_Est5FRSqrt: vex_printf("Est5FRSqrt"); return;
sewardj0f1ef862008-08-08 08:37:06 +0000279 case Iop_RoundF64toF64_NEAREST: vex_printf("RoundF64toF64_NEAREST"); return;
280 case Iop_RoundF64toF64_NegINF: vex_printf("RoundF64toF64_NegINF"); return;
281 case Iop_RoundF64toF64_PosINF: vex_printf("RoundF64toF64_PosINF"); return;
282 case Iop_RoundF64toF64_ZERO: vex_printf("RoundF64toF64_ZERO"); return;
283
sewardjb183b852006-02-03 16:08:03 +0000284 case Iop_TruncF64asF32: vex_printf("TruncF64asF32"); return;
sewardja0e3d422007-08-28 06:06:57 +0000285 case Iop_CalcFPRF: vex_printf("CalcFPRF"); return;
sewardjbaf971a2006-01-27 15:09:35 +0000286
sewardje2ea1762010-09-22 00:56:37 +0000287 case Iop_Add16x2: vex_printf("Add16x2"); return;
288 case Iop_Sub16x2: vex_printf("Sub16x2"); return;
289 case Iop_QAdd16Sx2: vex_printf("QAdd16Sx2"); return;
290 case Iop_QAdd16Ux2: vex_printf("QAdd16Ux2"); return;
291 case Iop_QSub16Sx2: vex_printf("QSub16Sx2"); return;
292 case Iop_QSub16Ux2: vex_printf("QSub16Ux2"); return;
293 case Iop_HAdd16Ux2: vex_printf("HAdd16Ux2"); return;
294 case Iop_HAdd16Sx2: vex_printf("HAdd16Sx2"); return;
295 case Iop_HSub16Ux2: vex_printf("HSub16Ux2"); return;
296 case Iop_HSub16Sx2: vex_printf("HSub16Sx2"); return;
297
298 case Iop_Add8x4: vex_printf("Add8x4"); return;
299 case Iop_Sub8x4: vex_printf("Sub8x4"); return;
300 case Iop_QAdd8Sx4: vex_printf("QAdd8Sx4"); return;
301 case Iop_QAdd8Ux4: vex_printf("QAdd8Ux4"); return;
302 case Iop_QSub8Sx4: vex_printf("QSub8Sx4"); return;
303 case Iop_QSub8Ux4: vex_printf("QSub8Ux4"); return;
304 case Iop_HAdd8Ux4: vex_printf("HAdd8Ux4"); return;
305 case Iop_HAdd8Sx4: vex_printf("HAdd8Sx4"); return;
306 case Iop_HSub8Ux4: vex_printf("HSub8Ux4"); return;
307 case Iop_HSub8Sx4: vex_printf("HSub8Sx4"); return;
308
309 case Iop_CmpNEZ16x2: vex_printf("CmpNEZ16x2"); return;
310 case Iop_CmpNEZ8x4: vex_printf("CmpNEZ8x4"); return;
311
sewardj46de4072004-09-11 19:23:24 +0000312 case Iop_CmpF64: vex_printf("CmpF64"); return;
313
sewardj6c299f32009-12-31 18:00:12 +0000314 case Iop_F64toI16S: vex_printf("F64toI16S"); return;
315 case Iop_F64toI32S: vex_printf("F64toI32S"); return;
316 case Iop_F64toI64S: vex_printf("F64toI64S"); return;
sewardj3bca9062004-12-04 14:36:09 +0000317
sewardj6c299f32009-12-31 18:00:12 +0000318 case Iop_F64toI32U: vex_printf("F64toI32U"); return;
319
320 case Iop_I16StoF64: vex_printf("I16StoF64"); return;
321 case Iop_I32StoF64: vex_printf("I32StoF64"); return;
322 case Iop_I64StoF64: vex_printf("I64StoF64"); return;
323
324 case Iop_I32UtoF64: vex_printf("I32UtoF64"); return;
sewardjcfded9a2004-09-09 11:44:16 +0000325
sewardj89cd0932004-09-08 18:23:25 +0000326 case Iop_F32toF64: vex_printf("F32toF64"); return;
327 case Iop_F64toF32: vex_printf("F64toF32"); return;
sewardjbb53f8c2004-08-14 11:50:01 +0000328
sewardjb183b852006-02-03 16:08:03 +0000329 case Iop_RoundF64toInt: vex_printf("RoundF64toInt"); return;
sewardjd15b5972010-06-27 09:06:34 +0000330 case Iop_RoundF32toInt: vex_printf("RoundF32toInt"); return;
sewardjb183b852006-02-03 16:08:03 +0000331 case Iop_RoundF64toF32: vex_printf("RoundF64toF32"); return;
sewardj3bca9062004-12-04 14:36:09 +0000332
sewardj17442fe2004-09-20 14:54:28 +0000333 case Iop_ReinterpF64asI64: vex_printf("ReinterpF64asI64"); return;
334 case Iop_ReinterpI64asF64: vex_printf("ReinterpI64asF64"); return;
sewardjfc1b5412007-01-09 15:20:07 +0000335 case Iop_ReinterpF32asI32: vex_printf("ReinterpF32asI32"); return;
sewardjfd226452004-12-07 19:02:18 +0000336 case Iop_ReinterpI32asF32: vex_printf("ReinterpI32asF32"); return;
sewardj17442fe2004-09-20 14:54:28 +0000337
sewardj228c7c82008-07-29 09:47:21 +0000338 case Iop_I32UtoFx4: vex_printf("I32UtoFx4"); return;
339 case Iop_I32StoFx4: vex_printf("I32StoFx4"); return;
cerionf294eb32005-11-16 17:21:10 +0000340
sewardj2fdd4162010-08-22 12:59:02 +0000341 case Iop_F32toF16x4: vex_printf("F32toF16x4"); return;
342 case Iop_F16toF32x4: vex_printf("F16toF32x4"); return;
343
344 case Iop_Rsqrte32Fx4: vex_printf("VRsqrte32Fx4"); return;
345 case Iop_Rsqrte32x4: vex_printf("VRsqrte32x4"); return;
346 case Iop_Rsqrte32Fx2: vex_printf("VRsqrte32Fx2"); return;
347 case Iop_Rsqrte32x2: vex_printf("VRsqrte32x2"); return;
348
sewardj228c7c82008-07-29 09:47:21 +0000349 case Iop_QFtoI32Ux4_RZ: vex_printf("QFtoI32Ux4_RZ"); return;
350 case Iop_QFtoI32Sx4_RZ: vex_printf("QFtoI32Sx4_RZ"); return;
cerionf294eb32005-11-16 17:21:10 +0000351
sewardj2fdd4162010-08-22 12:59:02 +0000352 case Iop_FtoI32Ux4_RZ: vex_printf("FtoI32Ux4_RZ"); return;
353 case Iop_FtoI32Sx4_RZ: vex_printf("FtoI32Sx4_RZ"); return;
354
355 case Iop_I32UtoFx2: vex_printf("I32UtoFx2"); return;
356 case Iop_I32StoFx2: vex_printf("I32StoFx2"); return;
357
358 case Iop_FtoI32Ux2_RZ: vex_printf("FtoI32Ux2_RZ"); return;
359 case Iop_FtoI32Sx2_RZ: vex_printf("FtoI32Sx2_RZ"); return;
360
sewardj228c7c82008-07-29 09:47:21 +0000361 case Iop_RoundF32x4_RM: vex_printf("RoundF32x4_RM"); return;
362 case Iop_RoundF32x4_RP: vex_printf("RoundF32x4_RP"); return;
363 case Iop_RoundF32x4_RN: vex_printf("RoundF32x4_RN"); return;
364 case Iop_RoundF32x4_RZ: vex_printf("RoundF32x4_RZ"); return;
cerionf294eb32005-11-16 17:21:10 +0000365
sewardj2fdd4162010-08-22 12:59:02 +0000366 case Iop_Abs8x8: vex_printf("Abs8x8"); return;
367 case Iop_Abs16x4: vex_printf("Abs16x4"); return;
368 case Iop_Abs32x2: vex_printf("Abs32x2"); return;
sewardj38a3f862005-01-13 15:06:51 +0000369 case Iop_Add8x8: vex_printf("Add8x8"); return;
370 case Iop_Add16x4: vex_printf("Add16x4"); return;
371 case Iop_Add32x2: vex_printf("Add32x2"); return;
372 case Iop_QAdd8Ux8: vex_printf("QAdd8Ux8"); return;
373 case Iop_QAdd16Ux4: vex_printf("QAdd16Ux4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000374 case Iop_QAdd32Ux2: vex_printf("QAdd32Ux2"); return;
375 case Iop_QAdd64Ux1: vex_printf("QAdd64Ux1"); return;
sewardj38a3f862005-01-13 15:06:51 +0000376 case Iop_QAdd8Sx8: vex_printf("QAdd8Sx8"); return;
377 case Iop_QAdd16Sx4: vex_printf("QAdd16Sx4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000378 case Iop_QAdd32Sx2: vex_printf("QAdd32Sx2"); return;
379 case Iop_QAdd64Sx1: vex_printf("QAdd64Sx1"); return;
380 case Iop_PwAdd8x8: vex_printf("PwAdd8x8"); return;
381 case Iop_PwAdd16x4: vex_printf("PwAdd16x4"); return;
382 case Iop_PwAdd32x2: vex_printf("PwAdd32x2"); return;
383 case Iop_PwAdd32Fx2: vex_printf("PwAdd32Fx2"); return;
384 case Iop_PwAddL8Ux8: vex_printf("PwAddL8Ux8"); return;
385 case Iop_PwAddL16Ux4: vex_printf("PwAddL16Ux4"); return;
386 case Iop_PwAddL32Ux2: vex_printf("PwAddL32Ux2"); return;
387 case Iop_PwAddL8Sx8: vex_printf("PwAddL8Sx8"); return;
388 case Iop_PwAddL16Sx4: vex_printf("PwAddL16Sx4"); return;
389 case Iop_PwAddL32Sx2: vex_printf("PwAddL32Sx2"); return;
sewardj38a3f862005-01-13 15:06:51 +0000390 case Iop_Sub8x8: vex_printf("Sub8x8"); return;
391 case Iop_Sub16x4: vex_printf("Sub16x4"); return;
392 case Iop_Sub32x2: vex_printf("Sub32x2"); return;
393 case Iop_QSub8Ux8: vex_printf("QSub8Ux8"); return;
394 case Iop_QSub16Ux4: vex_printf("QSub16Ux4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000395 case Iop_QSub32Ux2: vex_printf("QSub32Ux2"); return;
396 case Iop_QSub64Ux1: vex_printf("QSub64Ux1"); return;
sewardj38a3f862005-01-13 15:06:51 +0000397 case Iop_QSub8Sx8: vex_printf("QSub8Sx8"); return;
398 case Iop_QSub16Sx4: vex_printf("QSub16Sx4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000399 case Iop_QSub32Sx2: vex_printf("QSub32Sx2"); return;
400 case Iop_QSub64Sx1: vex_printf("QSub64Sx1"); return;
401 case Iop_Mul8x8: vex_printf("Mul8x8"); return;
sewardj38a3f862005-01-13 15:06:51 +0000402 case Iop_Mul16x4: vex_printf("Mul16x4"); return;
sewardjd166e282008-02-06 11:42:45 +0000403 case Iop_Mul32x2: vex_printf("Mul32x2"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000404 case Iop_Mul32Fx2: vex_printf("Mul32Fx2"); return;
405 case Iop_PolynomialMul8x8: vex_printf("PolynomialMul8x8"); return;
sewardj38a3f862005-01-13 15:06:51 +0000406 case Iop_MulHi16Ux4: vex_printf("MulHi16Ux4"); return;
407 case Iop_MulHi16Sx4: vex_printf("MulHi16Sx4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000408 case Iop_QDMulHi16Sx4: vex_printf("QDMulHi16Sx4"); return;
409 case Iop_QDMulHi32Sx2: vex_printf("QDMulHi32Sx2"); return;
410 case Iop_QRDMulHi16Sx4: vex_printf("QRDMulHi16Sx4"); return;
411 case Iop_QRDMulHi32Sx2: vex_printf("QRDMulHi32Sx2"); return;
412 case Iop_QDMulLong16Sx4: vex_printf("QDMulLong16Sx4"); return;
413 case Iop_QDMulLong32Sx2: vex_printf("QDMulLong32Sx2"); return;
sewardj38a3f862005-01-13 15:06:51 +0000414 case Iop_Avg8Ux8: vex_printf("Avg8Ux8"); return;
415 case Iop_Avg16Ux4: vex_printf("Avg16Ux4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000416 case Iop_Max8Sx8: vex_printf("Max8Sx8"); return;
sewardj38a3f862005-01-13 15:06:51 +0000417 case Iop_Max16Sx4: vex_printf("Max16Sx4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000418 case Iop_Max32Sx2: vex_printf("Max32Sx2"); return;
sewardj38a3f862005-01-13 15:06:51 +0000419 case Iop_Max8Ux8: vex_printf("Max8Ux8"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000420 case Iop_Max16Ux4: vex_printf("Max16Ux4"); return;
421 case Iop_Max32Ux2: vex_printf("Max32Ux2"); return;
422 case Iop_Min8Sx8: vex_printf("Min8Sx8"); return;
sewardj38a3f862005-01-13 15:06:51 +0000423 case Iop_Min16Sx4: vex_printf("Min16Sx4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000424 case Iop_Min32Sx2: vex_printf("Min32Sx2"); return;
sewardj38a3f862005-01-13 15:06:51 +0000425 case Iop_Min8Ux8: vex_printf("Min8Ux8"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000426 case Iop_Min16Ux4: vex_printf("Min16Ux4"); return;
427 case Iop_Min32Ux2: vex_printf("Min32Ux2"); return;
428 case Iop_PwMax8Sx8: vex_printf("PwMax8Sx8"); return;
429 case Iop_PwMax16Sx4: vex_printf("PwMax16Sx4"); return;
430 case Iop_PwMax32Sx2: vex_printf("PwMax32Sx2"); return;
431 case Iop_PwMax8Ux8: vex_printf("PwMax8Ux8"); return;
432 case Iop_PwMax16Ux4: vex_printf("PwMax16Ux4"); return;
433 case Iop_PwMax32Ux2: vex_printf("PwMax32Ux2"); return;
434 case Iop_PwMin8Sx8: vex_printf("PwMin8Sx8"); return;
435 case Iop_PwMin16Sx4: vex_printf("PwMin16Sx4"); return;
436 case Iop_PwMin32Sx2: vex_printf("PwMin32Sx2"); return;
437 case Iop_PwMin8Ux8: vex_printf("PwMin8Ux8"); return;
438 case Iop_PwMin16Ux4: vex_printf("PwMin16Ux4"); return;
439 case Iop_PwMin32Ux2: vex_printf("PwMin32Ux2"); return;
sewardj38a3f862005-01-13 15:06:51 +0000440 case Iop_CmpEQ8x8: vex_printf("CmpEQ8x8"); return;
441 case Iop_CmpEQ16x4: vex_printf("CmpEQ16x4"); return;
442 case Iop_CmpEQ32x2: vex_printf("CmpEQ32x2"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000443 case Iop_CmpGT8Ux8: vex_printf("CmpGT8Ux8"); return;
444 case Iop_CmpGT16Ux4: vex_printf("CmpGT16Ux4"); return;
445 case Iop_CmpGT32Ux2: vex_printf("CmpGT32Ux2"); return;
sewardj38a3f862005-01-13 15:06:51 +0000446 case Iop_CmpGT8Sx8: vex_printf("CmpGT8Sx8"); return;
447 case Iop_CmpGT16Sx4: vex_printf("CmpGT16Sx4"); return;
448 case Iop_CmpGT32Sx2: vex_printf("CmpGT32Sx2"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000449 case Iop_Cnt8x8: vex_printf("Cnt8x8"); return;
450 case Iop_Clz8Sx8: vex_printf("Clz8Sx8"); return;
451 case Iop_Clz16Sx4: vex_printf("Clz16Sx4"); return;
452 case Iop_Clz32Sx2: vex_printf("Clz32Sx2"); return;
453 case Iop_Cls8Sx8: vex_printf("Cls8Sx8"); return;
454 case Iop_Cls16Sx4: vex_printf("Cls16Sx4"); return;
455 case Iop_Cls32Sx2: vex_printf("Cls32Sx2"); return;
sewardjd166e282008-02-06 11:42:45 +0000456 case Iop_ShlN8x8: vex_printf("ShlN8x8"); return;
sewardj38a3f862005-01-13 15:06:51 +0000457 case Iop_ShlN16x4: vex_printf("ShlN16x4"); return;
458 case Iop_ShlN32x2: vex_printf("ShlN32x2"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000459 case Iop_ShrN8x8: vex_printf("ShrN8x8"); return;
sewardj38a3f862005-01-13 15:06:51 +0000460 case Iop_ShrN16x4: vex_printf("ShrN16x4"); return;
461 case Iop_ShrN32x2: vex_printf("ShrN32x2"); return;
sewardjd71ba832006-12-27 01:15:29 +0000462 case Iop_SarN8x8: vex_printf("SarN8x8"); return;
sewardj38a3f862005-01-13 15:06:51 +0000463 case Iop_SarN16x4: vex_printf("SarN16x4"); return;
464 case Iop_SarN32x2: vex_printf("SarN32x2"); return;
465 case Iop_QNarrow16Ux4: vex_printf("QNarrow16Ux4"); return;
466 case Iop_QNarrow16Sx4: vex_printf("QNarrow16Sx4"); return;
467 case Iop_QNarrow32Sx2: vex_printf("QNarrow32Sx2"); return;
468 case Iop_InterleaveHI8x8: vex_printf("InterleaveHI8x8"); return;
469 case Iop_InterleaveHI16x4: vex_printf("InterleaveHI16x4"); return;
470 case Iop_InterleaveHI32x2: vex_printf("InterleaveHI32x2"); return;
471 case Iop_InterleaveLO8x8: vex_printf("InterleaveLO8x8"); return;
472 case Iop_InterleaveLO16x4: vex_printf("InterleaveLO16x4"); return;
473 case Iop_InterleaveLO32x2: vex_printf("InterleaveLO32x2"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000474 case Iop_CatOddLanes8x8: vex_printf("CatOddLanes8x8"); return;
sewardjd166e282008-02-06 11:42:45 +0000475 case Iop_CatOddLanes16x4: vex_printf("CatOddLanes16x4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000476 case Iop_CatEvenLanes8x8: vex_printf("CatEvenLanes8x8"); return;
sewardjd166e282008-02-06 11:42:45 +0000477 case Iop_CatEvenLanes16x4: vex_printf("CatEvenLanes16x4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000478 case Iop_InterleaveOddLanes8x8: vex_printf("InterleaveOddLanes8x8"); return;
479 case Iop_InterleaveOddLanes16x4: vex_printf("InterleaveOddLanes16x4"); return;
480 case Iop_InterleaveEvenLanes8x8: vex_printf("InterleaveEvenLanes8x8"); return;
481 case Iop_InterleaveEvenLanes16x4: vex_printf("InterleaveEvenLanes16x4"); return;
482 case Iop_Shl8x8: vex_printf("Shl8x8"); return;
483 case Iop_Shl16x4: vex_printf("Shl16x4"); return;
484 case Iop_Shl32x2: vex_printf("Shl32x2"); return;
485 case Iop_Shr8x8: vex_printf("Shr8x8"); return;
486 case Iop_Shr16x4: vex_printf("Shr16x4"); return;
487 case Iop_Shr32x2: vex_printf("Shr32x2"); return;
488 case Iop_QShl8x8: vex_printf("QShl8x8"); return;
489 case Iop_QShl16x4: vex_printf("QShl16x4"); return;
490 case Iop_QShl32x2: vex_printf("QShl32x2"); return;
491 case Iop_QShl64x1: vex_printf("QShl64x1"); return;
492 case Iop_QSal8x8: vex_printf("QSal8x8"); return;
493 case Iop_QSal16x4: vex_printf("QSal16x4"); return;
494 case Iop_QSal32x2: vex_printf("QSal32x2"); return;
495 case Iop_QSal64x1: vex_printf("QSal64x1"); return;
496 case Iop_QShlN8x8: vex_printf("QShlN8x8"); return;
497 case Iop_QShlN16x4: vex_printf("QShlN16x4"); return;
498 case Iop_QShlN32x2: vex_printf("QShlN32x2"); return;
499 case Iop_QShlN64x1: vex_printf("QShlN64x1"); return;
500 case Iop_QShlN8Sx8: vex_printf("QShlN8Sx8"); return;
501 case Iop_QShlN16Sx4: vex_printf("QShlN16Sx4"); return;
502 case Iop_QShlN32Sx2: vex_printf("QShlN32Sx2"); return;
503 case Iop_QShlN64Sx1: vex_printf("QShlN64Sx1"); return;
504 case Iop_QSalN8x8: vex_printf("QSalN8x8"); return;
505 case Iop_QSalN16x4: vex_printf("QSalN16x4"); return;
506 case Iop_QSalN32x2: vex_printf("QSalN32x2"); return;
507 case Iop_QSalN64x1: vex_printf("QSalN64x1"); return;
508 case Iop_Sar8x8: vex_printf("Sar8x8"); return;
509 case Iop_Sar16x4: vex_printf("Sar16x4"); return;
510 case Iop_Sar32x2: vex_printf("Sar32x2"); return;
511 case Iop_Sal8x8: vex_printf("Sal8x8"); return;
512 case Iop_Sal16x4: vex_printf("Sal16x4"); return;
513 case Iop_Sal32x2: vex_printf("Sal32x2"); return;
514 case Iop_Sal64x1: vex_printf("Sal64x1"); return;
sewardj228c7c82008-07-29 09:47:21 +0000515 case Iop_Perm8x8: vex_printf("Perm8x8"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000516 case Iop_Reverse16_8x8: vex_printf("Reverse16_8x8"); return;
517 case Iop_Reverse32_8x8: vex_printf("Reverse32_8x8"); return;
518 case Iop_Reverse32_16x4: vex_printf("Reverse32_16x4"); return;
519 case Iop_Reverse64_8x8: vex_printf("Reverse64_8x8"); return;
520 case Iop_Reverse64_16x4: vex_printf("Reverse64_16x4"); return;
521 case Iop_Reverse64_32x2: vex_printf("Reverse64_32x2"); return;
522 case Iop_Abs32Fx2: vex_printf("Abs32Fx2"); return;
sewardj38a3f862005-01-13 15:06:51 +0000523
sewardj18069182005-01-13 19:16:04 +0000524 case Iop_CmpNEZ32x2: vex_printf("CmpNEZ32x2"); return;
525 case Iop_CmpNEZ16x4: vex_printf("CmpNEZ16x4"); return;
526 case Iop_CmpNEZ8x8: vex_printf("CmpNEZ8x8"); return;
527
sewardj1e6ad742004-12-02 16:16:11 +0000528 case Iop_Add32Fx4: vex_printf("Add32Fx4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000529 case Iop_Add32Fx2: vex_printf("Add32Fx2"); return;
sewardj1e6ad742004-12-02 16:16:11 +0000530 case Iop_Add32F0x4: vex_printf("Add32F0x4"); return;
sewardj636ad762004-12-07 11:16:04 +0000531 case Iop_Add64Fx2: vex_printf("Add64Fx2"); return;
532 case Iop_Add64F0x2: vex_printf("Add64F0x2"); return;
sewardj1e6ad742004-12-02 16:16:11 +0000533
sewardj176a59c2004-12-03 20:08:31 +0000534 case Iop_Div32Fx4: vex_printf("Div32Fx4"); return;
535 case Iop_Div32F0x4: vex_printf("Div32F0x4"); return;
sewardj636ad762004-12-07 11:16:04 +0000536 case Iop_Div64Fx2: vex_printf("Div64Fx2"); return;
537 case Iop_Div64F0x2: vex_printf("Div64F0x2"); return;
sewardj176a59c2004-12-03 20:08:31 +0000538
539 case Iop_Max32Fx4: vex_printf("Max32Fx4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000540 case Iop_Max32Fx2: vex_printf("Max32Fx2"); return;
541 case Iop_PwMax32Fx4: vex_printf("PwMax32Fx4"); return;
542 case Iop_PwMax32Fx2: vex_printf("PwMax32Fx2"); return;
sewardj176a59c2004-12-03 20:08:31 +0000543 case Iop_Max32F0x4: vex_printf("Max32F0x4"); return;
sewardj636ad762004-12-07 11:16:04 +0000544 case Iop_Max64Fx2: vex_printf("Max64Fx2"); return;
545 case Iop_Max64F0x2: vex_printf("Max64F0x2"); return;
sewardj176a59c2004-12-03 20:08:31 +0000546
547 case Iop_Min32Fx4: vex_printf("Min32Fx4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000548 case Iop_Min32Fx2: vex_printf("Min32Fx2"); return;
549 case Iop_PwMin32Fx4: vex_printf("PwMin32Fx4"); return;
550 case Iop_PwMin32Fx2: vex_printf("PwMin32Fx2"); return;
sewardj176a59c2004-12-03 20:08:31 +0000551 case Iop_Min32F0x4: vex_printf("Min32F0x4"); return;
sewardj636ad762004-12-07 11:16:04 +0000552 case Iop_Min64Fx2: vex_printf("Min64Fx2"); return;
553 case Iop_Min64F0x2: vex_printf("Min64F0x2"); return;
sewardj176a59c2004-12-03 20:08:31 +0000554
sewardj9636b442004-12-04 01:38:37 +0000555 case Iop_Mul32Fx4: vex_printf("Mul32Fx4"); return;
556 case Iop_Mul32F0x4: vex_printf("Mul32F0x4"); return;
sewardj636ad762004-12-07 11:16:04 +0000557 case Iop_Mul64Fx2: vex_printf("Mul64Fx2"); return;
558 case Iop_Mul64F0x2: vex_printf("Mul64F0x2"); return;
sewardj9636b442004-12-04 01:38:37 +0000559
sewardj2fdd4162010-08-22 12:59:02 +0000560 case Iop_Recip32x2: vex_printf("Recip32x2"); return;
561 case Iop_Recip32Fx2: vex_printf("Recip32Fx2"); return;
sewardj0bd7ce62004-12-05 02:47:40 +0000562 case Iop_Recip32Fx4: vex_printf("Recip32Fx4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000563 case Iop_Recip32x4: vex_printf("Recip32x4"); return;
sewardj0bd7ce62004-12-05 02:47:40 +0000564 case Iop_Recip32F0x4: vex_printf("Recip32F0x4"); return;
sewardj636ad762004-12-07 11:16:04 +0000565 case Iop_Recip64Fx2: vex_printf("Recip64Fx2"); return;
566 case Iop_Recip64F0x2: vex_printf("Recip64F0x2"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000567 case Iop_Recps32Fx2: vex_printf("VRecps32Fx2"); return;
568 case Iop_Recps32Fx4: vex_printf("VRecps32Fx4"); return;
569 case Iop_Abs32Fx4: vex_printf("Abs32Fx4"); return;
570 case Iop_Rsqrts32Fx4: vex_printf("VRsqrts32Fx4"); return;
571 case Iop_Rsqrts32Fx2: vex_printf("VRsqrts32Fx2"); return;
sewardj0bd7ce62004-12-05 02:47:40 +0000572
sewardjc1e7dfc2004-12-05 19:29:45 +0000573 case Iop_RSqrt32Fx4: vex_printf("RSqrt32Fx4"); return;
574 case Iop_RSqrt32F0x4: vex_printf("RSqrt32F0x4"); return;
sewardj636ad762004-12-07 11:16:04 +0000575 case Iop_RSqrt64Fx2: vex_printf("RSqrt64Fx2"); return;
576 case Iop_RSqrt64F0x2: vex_printf("RSqrt64F0x2"); return;
sewardjc1e7dfc2004-12-05 19:29:45 +0000577
sewardj636ad762004-12-07 11:16:04 +0000578 case Iop_Sqrt32Fx4: vex_printf("Sqrt32Fx4"); return;
579 case Iop_Sqrt32F0x4: vex_printf("Sqrt32F0x4"); return;
580 case Iop_Sqrt64Fx2: vex_printf("Sqrt64Fx2"); return;
581 case Iop_Sqrt64F0x2: vex_printf("Sqrt64F0x2"); return;
sewardjc1e7dfc2004-12-05 19:29:45 +0000582
583 case Iop_Sub32Fx4: vex_printf("Sub32Fx4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000584 case Iop_Sub32Fx2: vex_printf("Sub32Fx2"); return;
sewardjc1e7dfc2004-12-05 19:29:45 +0000585 case Iop_Sub32F0x4: vex_printf("Sub32F0x4"); return;
sewardj636ad762004-12-07 11:16:04 +0000586 case Iop_Sub64Fx2: vex_printf("Sub64Fx2"); return;
587 case Iop_Sub64F0x2: vex_printf("Sub64F0x2"); return;
sewardjc1e7dfc2004-12-05 19:29:45 +0000588
sewardj1e6ad742004-12-02 16:16:11 +0000589 case Iop_CmpEQ32Fx4: vex_printf("CmpEQ32Fx4"); return;
590 case Iop_CmpLT32Fx4: vex_printf("CmpLT32Fx4"); return;
591 case Iop_CmpLE32Fx4: vex_printf("CmpLE32Fx4"); return;
cerion206c3642005-11-14 00:35:59 +0000592 case Iop_CmpGT32Fx4: vex_printf("CmpGT32Fx4"); return;
593 case Iop_CmpGE32Fx4: vex_printf("CmpGE32Fx4"); return;
sewardj1e6ad742004-12-02 16:16:11 +0000594 case Iop_CmpUN32Fx4: vex_printf("CmpUN32Fx4"); return;
sewardj636ad762004-12-07 11:16:04 +0000595 case Iop_CmpEQ64Fx2: vex_printf("CmpEQ64Fx2"); return;
596 case Iop_CmpLT64Fx2: vex_printf("CmpLT64Fx2"); return;
597 case Iop_CmpLE64Fx2: vex_printf("CmpLE64Fx2"); return;
598 case Iop_CmpUN64Fx2: vex_printf("CmpUN64Fx2"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000599 case Iop_CmpGT32Fx2: vex_printf("CmpGT32Fx2"); return;
600 case Iop_CmpEQ32Fx2: vex_printf("CmpEQ32Fx2"); return;
601 case Iop_CmpGE32Fx2: vex_printf("CmpGE32Fx2"); return;
sewardj1e6ad742004-12-02 16:16:11 +0000602
603 case Iop_CmpEQ32F0x4: vex_printf("CmpEQ32F0x4"); return;
604 case Iop_CmpLT32F0x4: vex_printf("CmpLT32F0x4"); return;
605 case Iop_CmpLE32F0x4: vex_printf("CmpLE32F0x4"); return;
606 case Iop_CmpUN32F0x4: vex_printf("CmpUN32F0x4"); return;
sewardj636ad762004-12-07 11:16:04 +0000607 case Iop_CmpEQ64F0x2: vex_printf("CmpEQ64F0x2"); return;
608 case Iop_CmpLT64F0x2: vex_printf("CmpLT64F0x2"); return;
609 case Iop_CmpLE64F0x2: vex_printf("CmpLE64F0x2"); return;
610 case Iop_CmpUN64F0x2: vex_printf("CmpUN64F0x2"); return;
sewardjc9a43662004-11-30 18:51:59 +0000611
sewardj2fdd4162010-08-22 12:59:02 +0000612 case Iop_Neg32Fx4: vex_printf("Neg32Fx4"); return;
613 case Iop_Neg32Fx2: vex_printf("Neg32Fx2"); return;
614
sewardjf0c1c582005-02-07 23:47:38 +0000615 case Iop_V128to64: vex_printf("V128to64"); return;
616 case Iop_V128HIto64: vex_printf("V128HIto64"); return;
617 case Iop_64HLtoV128: vex_printf("64HLtoV128"); return;
sewardja0037df2004-12-10 18:56:29 +0000618
sewardjf0c1c582005-02-07 23:47:38 +0000619 case Iop_64UtoV128: vex_printf("64UtoV128"); return;
620 case Iop_SetV128lo64: vex_printf("SetV128lo64"); return;
sewardjc9a43662004-11-30 18:51:59 +0000621
sewardjf0c1c582005-02-07 23:47:38 +0000622 case Iop_32UtoV128: vex_printf("32UtoV128"); return;
623 case Iop_V128to32: vex_printf("V128to32"); return;
624 case Iop_SetV128lo32: vex_printf("SetV128lo32"); return;
sewardj129b3d92004-12-05 15:42:05 +0000625
cerionf887b3e2005-09-13 16:34:28 +0000626 case Iop_Dup8x16: vex_printf("Dup8x16"); return;
627 case Iop_Dup16x8: vex_printf("Dup16x8"); return;
628 case Iop_Dup32x4: vex_printf("Dup32x4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000629 case Iop_Dup8x8: vex_printf("Dup8x8"); return;
630 case Iop_Dup16x4: vex_printf("Dup16x4"); return;
631 case Iop_Dup32x2: vex_printf("Dup32x2"); return;
cerionf887b3e2005-09-13 16:34:28 +0000632
sewardjf0c1c582005-02-07 23:47:38 +0000633 case Iop_NotV128: vex_printf("NotV128"); return;
634 case Iop_AndV128: vex_printf("AndV128"); return;
635 case Iop_OrV128: vex_printf("OrV128"); return;
636 case Iop_XorV128: vex_printf("XorV128"); return;
sewardj18069182005-01-13 19:16:04 +0000637
sewardj2e383862004-12-12 16:46:47 +0000638 case Iop_CmpNEZ8x16: vex_printf("CmpNEZ8x16"); return;
639 case Iop_CmpNEZ16x8: vex_printf("CmpNEZ16x8"); return;
sewardj70f676d2004-12-10 14:59:57 +0000640 case Iop_CmpNEZ32x4: vex_printf("CmpNEZ32x4"); return;
sewardj109ffdb2004-12-10 21:45:38 +0000641 case Iop_CmpNEZ64x2: vex_printf("CmpNEZ64x2"); return;
sewardj164f9272004-12-09 00:39:32 +0000642
sewardj2fdd4162010-08-22 12:59:02 +0000643 case Iop_Abs8x16: vex_printf("Abs8x16"); return;
644 case Iop_Abs16x8: vex_printf("Abs16x8"); return;
645 case Iop_Abs32x4: vex_printf("Abs32x4"); return;
646
sewardj164f9272004-12-09 00:39:32 +0000647 case Iop_Add8x16: vex_printf("Add8x16"); return;
648 case Iop_Add16x8: vex_printf("Add16x8"); return;
649 case Iop_Add32x4: vex_printf("Add32x4"); return;
650 case Iop_Add64x2: vex_printf("Add64x2"); return;
651 case Iop_QAdd8Ux16: vex_printf("QAdd8Ux16"); return;
652 case Iop_QAdd16Ux8: vex_printf("QAdd16Ux8"); return;
cerionf887b3e2005-09-13 16:34:28 +0000653 case Iop_QAdd32Ux4: vex_printf("QAdd32Ux4"); return;
sewardj164f9272004-12-09 00:39:32 +0000654 case Iop_QAdd8Sx16: vex_printf("QAdd8Sx16"); return;
655 case Iop_QAdd16Sx8: vex_printf("QAdd16Sx8"); return;
cerionf887b3e2005-09-13 16:34:28 +0000656 case Iop_QAdd32Sx4: vex_printf("QAdd32Sx4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000657 case Iop_QAdd64Ux2: vex_printf("QAdd64Ux2"); return;
658 case Iop_QAdd64Sx2: vex_printf("QAdd64Sx2"); return;
659 case Iop_PwAdd8x16: vex_printf("PwAdd8x16"); return;
660 case Iop_PwAdd16x8: vex_printf("PwAdd16x8"); return;
661 case Iop_PwAdd32x4: vex_printf("PwAdd32x4"); return;
662 case Iop_PwAddL8Ux16: vex_printf("PwAddL8Ux16"); return;
663 case Iop_PwAddL16Ux8: vex_printf("PwAddL16Ux8"); return;
664 case Iop_PwAddL32Ux4: vex_printf("PwAddL32Ux4"); return;
665 case Iop_PwAddL8Sx16: vex_printf("PwAddL8Sx16"); return;
666 case Iop_PwAddL16Sx8: vex_printf("PwAddL16Sx8"); return;
667 case Iop_PwAddL32Sx4: vex_printf("PwAddL32Sx4"); return;
sewardj164f9272004-12-09 00:39:32 +0000668
669 case Iop_Sub8x16: vex_printf("Sub8x16"); return;
670 case Iop_Sub16x8: vex_printf("Sub16x8"); return;
671 case Iop_Sub32x4: vex_printf("Sub32x4"); return;
672 case Iop_Sub64x2: vex_printf("Sub64x2"); return;
673 case Iop_QSub8Ux16: vex_printf("QSub8Ux16"); return;
674 case Iop_QSub16Ux8: vex_printf("QSub16Ux8"); return;
cerionf887b3e2005-09-13 16:34:28 +0000675 case Iop_QSub32Ux4: vex_printf("QSub32Ux4"); return;
sewardj164f9272004-12-09 00:39:32 +0000676 case Iop_QSub8Sx16: vex_printf("QSub8Sx16"); return;
677 case Iop_QSub16Sx8: vex_printf("QSub16Sx8"); return;
cerionf887b3e2005-09-13 16:34:28 +0000678 case Iop_QSub32Sx4: vex_printf("QSub32Sx4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000679 case Iop_QSub64Ux2: vex_printf("QSub64Ux2"); return;
680 case Iop_QSub64Sx2: vex_printf("QSub64Sx2"); return;
sewardj164f9272004-12-09 00:39:32 +0000681
sewardj2fdd4162010-08-22 12:59:02 +0000682 case Iop_Mul8x16: vex_printf("Mul8x16"); return;
sewardj164f9272004-12-09 00:39:32 +0000683 case Iop_Mul16x8: vex_printf("Mul16x8"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000684 case Iop_Mul32x4: vex_printf("Mul32x4"); return;
685 case Iop_Mull8Ux8: vex_printf("Mull8Ux8"); return;
686 case Iop_Mull8Sx8: vex_printf("Mull8Sx8"); return;
687 case Iop_Mull16Ux4: vex_printf("Mull16Ux4"); return;
688 case Iop_Mull16Sx4: vex_printf("Mull16Sx4"); return;
689 case Iop_Mull32Ux2: vex_printf("Mull32Ux2"); return;
690 case Iop_Mull32Sx2: vex_printf("Mull32Sx2"); return;
691 case Iop_PolynomialMul8x16: vex_printf("PolynomialMul8x16"); return;
692 case Iop_PolynomialMull8x8: vex_printf("PolynomialMull8x8"); return;
sewardj164f9272004-12-09 00:39:32 +0000693 case Iop_MulHi16Ux8: vex_printf("MulHi16Ux8"); return;
cerionf887b3e2005-09-13 16:34:28 +0000694 case Iop_MulHi32Ux4: vex_printf("MulHi32Ux4"); return;
sewardj164f9272004-12-09 00:39:32 +0000695 case Iop_MulHi16Sx8: vex_printf("MulHi16Sx8"); return;
cerionf887b3e2005-09-13 16:34:28 +0000696 case Iop_MulHi32Sx4: vex_printf("MulHi32Sx4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000697 case Iop_QDMulHi16Sx8: vex_printf("QDMulHi16Sx8"); return;
698 case Iop_QDMulHi32Sx4: vex_printf("QDMulHi32Sx4"); return;
699 case Iop_QRDMulHi16Sx8: vex_printf("QRDMulHi16Sx8"); return;
700 case Iop_QRDMulHi32Sx4: vex_printf("QRDMulHi32Sx4"); return;
sewardj164f9272004-12-09 00:39:32 +0000701
cerion1ac656a2005-11-04 19:44:48 +0000702 case Iop_MullEven8Ux16: vex_printf("MullEven8Ux16"); return;
703 case Iop_MullEven16Ux8: vex_printf("MullEven16Ux8"); return;
704 case Iop_MullEven8Sx16: vex_printf("MullEven8Sx16"); return;
705 case Iop_MullEven16Sx8: vex_printf("MullEven16Sx8"); return;
706
sewardj164f9272004-12-09 00:39:32 +0000707 case Iop_Avg8Ux16: vex_printf("Avg8Ux16"); return;
708 case Iop_Avg16Ux8: vex_printf("Avg16Ux8"); return;
cerionf887b3e2005-09-13 16:34:28 +0000709 case Iop_Avg32Ux4: vex_printf("Avg32Ux4"); return;
710 case Iop_Avg8Sx16: vex_printf("Avg8Sx16"); return;
711 case Iop_Avg16Sx8: vex_printf("Avg16Sx8"); return;
712 case Iop_Avg32Sx4: vex_printf("Avg32Sx4"); return;
sewardj164f9272004-12-09 00:39:32 +0000713
cerionf887b3e2005-09-13 16:34:28 +0000714 case Iop_Max8Sx16: vex_printf("Max8Sx16"); return;
sewardj164f9272004-12-09 00:39:32 +0000715 case Iop_Max16Sx8: vex_printf("Max16Sx8"); return;
cerionf887b3e2005-09-13 16:34:28 +0000716 case Iop_Max32Sx4: vex_printf("Max32Sx4"); return;
sewardj164f9272004-12-09 00:39:32 +0000717 case Iop_Max8Ux16: vex_printf("Max8Ux16"); return;
cerionf887b3e2005-09-13 16:34:28 +0000718 case Iop_Max16Ux8: vex_printf("Max16Ux8"); return;
719 case Iop_Max32Ux4: vex_printf("Max32Ux4"); return;
720
721 case Iop_Min8Sx16: vex_printf("Min8Sx16"); return;
sewardj164f9272004-12-09 00:39:32 +0000722 case Iop_Min16Sx8: vex_printf("Min16Sx8"); return;
cerionf887b3e2005-09-13 16:34:28 +0000723 case Iop_Min32Sx4: vex_printf("Min32Sx4"); return;
sewardj164f9272004-12-09 00:39:32 +0000724 case Iop_Min8Ux16: vex_printf("Min8Ux16"); return;
cerionf887b3e2005-09-13 16:34:28 +0000725 case Iop_Min16Ux8: vex_printf("Min16Ux8"); return;
726 case Iop_Min32Ux4: vex_printf("Min32Ux4"); return;
sewardj164f9272004-12-09 00:39:32 +0000727
728 case Iop_CmpEQ8x16: vex_printf("CmpEQ8x16"); return;
729 case Iop_CmpEQ16x8: vex_printf("CmpEQ16x8"); return;
730 case Iop_CmpEQ32x4: vex_printf("CmpEQ32x4"); return;
731 case Iop_CmpGT8Sx16: vex_printf("CmpGT8Sx16"); return;
732 case Iop_CmpGT16Sx8: vex_printf("CmpGT16Sx8"); return;
733 case Iop_CmpGT32Sx4: vex_printf("CmpGT32Sx4"); return;
sewardj69d98e32010-06-18 08:17:41 +0000734 case Iop_CmpGT64Sx2: vex_printf("CmpGT64Sx2"); return;
cerionf887b3e2005-09-13 16:34:28 +0000735 case Iop_CmpGT8Ux16: vex_printf("CmpGT8Ux16"); return;
736 case Iop_CmpGT16Ux8: vex_printf("CmpGT16Ux8"); return;
737 case Iop_CmpGT32Ux4: vex_printf("CmpGT32Ux4"); return;
738
sewardj2fdd4162010-08-22 12:59:02 +0000739 case Iop_Cnt8x16: vex_printf("Cnt8x16"); return;
740 case Iop_Clz8Sx16: vex_printf("Clz8Sx16"); return;
741 case Iop_Clz16Sx8: vex_printf("Clz16Sx8"); return;
742 case Iop_Clz32Sx4: vex_printf("Clz32Sx4"); return;
743 case Iop_Cls8Sx16: vex_printf("Cls8Sx16"); return;
744 case Iop_Cls16Sx8: vex_printf("Cls16Sx8"); return;
745 case Iop_Cls32Sx4: vex_printf("Cls32Sx4"); return;
746
cerionf887b3e2005-09-13 16:34:28 +0000747 case Iop_ShlV128: vex_printf("ShlV128"); return;
748 case Iop_ShrV128: vex_printf("ShrV128"); return;
sewardj164f9272004-12-09 00:39:32 +0000749
cerion2a4b8452005-09-15 16:28:36 +0000750 case Iop_ShlN8x16: vex_printf("ShlN8x16"); return;
sewardj164f9272004-12-09 00:39:32 +0000751 case Iop_ShlN16x8: vex_printf("ShlN16x8"); return;
752 case Iop_ShlN32x4: vex_printf("ShlN32x4"); return;
753 case Iop_ShlN64x2: vex_printf("ShlN64x2"); return;
cerion2a4b8452005-09-15 16:28:36 +0000754 case Iop_ShrN8x16: vex_printf("ShrN8x16"); return;
sewardj164f9272004-12-09 00:39:32 +0000755 case Iop_ShrN16x8: vex_printf("ShrN16x8"); return;
756 case Iop_ShrN32x4: vex_printf("ShrN32x4"); return;
757 case Iop_ShrN64x2: vex_printf("ShrN64x2"); return;
cerion2a4b8452005-09-15 16:28:36 +0000758 case Iop_SarN8x16: vex_printf("SarN8x16"); return;
sewardj164f9272004-12-09 00:39:32 +0000759 case Iop_SarN16x8: vex_printf("SarN16x8"); return;
760 case Iop_SarN32x4: vex_printf("SarN32x4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000761 case Iop_SarN64x2: vex_printf("SarN64x2"); return;
sewardj164f9272004-12-09 00:39:32 +0000762
cerionf887b3e2005-09-13 16:34:28 +0000763 case Iop_Shl8x16: vex_printf("Shl8x16"); return;
764 case Iop_Shl16x8: vex_printf("Shl16x8"); return;
765 case Iop_Shl32x4: vex_printf("Shl32x4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000766 case Iop_Shl64x2: vex_printf("Shl64x2"); return;
767 case Iop_QSal8x16: vex_printf("QSal8x16"); return;
768 case Iop_QSal16x8: vex_printf("QSal16x8"); return;
769 case Iop_QSal32x4: vex_printf("QSal32x4"); return;
770 case Iop_QSal64x2: vex_printf("QSal64x2"); return;
771 case Iop_QShl8x16: vex_printf("QShl8x16"); return;
772 case Iop_QShl16x8: vex_printf("QShl16x8"); return;
773 case Iop_QShl32x4: vex_printf("QShl32x4"); return;
774 case Iop_QShl64x2: vex_printf("QShl64x2"); return;
775 case Iop_QSalN8x16: vex_printf("QSalN8x16"); return;
776 case Iop_QSalN16x8: vex_printf("QSalN16x8"); return;
777 case Iop_QSalN32x4: vex_printf("QSalN32x4"); return;
778 case Iop_QSalN64x2: vex_printf("QSalN64x2"); return;
779 case Iop_QShlN8x16: vex_printf("QShlN8x16"); return;
780 case Iop_QShlN16x8: vex_printf("QShlN16x8"); return;
781 case Iop_QShlN32x4: vex_printf("QShlN32x4"); return;
782 case Iop_QShlN64x2: vex_printf("QShlN64x2"); return;
783 case Iop_QShlN8Sx16: vex_printf("QShlN8Sx16"); return;
784 case Iop_QShlN16Sx8: vex_printf("QShlN16Sx8"); return;
785 case Iop_QShlN32Sx4: vex_printf("QShlN32Sx4"); return;
786 case Iop_QShlN64Sx2: vex_printf("QShlN64Sx2"); return;
cerionf887b3e2005-09-13 16:34:28 +0000787 case Iop_Shr8x16: vex_printf("Shr8x16"); return;
788 case Iop_Shr16x8: vex_printf("Shr16x8"); return;
789 case Iop_Shr32x4: vex_printf("Shr32x4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000790 case Iop_Shr64x2: vex_printf("Shr64x2"); return;
cerionf887b3e2005-09-13 16:34:28 +0000791 case Iop_Sar8x16: vex_printf("Sar8x16"); return;
792 case Iop_Sar16x8: vex_printf("Sar16x8"); return;
793 case Iop_Sar32x4: vex_printf("Sar32x4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000794 case Iop_Sar64x2: vex_printf("Sar64x2"); return;
795 case Iop_Sal8x16: vex_printf("Sal8x16"); return;
796 case Iop_Sal16x8: vex_printf("Sal16x8"); return;
797 case Iop_Sal32x4: vex_printf("Sal32x4"); return;
798 case Iop_Sal64x2: vex_printf("Sal64x2"); return;
sewardj1bee5612005-11-10 18:10:58 +0000799 case Iop_Rol8x16: vex_printf("Rol8x16"); return;
800 case Iop_Rol16x8: vex_printf("Rol16x8"); return;
801 case Iop_Rol32x4: vex_printf("Rol32x4"); return;
cerionf887b3e2005-09-13 16:34:28 +0000802
sewardj1bee5612005-11-10 18:10:58 +0000803 case Iop_Narrow16x8: vex_printf("Narrow16x8"); return;
804 case Iop_Narrow32x4: vex_printf("Narrow32x4"); return;
sewardj164f9272004-12-09 00:39:32 +0000805 case Iop_QNarrow16Ux8: vex_printf("QNarrow16Ux8"); return;
cerion9e7677b2005-09-13 17:25:41 +0000806 case Iop_QNarrow32Ux4: vex_printf("QNarrow32Ux4"); return;
sewardj164f9272004-12-09 00:39:32 +0000807 case Iop_QNarrow16Sx8: vex_printf("QNarrow16Sx8"); return;
808 case Iop_QNarrow32Sx4: vex_printf("QNarrow32Sx4"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000809 case Iop_Shorten16x8: vex_printf("Shorten16x8"); return;
810 case Iop_Shorten32x4: vex_printf("Shorten32x4"); return;
811 case Iop_Shorten64x2: vex_printf("Shorten64x2"); return;
812 case Iop_QShortenU16Ux8: vex_printf("QShortenU16Ux8"); return;
813 case Iop_QShortenU32Ux4: vex_printf("QShortenU32Ux4"); return;
814 case Iop_QShortenU64Ux2: vex_printf("QShortenU64Ux2"); return;
815 case Iop_QShortenS16Sx8: vex_printf("QShortenS16Sx8"); return;
816 case Iop_QShortenS32Sx4: vex_printf("QShortenS32Sx4"); return;
817 case Iop_QShortenS64Sx2: vex_printf("QShortenS64Sx2"); return;
818 case Iop_QShortenU16Sx8: vex_printf("QShortenU16Sx8"); return;
819 case Iop_QShortenU32Sx4: vex_printf("QShortenU32Sx4"); return;
820 case Iop_QShortenU64Sx2: vex_printf("QShortenU64Sx2"); return;
821 case Iop_Longen8Ux8: vex_printf("Longen8Ux8"); return;
822 case Iop_Longen16Ux4: vex_printf("Longen16Ux4"); return;
823 case Iop_Longen32Ux2: vex_printf("Longen32Ux2"); return;
824 case Iop_Longen8Sx8: vex_printf("Longen8Sx8"); return;
825 case Iop_Longen16Sx4: vex_printf("Longen16Sx4"); return;
826 case Iop_Longen32Sx2: vex_printf("Longen32Sx2"); return;
sewardj164f9272004-12-09 00:39:32 +0000827
828 case Iop_InterleaveHI8x16: vex_printf("InterleaveHI8x16"); return;
829 case Iop_InterleaveHI16x8: vex_printf("InterleaveHI16x8"); return;
830 case Iop_InterleaveHI32x4: vex_printf("InterleaveHI32x4"); return;
831 case Iop_InterleaveHI64x2: vex_printf("InterleaveHI64x2"); return;
832 case Iop_InterleaveLO8x16: vex_printf("InterleaveLO8x16"); return;
833 case Iop_InterleaveLO16x8: vex_printf("InterleaveLO16x8"); return;
834 case Iop_InterleaveLO32x4: vex_printf("InterleaveLO32x4"); return;
835 case Iop_InterleaveLO64x2: vex_printf("InterleaveLO64x2"); return;
836
sewardj2fdd4162010-08-22 12:59:02 +0000837 case Iop_CatOddLanes8x16: vex_printf("CatOddLanes8x16"); return;
838 case Iop_CatOddLanes16x8: vex_printf("CatOddLanes16x8"); return;
839 case Iop_CatOddLanes32x4: vex_printf("CatOddLanes32x4"); return;
840 case Iop_CatEvenLanes8x16: vex_printf("CatEvenLanes8x16"); return;
841 case Iop_CatEvenLanes16x8: vex_printf("CatEvenLanes16x8"); return;
842 case Iop_CatEvenLanes32x4: vex_printf("CatEvenLanes32x4"); return;
843
844 case Iop_InterleaveOddLanes8x16: vex_printf("InterleaveOddLanes8x16"); return;
845 case Iop_InterleaveOddLanes16x8: vex_printf("InterleaveOddLanes16x8"); return;
846 case Iop_InterleaveOddLanes32x4: vex_printf("InterleaveOddLanes32x4"); return;
847 case Iop_InterleaveEvenLanes8x16: vex_printf("InterleaveEvenLanes8x16"); return;
848 case Iop_InterleaveEvenLanes16x8: vex_printf("InterleaveEvenLanes16x8"); return;
849 case Iop_InterleaveEvenLanes32x4: vex_printf("InterleaveEvenLanes32x4"); return;
850
851 case Iop_GetElem8x16: vex_printf("GetElem8x16"); return;
852 case Iop_GetElem16x8: vex_printf("GetElem16x8"); return;
853 case Iop_GetElem32x4: vex_printf("GetElem32x4"); return;
854 case Iop_GetElem64x2: vex_printf("GetElem64x2"); return;
855
856 case Iop_GetElem8x8: vex_printf("GetElem8x8"); return;
857 case Iop_GetElem16x4: vex_printf("GetElem16x4"); return;
858 case Iop_GetElem32x2: vex_printf("GetElem32x2"); return;
859 case Iop_SetElem8x8: vex_printf("SetElem8x8"); return;
860 case Iop_SetElem16x4: vex_printf("SetElem16x4"); return;
861 case Iop_SetElem32x2: vex_printf("SetElem32x2"); return;
862
863 case Iop_Extract64: vex_printf("Extract64"); return;
864 case Iop_ExtractV128: vex_printf("ExtractV128"); return;
865
sewardjdc1f9132005-10-22 12:49:49 +0000866 case Iop_Perm8x16: vex_printf("Perm8x16"); return;
sewardj2fdd4162010-08-22 12:59:02 +0000867 case Iop_Reverse16_8x16: vex_printf("Reverse16_8x16"); return;
868 case Iop_Reverse32_8x16: vex_printf("Reverse32_8x16"); return;
869 case Iop_Reverse32_16x8: vex_printf("Reverse32_16x8"); return;
870 case Iop_Reverse64_8x16: vex_printf("Reverse64_8x16"); return;
871 case Iop_Reverse64_16x8: vex_printf("Reverse64_16x8"); return;
872 case Iop_Reverse64_32x4: vex_printf("Reverse64_32x4"); return;
873
874 case Iop_F32ToFixed32Ux4_RZ: vex_printf("F32ToFixed32Ux4_RZ"); return;
875 case Iop_F32ToFixed32Sx4_RZ: vex_printf("F32ToFixed32Sx4_RZ"); return;
876 case Iop_Fixed32UToF32x4_RN: vex_printf("Fixed32UToF32x4_RN"); return;
877 case Iop_Fixed32SToF32x4_RN: vex_printf("Fixed32SToF32x4_RN"); return;
878 case Iop_F32ToFixed32Ux2_RZ: vex_printf("F32ToFixed32Ux2_RZ"); return;
879 case Iop_F32ToFixed32Sx2_RZ: vex_printf("F32ToFixed32Sx2_RZ"); return;
880 case Iop_Fixed32UToF32x2_RN: vex_printf("Fixed32UToF32x2_RN"); return;
881 case Iop_Fixed32SToF32x2_RN: vex_printf("Fixed32SToF32x2_RN"); return;
cerionf887b3e2005-09-13 16:34:28 +0000882
sewardjc9a43662004-11-30 18:51:59 +0000883 default: vpanic("ppIROp(1)");
sewardj41f43bc2004-07-08 14:23:22 +0000884 }
sewardj1fb8c922009-07-12 12:56:53 +0000885
886 vassert(str);
sewardj41f43bc2004-07-08 14:23:22 +0000887 switch (op - base) {
sewardjecbaee72008-11-01 23:54:45 +0000888 case 0: vex_printf("%s",str); vex_printf("8"); break;
889 case 1: vex_printf("%s",str); vex_printf("16"); break;
890 case 2: vex_printf("%s",str); vex_printf("32"); break;
891 case 3: vex_printf("%s",str); vex_printf("64"); break;
sewardj41f43bc2004-07-08 14:23:22 +0000892 default: vpanic("ppIROp(2)");
893 }
sewardje3d0d2e2004-06-27 10:42:44 +0000894}
895
sewardj35421a32004-07-05 13:12:34 +0000896void ppIRExpr ( IRExpr* e )
sewardje3d0d2e2004-06-27 10:42:44 +0000897{
sewardje87b4842004-07-10 12:23:30 +0000898 Int i;
sewardje3d0d2e2004-06-27 10:42:44 +0000899 switch (e->tag) {
sewardj443cd9d2004-07-18 23:06:45 +0000900 case Iex_Binder:
901 vex_printf("BIND-%d", e->Iex.Binder.binder);
902 break;
sewardje3d0d2e2004-06-27 10:42:44 +0000903 case Iex_Get:
sewardjc9a43662004-11-30 18:51:59 +0000904 vex_printf( "GET:" );
sewardjfbcaf332004-07-08 01:46:01 +0000905 ppIRType(e->Iex.Get.ty);
sewardjc9a43662004-11-30 18:51:59 +0000906 vex_printf("(%d)", e->Iex.Get.offset);
sewardjec6ad592004-06-20 12:26:53 +0000907 break;
sewardjbb53f8c2004-08-14 11:50:01 +0000908 case Iex_GetI:
sewardj2d3f77c2004-09-22 23:49:09 +0000909 vex_printf( "GETI" );
sewardjdd40fdf2006-12-24 02:20:24 +0000910 ppIRRegArray(e->Iex.GetI.descr);
sewardj2d3f77c2004-09-22 23:49:09 +0000911 vex_printf("[");
sewardjeeac8412004-11-02 00:26:55 +0000912 ppIRExpr(e->Iex.GetI.ix);
sewardj2d3f77c2004-09-22 23:49:09 +0000913 vex_printf(",%d]", e->Iex.GetI.bias);
sewardjbb53f8c2004-08-14 11:50:01 +0000914 break;
sewardjdd40fdf2006-12-24 02:20:24 +0000915 case Iex_RdTmp:
916 ppIRTemp(e->Iex.RdTmp.tmp);
sewardjec6ad592004-06-20 12:26:53 +0000917 break;
sewardj40c80262006-02-08 19:30:46 +0000918 case Iex_Qop:
919 ppIROp(e->Iex.Qop.op);
920 vex_printf( "(" );
921 ppIRExpr(e->Iex.Qop.arg1);
922 vex_printf( "," );
923 ppIRExpr(e->Iex.Qop.arg2);
924 vex_printf( "," );
925 ppIRExpr(e->Iex.Qop.arg3);
926 vex_printf( "," );
927 ppIRExpr(e->Iex.Qop.arg4);
928 vex_printf( ")" );
929 break;
sewardjb183b852006-02-03 16:08:03 +0000930 case Iex_Triop:
931 ppIROp(e->Iex.Triop.op);
932 vex_printf( "(" );
933 ppIRExpr(e->Iex.Triop.arg1);
934 vex_printf( "," );
935 ppIRExpr(e->Iex.Triop.arg2);
936 vex_printf( "," );
937 ppIRExpr(e->Iex.Triop.arg3);
938 vex_printf( ")" );
939 break;
sewardje3d0d2e2004-06-27 10:42:44 +0000940 case Iex_Binop:
sewardj35421a32004-07-05 13:12:34 +0000941 ppIROp(e->Iex.Binop.op);
942 vex_printf( "(" );
943 ppIRExpr(e->Iex.Binop.arg1);
944 vex_printf( "," );
945 ppIRExpr(e->Iex.Binop.arg2);
946 vex_printf( ")" );
sewardjec6ad592004-06-20 12:26:53 +0000947 break;
sewardje3d0d2e2004-06-27 10:42:44 +0000948 case Iex_Unop:
sewardj35421a32004-07-05 13:12:34 +0000949 ppIROp(e->Iex.Unop.op);
950 vex_printf( "(" );
951 ppIRExpr(e->Iex.Unop.arg);
952 vex_printf( ")" );
sewardjec6ad592004-06-20 12:26:53 +0000953 break;
sewardjaf1ceca2005-06-30 23:31:27 +0000954 case Iex_Load:
sewardje768e922009-11-26 17:17:37 +0000955 vex_printf( "LD%s:", e->Iex.Load.end==Iend_LE ? "le" : "be" );
sewardjaf1ceca2005-06-30 23:31:27 +0000956 ppIRType(e->Iex.Load.ty);
sewardje05c42c2004-07-08 20:25:10 +0000957 vex_printf( "(" );
sewardjaf1ceca2005-06-30 23:31:27 +0000958 ppIRExpr(e->Iex.Load.addr);
sewardj35421a32004-07-05 13:12:34 +0000959 vex_printf( ")" );
sewardjec6ad592004-06-20 12:26:53 +0000960 break;
sewardje3d0d2e2004-06-27 10:42:44 +0000961 case Iex_Const:
sewardj35421a32004-07-05 13:12:34 +0000962 ppIRConst(e->Iex.Const.con);
sewardjec6ad592004-06-20 12:26:53 +0000963 break;
sewardje87b4842004-07-10 12:23:30 +0000964 case Iex_CCall:
sewardj8ea867b2004-10-30 19:03:02 +0000965 ppIRCallee(e->Iex.CCall.cee);
966 vex_printf("(");
sewardje87b4842004-07-10 12:23:30 +0000967 for (i = 0; e->Iex.CCall.args[i] != NULL; i++) {
968 ppIRExpr(e->Iex.CCall.args[i]);
969 if (e->Iex.CCall.args[i+1] != NULL)
970 vex_printf(",");
971 }
972 vex_printf("):");
973 ppIRType(e->Iex.CCall.retty);
974 break;
sewardj4042c7e2004-07-18 01:28:30 +0000975 case Iex_Mux0X:
976 vex_printf("Mux0X(");
977 ppIRExpr(e->Iex.Mux0X.cond);
sewardjeeb9ef82004-07-15 12:39:03 +0000978 vex_printf(",");
sewardj4042c7e2004-07-18 01:28:30 +0000979 ppIRExpr(e->Iex.Mux0X.expr0);
sewardjeeb9ef82004-07-15 12:39:03 +0000980 vex_printf(",");
sewardj4042c7e2004-07-18 01:28:30 +0000981 ppIRExpr(e->Iex.Mux0X.exprX);
sewardjeeb9ef82004-07-15 12:39:03 +0000982 vex_printf(")");
983 break;
sewardjec6ad592004-06-20 12:26:53 +0000984 default:
sewardj909c06d2005-02-19 22:47:41 +0000985 vpanic("ppIRExpr");
sewardjec6ad592004-06-20 12:26:53 +0000986 }
987}
988
sewardj17442fe2004-09-20 14:54:28 +0000989void ppIREffect ( IREffect fx )
990{
991 switch (fx) {
992 case Ifx_None: vex_printf("noFX"); return;
993 case Ifx_Read: vex_printf("RdFX"); return;
994 case Ifx_Write: vex_printf("WrFX"); return;
995 case Ifx_Modify: vex_printf("MoFX"); return;
996 default: vpanic("ppIREffect");
997 }
998}
999
1000void ppIRDirty ( IRDirty* d )
1001{
1002 Int i;
sewardj92d168d2004-11-15 14:22:12 +00001003 if (d->tmp != IRTemp_INVALID) {
sewardj4b861de2004-11-03 15:24:42 +00001004 ppIRTemp(d->tmp);
1005 vex_printf(" = ");
1006 }
sewardjb8385d82004-11-02 01:34:15 +00001007 vex_printf("DIRTY ");
1008 ppIRExpr(d->guard);
sewardjc5fc7aa2004-10-27 23:00:55 +00001009 if (d->needsBBP)
1010 vex_printf(" NeedsBBP");
sewardj17442fe2004-09-20 14:54:28 +00001011 if (d->mFx != Ifx_None) {
sewardj49651f42004-10-28 22:11:04 +00001012 vex_printf(" ");
sewardj17442fe2004-09-20 14:54:28 +00001013 ppIREffect(d->mFx);
1014 vex_printf("-mem(");
1015 ppIRExpr(d->mAddr);
sewardj49651f42004-10-28 22:11:04 +00001016 vex_printf(",%d)", d->mSize);
sewardj17442fe2004-09-20 14:54:28 +00001017 }
1018 for (i = 0; i < d->nFxState; i++) {
sewardj49651f42004-10-28 22:11:04 +00001019 vex_printf(" ");
sewardj17442fe2004-09-20 14:54:28 +00001020 ppIREffect(d->fxState[i].fx);
sewardj49651f42004-10-28 22:11:04 +00001021 vex_printf("-gst(%d,%d)", d->fxState[i].offset, d->fxState[i].size);
sewardj17442fe2004-09-20 14:54:28 +00001022 }
sewardjc5fc7aa2004-10-27 23:00:55 +00001023 vex_printf(" ::: ");
sewardj8ea867b2004-10-30 19:03:02 +00001024 ppIRCallee(d->cee);
1025 vex_printf("(");
sewardj17442fe2004-09-20 14:54:28 +00001026 for (i = 0; d->args[i] != NULL; i++) {
1027 ppIRExpr(d->args[i]);
1028 if (d->args[i+1] != NULL) {
1029 vex_printf(",");
1030 }
1031 }
1032 vex_printf(")");
1033}
1034
sewardje9d8a262009-07-01 08:06:34 +00001035void ppIRCAS ( IRCAS* cas )
1036{
1037 /* Print even structurally invalid constructions, as an aid to
1038 debugging. */
1039 if (cas->oldHi != IRTemp_INVALID) {
1040 ppIRTemp(cas->oldHi);
1041 vex_printf(",");
1042 }
1043 ppIRTemp(cas->oldLo);
1044 vex_printf(" = CAS%s(", cas->end==Iend_LE ? "le" : "be" );
1045 ppIRExpr(cas->addr);
1046 vex_printf("::");
1047 if (cas->expdHi) {
1048 ppIRExpr(cas->expdHi);
1049 vex_printf(",");
1050 }
1051 ppIRExpr(cas->expdLo);
1052 vex_printf("->");
1053 if (cas->dataHi) {
1054 ppIRExpr(cas->dataHi);
1055 vex_printf(",");
1056 }
1057 ppIRExpr(cas->dataLo);
1058 vex_printf(")");
1059}
1060
sewardj893aada2004-11-29 19:57:54 +00001061void ppIRJumpKind ( IRJumpKind kind )
1062{
1063 switch (kind) {
sewardj4fa325a2005-11-03 13:27:24 +00001064 case Ijk_Boring: vex_printf("Boring"); break;
1065 case Ijk_Call: vex_printf("Call"); break;
1066 case Ijk_Ret: vex_printf("Return"); break;
1067 case Ijk_ClientReq: vex_printf("ClientReq"); break;
1068 case Ijk_Yield: vex_printf("Yield"); break;
1069 case Ijk_EmWarn: vex_printf("EmWarn"); break;
sewardj9dd9cf12006-01-20 14:13:55 +00001070 case Ijk_EmFail: vex_printf("EmFail"); break;
sewardj4fa325a2005-11-03 13:27:24 +00001071 case Ijk_NoDecode: vex_printf("NoDecode"); break;
1072 case Ijk_MapFail: vex_printf("MapFail"); break;
1073 case Ijk_TInval: vex_printf("Invalidate"); break;
sewardjce02aa72006-01-12 12:27:58 +00001074 case Ijk_NoRedir: vex_printf("NoRedir"); break;
sewardj0f500042007-08-29 09:09:17 +00001075 case Ijk_SigTRAP: vex_printf("SigTRAP"); break;
1076 case Ijk_SigSEGV: vex_printf("SigSEGV"); break;
sewardje9d8a262009-07-01 08:06:34 +00001077 case Ijk_SigBUS: vex_printf("SigBUS"); break;
sewardj4fa325a2005-11-03 13:27:24 +00001078 case Ijk_Sys_syscall: vex_printf("Sys_syscall"); break;
1079 case Ijk_Sys_int32: vex_printf("Sys_int32"); break;
1080 case Ijk_Sys_int128: vex_printf("Sys_int128"); break;
sewardjd660d412008-12-03 21:29:59 +00001081 case Ijk_Sys_int129: vex_printf("Sys_int129"); break;
1082 case Ijk_Sys_int130: vex_printf("Sys_int130"); break;
sewardj4fa325a2005-11-03 13:27:24 +00001083 case Ijk_Sys_sysenter: vex_printf("Sys_sysenter"); break;
1084 default: vpanic("ppIRJumpKind");
sewardj893aada2004-11-29 19:57:54 +00001085 }
1086}
1087
sewardjc4356f02007-11-09 21:15:04 +00001088void ppIRMBusEvent ( IRMBusEvent event )
1089{
1090 switch (event) {
sewardje9d8a262009-07-01 08:06:34 +00001091 case Imbe_Fence: vex_printf("Fence"); break;
1092 default: vpanic("ppIRMBusEvent");
sewardjc4356f02007-11-09 21:15:04 +00001093 }
1094}
1095
sewardj35421a32004-07-05 13:12:34 +00001096void ppIRStmt ( IRStmt* s )
sewardjec6ad592004-06-20 12:26:53 +00001097{
sewardjd2445f62005-03-21 00:15:53 +00001098 if (!s) {
1099 vex_printf("!!! IRStmt* which is NULL !!!");
1100 return;
1101 }
sewardj17442fe2004-09-20 14:54:28 +00001102 switch (s->tag) {
sewardjd2445f62005-03-21 00:15:53 +00001103 case Ist_NoOp:
1104 vex_printf("IR-NoOp");
1105 break;
sewardjf1689312005-03-16 18:19:10 +00001106 case Ist_IMark:
sewardj0c12a272005-03-17 09:57:03 +00001107 vex_printf( "------ IMark(0x%llx, %d) ------",
1108 s->Ist.IMark.addr, s->Ist.IMark.len);
sewardjf1689312005-03-16 18:19:10 +00001109 break;
sewardj5a9ffab2005-05-12 17:55:01 +00001110 case Ist_AbiHint:
1111 vex_printf("====== AbiHint(");
1112 ppIRExpr(s->Ist.AbiHint.base);
sewardj478646f2008-05-01 20:13:04 +00001113 vex_printf(", %d, ", s->Ist.AbiHint.len);
1114 ppIRExpr(s->Ist.AbiHint.nia);
1115 vex_printf(") ======");
sewardj5a9ffab2005-05-12 17:55:01 +00001116 break;
sewardj17442fe2004-09-20 14:54:28 +00001117 case Ist_Put:
1118 vex_printf( "PUT(%d) = ", s->Ist.Put.offset);
sewardj6d076362004-09-23 11:06:17 +00001119 ppIRExpr(s->Ist.Put.data);
sewardj17442fe2004-09-20 14:54:28 +00001120 break;
1121 case Ist_PutI:
sewardj2d3f77c2004-09-22 23:49:09 +00001122 vex_printf( "PUTI" );
sewardjdd40fdf2006-12-24 02:20:24 +00001123 ppIRRegArray(s->Ist.PutI.descr);
sewardj2d3f77c2004-09-22 23:49:09 +00001124 vex_printf("[");
sewardjeeac8412004-11-02 00:26:55 +00001125 ppIRExpr(s->Ist.PutI.ix);
sewardj2d3f77c2004-09-22 23:49:09 +00001126 vex_printf(",%d] = ", s->Ist.PutI.bias);
1127 ppIRExpr(s->Ist.PutI.data);
sewardj17442fe2004-09-20 14:54:28 +00001128 break;
sewardjdd40fdf2006-12-24 02:20:24 +00001129 case Ist_WrTmp:
1130 ppIRTemp(s->Ist.WrTmp.tmp);
sewardj17442fe2004-09-20 14:54:28 +00001131 vex_printf( " = " );
sewardjdd40fdf2006-12-24 02:20:24 +00001132 ppIRExpr(s->Ist.WrTmp.data);
sewardj17442fe2004-09-20 14:54:28 +00001133 break;
sewardjaf1ceca2005-06-30 23:31:27 +00001134 case Ist_Store:
1135 vex_printf( "ST%s(", s->Ist.Store.end==Iend_LE ? "le" : "be" );
1136 ppIRExpr(s->Ist.Store.addr);
sewardj17442fe2004-09-20 14:54:28 +00001137 vex_printf( ") = ");
sewardjaf1ceca2005-06-30 23:31:27 +00001138 ppIRExpr(s->Ist.Store.data);
sewardje9d8a262009-07-01 08:06:34 +00001139 break;
1140 case Ist_CAS:
1141 ppIRCAS(s->Ist.CAS.details);
sewardj17442fe2004-09-20 14:54:28 +00001142 break;
sewardje768e922009-11-26 17:17:37 +00001143 case Ist_LLSC:
1144 if (s->Ist.LLSC.storedata == NULL) {
1145 ppIRTemp(s->Ist.LLSC.result);
1146 vex_printf(" = LD%s-Linked(",
1147 s->Ist.LLSC.end==Iend_LE ? "le" : "be");
1148 ppIRExpr(s->Ist.LLSC.addr);
1149 vex_printf(")");
1150 } else {
1151 ppIRTemp(s->Ist.LLSC.result);
1152 vex_printf(" = ( ST%s-Cond(",
1153 s->Ist.LLSC.end==Iend_LE ? "le" : "be");
1154 ppIRExpr(s->Ist.LLSC.addr);
1155 vex_printf(") = ");
1156 ppIRExpr(s->Ist.LLSC.storedata);
1157 vex_printf(" )");
1158 }
1159 break;
sewardj17442fe2004-09-20 14:54:28 +00001160 case Ist_Dirty:
1161 ppIRDirty(s->Ist.Dirty.details);
1162 break;
sewardjc4356f02007-11-09 21:15:04 +00001163 case Ist_MBE:
1164 vex_printf("IR-");
1165 ppIRMBusEvent(s->Ist.MBE.event);
sewardj3e838932005-01-07 12:09:15 +00001166 break;
sewardj17442fe2004-09-20 14:54:28 +00001167 case Ist_Exit:
1168 vex_printf( "if (" );
sewardj0276d4b2004-11-15 15:30:21 +00001169 ppIRExpr(s->Ist.Exit.guard);
sewardj893aada2004-11-29 19:57:54 +00001170 vex_printf( ") goto {");
1171 ppIRJumpKind(s->Ist.Exit.jk);
1172 vex_printf("} ");
sewardj17442fe2004-09-20 14:54:28 +00001173 ppIRConst(s->Ist.Exit.dst);
1174 break;
1175 default:
1176 vpanic("ppIRStmt");
1177 }
sewardjec6ad592004-06-20 12:26:53 +00001178}
1179
sewardj35421a32004-07-05 13:12:34 +00001180void ppIRTypeEnv ( IRTypeEnv* env ) {
sewardjc97096c2004-06-30 09:28:04 +00001181 UInt i;
sewardje539a402004-07-14 18:24:17 +00001182 for (i = 0; i < env->types_used; i++) {
sewardjc97096c2004-06-30 09:28:04 +00001183 if (i % 8 == 0)
sewardj35421a32004-07-05 13:12:34 +00001184 vex_printf( " ");
sewardje539a402004-07-14 18:24:17 +00001185 ppIRTemp(i);
sewardj35421a32004-07-05 13:12:34 +00001186 vex_printf( ":");
sewardje539a402004-07-14 18:24:17 +00001187 ppIRType(env->types[i]);
sewardjc97096c2004-06-30 09:28:04 +00001188 if (i % 8 == 7)
sewardj35421a32004-07-05 13:12:34 +00001189 vex_printf( "\n");
sewardjc97096c2004-06-30 09:28:04 +00001190 else
sewardj35421a32004-07-05 13:12:34 +00001191 vex_printf( " ");
sewardjc97096c2004-06-30 09:28:04 +00001192 }
sewardje539a402004-07-14 18:24:17 +00001193 if (env->types_used > 0 && env->types_used % 8 != 7)
sewardj35421a32004-07-05 13:12:34 +00001194 vex_printf( "\n");
sewardjc97096c2004-06-30 09:28:04 +00001195}
1196
sewardjdd40fdf2006-12-24 02:20:24 +00001197void ppIRSB ( IRSB* bb )
sewardjec6ad592004-06-20 12:26:53 +00001198{
sewardjd7cb8532004-08-17 23:59:23 +00001199 Int i;
sewardjdd40fdf2006-12-24 02:20:24 +00001200 vex_printf("IRSB {\n");
sewardj35421a32004-07-05 13:12:34 +00001201 ppIRTypeEnv(bb->tyenv);
sewardj35439212004-07-14 22:36:10 +00001202 vex_printf("\n");
sewardjd7cb8532004-08-17 23:59:23 +00001203 for (i = 0; i < bb->stmts_used; i++) {
sewardjd2445f62005-03-21 00:15:53 +00001204 vex_printf( " ");
1205 ppIRStmt(bb->stmts[i]);
sewardj35421a32004-07-05 13:12:34 +00001206 vex_printf( "\n");
sewardjec6ad592004-06-20 12:26:53 +00001207 }
sewardje539a402004-07-14 18:24:17 +00001208 vex_printf( " goto {");
1209 ppIRJumpKind(bb->jumpkind);
1210 vex_printf( "} ");
1211 ppIRExpr( bb->next );
sewardj35439212004-07-14 22:36:10 +00001212 vex_printf( "\n}\n");
sewardjec6ad592004-06-20 12:26:53 +00001213}
1214
1215
1216/*---------------------------------------------------------------*/
1217/*--- Constructors ---*/
1218/*---------------------------------------------------------------*/
1219
sewardjc97096c2004-06-30 09:28:04 +00001220
1221/* Constructors -- IRConst */
1222
sewardjba999312004-11-15 15:21:17 +00001223IRConst* IRConst_U1 ( Bool bit )
sewardjb8e75862004-08-19 17:58:45 +00001224{
1225 IRConst* c = LibVEX_Alloc(sizeof(IRConst));
sewardjba999312004-11-15 15:21:17 +00001226 c->tag = Ico_U1;
1227 c->Ico.U1 = bit;
sewardj4b861de2004-11-03 15:24:42 +00001228 /* call me paranoid; I don't care :-) */
1229 vassert(bit == False || bit == True);
sewardjb8e75862004-08-19 17:58:45 +00001230 return c;
1231}
sewardjc97096c2004-06-30 09:28:04 +00001232IRConst* IRConst_U8 ( UChar u8 )
1233{
sewardj35421a32004-07-05 13:12:34 +00001234 IRConst* c = LibVEX_Alloc(sizeof(IRConst));
sewardjc97096c2004-06-30 09:28:04 +00001235 c->tag = Ico_U8;
1236 c->Ico.U8 = u8;
1237 return c;
1238}
1239IRConst* IRConst_U16 ( UShort u16 )
1240{
sewardj35421a32004-07-05 13:12:34 +00001241 IRConst* c = LibVEX_Alloc(sizeof(IRConst));
sewardjc97096c2004-06-30 09:28:04 +00001242 c->tag = Ico_U16;
1243 c->Ico.U16 = u16;
1244 return c;
1245}
1246IRConst* IRConst_U32 ( UInt u32 )
1247{
sewardj35421a32004-07-05 13:12:34 +00001248 IRConst* c = LibVEX_Alloc(sizeof(IRConst));
sewardjc97096c2004-06-30 09:28:04 +00001249 c->tag = Ico_U32;
1250 c->Ico.U32 = u32;
1251 return c;
1252}
1253IRConst* IRConst_U64 ( ULong u64 )
1254{
sewardj35421a32004-07-05 13:12:34 +00001255 IRConst* c = LibVEX_Alloc(sizeof(IRConst));
sewardjc97096c2004-06-30 09:28:04 +00001256 c->tag = Ico_U64;
1257 c->Ico.U64 = u64;
1258 return c;
1259}
sewardja58ea662004-08-15 03:12:41 +00001260IRConst* IRConst_F64 ( Double f64 )
1261{
1262 IRConst* c = LibVEX_Alloc(sizeof(IRConst));
1263 c->tag = Ico_F64;
1264 c->Ico.F64 = f64;
1265 return c;
1266}
sewardj17442fe2004-09-20 14:54:28 +00001267IRConst* IRConst_F64i ( ULong f64i )
sewardj207557a2004-08-27 12:00:18 +00001268{
sewardj17442fe2004-09-20 14:54:28 +00001269 IRConst* c = LibVEX_Alloc(sizeof(IRConst));
1270 c->tag = Ico_F64i;
1271 c->Ico.F64i = f64i;
sewardj207557a2004-08-27 12:00:18 +00001272 return c;
1273}
sewardj1e6ad742004-12-02 16:16:11 +00001274IRConst* IRConst_V128 ( UShort con )
1275{
1276 IRConst* c = LibVEX_Alloc(sizeof(IRConst));
1277 c->tag = Ico_V128;
1278 c->Ico.V128 = con;
1279 return c;
1280}
sewardjc97096c2004-06-30 09:28:04 +00001281
sewardj8ea867b2004-10-30 19:03:02 +00001282/* Constructors -- IRCallee */
1283
sewardj2d49b432005-02-01 00:37:06 +00001284IRCallee* mkIRCallee ( Int regparms, HChar* name, void* addr )
sewardj8ea867b2004-10-30 19:03:02 +00001285{
1286 IRCallee* ce = LibVEX_Alloc(sizeof(IRCallee));
sewardj77352542004-10-30 20:39:01 +00001287 ce->regparms = regparms;
1288 ce->name = name;
1289 ce->addr = addr;
sewardj43c56462004-11-06 12:17:57 +00001290 ce->mcx_mask = 0;
sewardj77352542004-10-30 20:39:01 +00001291 vassert(regparms >= 0 && regparms <= 3);
sewardj8ea867b2004-10-30 19:03:02 +00001292 vassert(name != NULL);
1293 vassert(addr != 0);
1294 return ce;
1295}
1296
1297
sewardjdd40fdf2006-12-24 02:20:24 +00001298/* Constructors -- IRRegArray */
sewardje3d0d2e2004-06-27 10:42:44 +00001299
sewardjdd40fdf2006-12-24 02:20:24 +00001300IRRegArray* mkIRRegArray ( Int base, IRType elemTy, Int nElems )
sewardj2d3f77c2004-09-22 23:49:09 +00001301{
sewardjdd40fdf2006-12-24 02:20:24 +00001302 IRRegArray* arr = LibVEX_Alloc(sizeof(IRRegArray));
1303 arr->base = base;
1304 arr->elemTy = elemTy;
1305 arr->nElems = nElems;
sewardj2d3f77c2004-09-22 23:49:09 +00001306 vassert(!(arr->base < 0 || arr->base > 10000 /* somewhat arbitrary */));
sewardjba999312004-11-15 15:21:17 +00001307 vassert(!(arr->elemTy == Ity_I1));
sewardj2d3f77c2004-09-22 23:49:09 +00001308 vassert(!(arr->nElems <= 0 || arr->nElems > 500 /* somewhat arbitrary */));
1309 return arr;
1310}
1311
1312
1313/* Constructors -- IRExpr */
1314
sewardj443cd9d2004-07-18 23:06:45 +00001315IRExpr* IRExpr_Binder ( Int binder ) {
1316 IRExpr* e = LibVEX_Alloc(sizeof(IRExpr));
1317 e->tag = Iex_Binder;
1318 e->Iex.Binder.binder = binder;
1319 return e;
1320}
sewardjfbcaf332004-07-08 01:46:01 +00001321IRExpr* IRExpr_Get ( Int off, IRType ty ) {
sewardj35421a32004-07-05 13:12:34 +00001322 IRExpr* e = LibVEX_Alloc(sizeof(IRExpr));
sewardje3d0d2e2004-06-27 10:42:44 +00001323 e->tag = Iex_Get;
1324 e->Iex.Get.offset = off;
sewardjfbcaf332004-07-08 01:46:01 +00001325 e->Iex.Get.ty = ty;
sewardje3d0d2e2004-06-27 10:42:44 +00001326 return e;
1327}
sewardjdd40fdf2006-12-24 02:20:24 +00001328IRExpr* IRExpr_GetI ( IRRegArray* descr, IRExpr* ix, Int bias ) {
sewardj2d3f77c2004-09-22 23:49:09 +00001329 IRExpr* e = LibVEX_Alloc(sizeof(IRExpr));
1330 e->tag = Iex_GetI;
1331 e->Iex.GetI.descr = descr;
sewardjeeac8412004-11-02 00:26:55 +00001332 e->Iex.GetI.ix = ix;
sewardj2d3f77c2004-09-22 23:49:09 +00001333 e->Iex.GetI.bias = bias;
sewardjd1725d12004-08-12 20:46:53 +00001334 return e;
1335}
sewardjdd40fdf2006-12-24 02:20:24 +00001336IRExpr* IRExpr_RdTmp ( IRTemp tmp ) {
1337 IRExpr* e = LibVEX_Alloc(sizeof(IRExpr));
1338 e->tag = Iex_RdTmp;
1339 e->Iex.RdTmp.tmp = tmp;
sewardje3d0d2e2004-06-27 10:42:44 +00001340 return e;
1341}
sewardj40c80262006-02-08 19:30:46 +00001342IRExpr* IRExpr_Qop ( IROp op, IRExpr* arg1, IRExpr* arg2,
1343 IRExpr* arg3, IRExpr* arg4 ) {
1344 IRExpr* e = LibVEX_Alloc(sizeof(IRExpr));
1345 e->tag = Iex_Qop;
1346 e->Iex.Qop.op = op;
1347 e->Iex.Qop.arg1 = arg1;
1348 e->Iex.Qop.arg2 = arg2;
1349 e->Iex.Qop.arg3 = arg3;
1350 e->Iex.Qop.arg4 = arg4;
1351 return e;
1352}
sewardjb183b852006-02-03 16:08:03 +00001353IRExpr* IRExpr_Triop ( IROp op, IRExpr* arg1,
1354 IRExpr* arg2, IRExpr* arg3 ) {
1355 IRExpr* e = LibVEX_Alloc(sizeof(IRExpr));
1356 e->tag = Iex_Triop;
1357 e->Iex.Triop.op = op;
1358 e->Iex.Triop.arg1 = arg1;
1359 e->Iex.Triop.arg2 = arg2;
1360 e->Iex.Triop.arg3 = arg3;
1361 return e;
1362}
sewardjc97096c2004-06-30 09:28:04 +00001363IRExpr* IRExpr_Binop ( IROp op, IRExpr* arg1, IRExpr* arg2 ) {
sewardj35421a32004-07-05 13:12:34 +00001364 IRExpr* e = LibVEX_Alloc(sizeof(IRExpr));
sewardje3d0d2e2004-06-27 10:42:44 +00001365 e->tag = Iex_Binop;
1366 e->Iex.Binop.op = op;
1367 e->Iex.Binop.arg1 = arg1;
1368 e->Iex.Binop.arg2 = arg2;
1369 return e;
1370}
sewardjc97096c2004-06-30 09:28:04 +00001371IRExpr* IRExpr_Unop ( IROp op, IRExpr* arg ) {
sewardj35421a32004-07-05 13:12:34 +00001372 IRExpr* e = LibVEX_Alloc(sizeof(IRExpr));
sewardje3d0d2e2004-06-27 10:42:44 +00001373 e->tag = Iex_Unop;
1374 e->Iex.Unop.op = op;
1375 e->Iex.Unop.arg = arg;
1376 return e;
1377}
sewardje768e922009-11-26 17:17:37 +00001378IRExpr* IRExpr_Load ( IREndness end, IRType ty, IRExpr* addr ) {
sewardj35421a32004-07-05 13:12:34 +00001379 IRExpr* e = LibVEX_Alloc(sizeof(IRExpr));
sewardjaf1ceca2005-06-30 23:31:27 +00001380 e->tag = Iex_Load;
1381 e->Iex.Load.end = end;
1382 e->Iex.Load.ty = ty;
1383 e->Iex.Load.addr = addr;
1384 vassert(end == Iend_LE || end == Iend_BE);
sewardje3d0d2e2004-06-27 10:42:44 +00001385 return e;
1386}
sewardjc97096c2004-06-30 09:28:04 +00001387IRExpr* IRExpr_Const ( IRConst* con ) {
sewardj35421a32004-07-05 13:12:34 +00001388 IRExpr* e = LibVEX_Alloc(sizeof(IRExpr));
sewardje3d0d2e2004-06-27 10:42:44 +00001389 e->tag = Iex_Const;
1390 e->Iex.Const.con = con;
1391 return e;
sewardjec6ad592004-06-20 12:26:53 +00001392}
sewardj8ea867b2004-10-30 19:03:02 +00001393IRExpr* IRExpr_CCall ( IRCallee* cee, IRType retty, IRExpr** args ) {
sewardje87b4842004-07-10 12:23:30 +00001394 IRExpr* e = LibVEX_Alloc(sizeof(IRExpr));
1395 e->tag = Iex_CCall;
sewardj8ea867b2004-10-30 19:03:02 +00001396 e->Iex.CCall.cee = cee;
sewardje87b4842004-07-10 12:23:30 +00001397 e->Iex.CCall.retty = retty;
1398 e->Iex.CCall.args = args;
1399 return e;
1400}
sewardj4042c7e2004-07-18 01:28:30 +00001401IRExpr* IRExpr_Mux0X ( IRExpr* cond, IRExpr* expr0, IRExpr* exprX ) {
sewardjeeb9ef82004-07-15 12:39:03 +00001402 IRExpr* e = LibVEX_Alloc(sizeof(IRExpr));
sewardj4042c7e2004-07-18 01:28:30 +00001403 e->tag = Iex_Mux0X;
1404 e->Iex.Mux0X.cond = cond;
1405 e->Iex.Mux0X.expr0 = expr0;
1406 e->Iex.Mux0X.exprX = exprX;
sewardjeeb9ef82004-07-15 12:39:03 +00001407 return e;
1408}
sewardjec6ad592004-06-20 12:26:53 +00001409
sewardjec6ad592004-06-20 12:26:53 +00001410
sewardjc5fc7aa2004-10-27 23:00:55 +00001411/* Constructors for NULL-terminated IRExpr expression vectors,
1412 suitable for use as arg lists in clean/dirty helper calls. */
1413
1414IRExpr** mkIRExprVec_0 ( void ) {
1415 IRExpr** vec = LibVEX_Alloc(1 * sizeof(IRExpr*));
1416 vec[0] = NULL;
1417 return vec;
1418}
1419IRExpr** mkIRExprVec_1 ( IRExpr* arg1 ) {
1420 IRExpr** vec = LibVEX_Alloc(2 * sizeof(IRExpr*));
1421 vec[0] = arg1;
1422 vec[1] = NULL;
1423 return vec;
1424}
1425IRExpr** mkIRExprVec_2 ( IRExpr* arg1, IRExpr* arg2 ) {
1426 IRExpr** vec = LibVEX_Alloc(3 * sizeof(IRExpr*));
1427 vec[0] = arg1;
1428 vec[1] = arg2;
1429 vec[2] = NULL;
1430 return vec;
1431}
sewardjf9655262004-10-31 20:02:16 +00001432IRExpr** mkIRExprVec_3 ( IRExpr* arg1, IRExpr* arg2, IRExpr* arg3 ) {
1433 IRExpr** vec = LibVEX_Alloc(4 * sizeof(IRExpr*));
1434 vec[0] = arg1;
1435 vec[1] = arg2;
1436 vec[2] = arg3;
1437 vec[3] = NULL;
1438 return vec;
1439}
sewardj78ec32b2007-01-08 05:09:55 +00001440IRExpr** mkIRExprVec_4 ( IRExpr* arg1, IRExpr* arg2, IRExpr* arg3,
1441 IRExpr* arg4 ) {
sewardjf9655262004-10-31 20:02:16 +00001442 IRExpr** vec = LibVEX_Alloc(5 * sizeof(IRExpr*));
1443 vec[0] = arg1;
1444 vec[1] = arg2;
1445 vec[2] = arg3;
1446 vec[3] = arg4;
1447 vec[4] = NULL;
1448 return vec;
1449}
sewardj78ec32b2007-01-08 05:09:55 +00001450IRExpr** mkIRExprVec_5 ( IRExpr* arg1, IRExpr* arg2, IRExpr* arg3,
1451 IRExpr* arg4, IRExpr* arg5 ) {
sewardjf32c67d2004-11-08 13:10:44 +00001452 IRExpr** vec = LibVEX_Alloc(6 * sizeof(IRExpr*));
1453 vec[0] = arg1;
1454 vec[1] = arg2;
1455 vec[2] = arg3;
1456 vec[3] = arg4;
1457 vec[4] = arg5;
1458 vec[5] = NULL;
1459 return vec;
1460}
sewardj78ec32b2007-01-08 05:09:55 +00001461IRExpr** mkIRExprVec_6 ( IRExpr* arg1, IRExpr* arg2, IRExpr* arg3,
1462 IRExpr* arg4, IRExpr* arg5, IRExpr* arg6 ) {
1463 IRExpr** vec = LibVEX_Alloc(7 * sizeof(IRExpr*));
1464 vec[0] = arg1;
1465 vec[1] = arg2;
1466 vec[2] = arg3;
1467 vec[3] = arg4;
1468 vec[4] = arg5;
1469 vec[5] = arg6;
1470 vec[6] = NULL;
1471 return vec;
1472}
1473IRExpr** mkIRExprVec_7 ( IRExpr* arg1, IRExpr* arg2, IRExpr* arg3,
1474 IRExpr* arg4, IRExpr* arg5, IRExpr* arg6,
1475 IRExpr* arg7 ) {
1476 IRExpr** vec = LibVEX_Alloc(8 * sizeof(IRExpr*));
1477 vec[0] = arg1;
1478 vec[1] = arg2;
1479 vec[2] = arg3;
1480 vec[3] = arg4;
1481 vec[4] = arg5;
1482 vec[5] = arg6;
1483 vec[6] = arg7;
1484 vec[7] = NULL;
1485 return vec;
1486}
sewardj2fdd4162010-08-22 12:59:02 +00001487IRExpr** mkIRExprVec_8 ( IRExpr* arg1, IRExpr* arg2, IRExpr* arg3,
1488 IRExpr* arg4, IRExpr* arg5, IRExpr* arg6,
1489 IRExpr* arg7, IRExpr* arg8 ) {
1490 IRExpr** vec = LibVEX_Alloc(9 * sizeof(IRExpr*));
1491 vec[0] = arg1;
1492 vec[1] = arg2;
1493 vec[2] = arg3;
1494 vec[3] = arg4;
1495 vec[4] = arg5;
1496 vec[5] = arg6;
1497 vec[6] = arg7;
1498 vec[7] = arg8;
1499 vec[8] = NULL;
1500 return vec;
1501}
sewardjc5fc7aa2004-10-27 23:00:55 +00001502
1503
sewardj17442fe2004-09-20 14:54:28 +00001504/* Constructors -- IRDirty */
1505
sewardjc5fc7aa2004-10-27 23:00:55 +00001506IRDirty* emptyIRDirty ( void ) {
sewardj17442fe2004-09-20 14:54:28 +00001507 IRDirty* d = LibVEX_Alloc(sizeof(IRDirty));
sewardj8ea867b2004-10-30 19:03:02 +00001508 d->cee = NULL;
sewardjb8385d82004-11-02 01:34:15 +00001509 d->guard = NULL;
sewardj17442fe2004-09-20 14:54:28 +00001510 d->args = NULL;
sewardj92d168d2004-11-15 14:22:12 +00001511 d->tmp = IRTemp_INVALID;
sewardj17442fe2004-09-20 14:54:28 +00001512 d->mFx = Ifx_None;
1513 d->mAddr = NULL;
1514 d->mSize = 0;
sewardjc5fc7aa2004-10-27 23:00:55 +00001515 d->needsBBP = False;
sewardj17442fe2004-09-20 14:54:28 +00001516 d->nFxState = 0;
1517 return d;
1518}
1519
1520
sewardje9d8a262009-07-01 08:06:34 +00001521/* Constructors -- IRCAS */
1522
1523IRCAS* mkIRCAS ( IRTemp oldHi, IRTemp oldLo,
1524 IREndness end, IRExpr* addr,
1525 IRExpr* expdHi, IRExpr* expdLo,
1526 IRExpr* dataHi, IRExpr* dataLo ) {
1527 IRCAS* cas = LibVEX_Alloc(sizeof(IRCAS));
1528 cas->oldHi = oldHi;
1529 cas->oldLo = oldLo;
1530 cas->end = end;
1531 cas->addr = addr;
1532 cas->expdHi = expdHi;
1533 cas->expdLo = expdLo;
1534 cas->dataHi = dataHi;
1535 cas->dataLo = dataLo;
1536 return cas;
1537}
1538
1539
sewardjec6ad592004-06-20 12:26:53 +00001540/* Constructors -- IRStmt */
sewardje3d0d2e2004-06-27 10:42:44 +00001541
sewardjd2445f62005-03-21 00:15:53 +00001542IRStmt* IRStmt_NoOp ( void )
1543{
1544 /* Just use a single static closure. */
1545 static IRStmt static_closure;
1546 static_closure.tag = Ist_NoOp;
1547 return &static_closure;
1548}
sewardjf1689312005-03-16 18:19:10 +00001549IRStmt* IRStmt_IMark ( Addr64 addr, Int len ) {
1550 IRStmt* s = LibVEX_Alloc(sizeof(IRStmt));
1551 s->tag = Ist_IMark;
1552 s->Ist.IMark.addr = addr;
1553 s->Ist.IMark.len = len;
1554 return s;
1555}
sewardj478646f2008-05-01 20:13:04 +00001556IRStmt* IRStmt_AbiHint ( IRExpr* base, Int len, IRExpr* nia ) {
sewardj5a9ffab2005-05-12 17:55:01 +00001557 IRStmt* s = LibVEX_Alloc(sizeof(IRStmt));
1558 s->tag = Ist_AbiHint;
1559 s->Ist.AbiHint.base = base;
1560 s->Ist.AbiHint.len = len;
sewardj478646f2008-05-01 20:13:04 +00001561 s->Ist.AbiHint.nia = nia;
sewardj5a9ffab2005-05-12 17:55:01 +00001562 return s;
1563}
sewardj6d076362004-09-23 11:06:17 +00001564IRStmt* IRStmt_Put ( Int off, IRExpr* data ) {
sewardj35421a32004-07-05 13:12:34 +00001565 IRStmt* s = LibVEX_Alloc(sizeof(IRStmt));
sewardje3d0d2e2004-06-27 10:42:44 +00001566 s->tag = Ist_Put;
1567 s->Ist.Put.offset = off;
sewardj6d076362004-09-23 11:06:17 +00001568 s->Ist.Put.data = data;
sewardje3d0d2e2004-06-27 10:42:44 +00001569 return s;
sewardjec6ad592004-06-20 12:26:53 +00001570}
sewardjdd40fdf2006-12-24 02:20:24 +00001571IRStmt* IRStmt_PutI ( IRRegArray* descr, IRExpr* ix,
sewardj2d3f77c2004-09-22 23:49:09 +00001572 Int bias, IRExpr* data ) {
1573 IRStmt* s = LibVEX_Alloc(sizeof(IRStmt));
1574 s->tag = Ist_PutI;
1575 s->Ist.PutI.descr = descr;
sewardjeeac8412004-11-02 00:26:55 +00001576 s->Ist.PutI.ix = ix;
sewardj2d3f77c2004-09-22 23:49:09 +00001577 s->Ist.PutI.bias = bias;
1578 s->Ist.PutI.data = data;
sewardjd1725d12004-08-12 20:46:53 +00001579 return s;
1580}
sewardjdd40fdf2006-12-24 02:20:24 +00001581IRStmt* IRStmt_WrTmp ( IRTemp tmp, IRExpr* data ) {
1582 IRStmt* s = LibVEX_Alloc(sizeof(IRStmt));
1583 s->tag = Ist_WrTmp;
1584 s->Ist.WrTmp.tmp = tmp;
1585 s->Ist.WrTmp.data = data;
sewardje3d0d2e2004-06-27 10:42:44 +00001586 return s;
sewardjec6ad592004-06-20 12:26:53 +00001587}
sewardje768e922009-11-26 17:17:37 +00001588IRStmt* IRStmt_Store ( IREndness end, IRExpr* addr, IRExpr* data ) {
1589 IRStmt* s = LibVEX_Alloc(sizeof(IRStmt));
1590 s->tag = Ist_Store;
1591 s->Ist.Store.end = end;
1592 s->Ist.Store.addr = addr;
1593 s->Ist.Store.data = data;
sewardjaf1ceca2005-06-30 23:31:27 +00001594 vassert(end == Iend_LE || end == Iend_BE);
sewardje3d0d2e2004-06-27 10:42:44 +00001595 return s;
sewardjec6ad592004-06-20 12:26:53 +00001596}
sewardje9d8a262009-07-01 08:06:34 +00001597IRStmt* IRStmt_CAS ( IRCAS* cas ) {
1598 IRStmt* s = LibVEX_Alloc(sizeof(IRStmt));
1599 s->tag = Ist_CAS;
1600 s->Ist.CAS.details = cas;
1601 return s;
1602}
sewardje768e922009-11-26 17:17:37 +00001603IRStmt* IRStmt_LLSC ( IREndness end,
1604 IRTemp result, IRExpr* addr, IRExpr* storedata ) {
1605 IRStmt* s = LibVEX_Alloc(sizeof(IRStmt));
1606 s->tag = Ist_LLSC;
1607 s->Ist.LLSC.end = end;
1608 s->Ist.LLSC.result = result;
1609 s->Ist.LLSC.addr = addr;
1610 s->Ist.LLSC.storedata = storedata;
1611 return s;
1612}
sewardj17442fe2004-09-20 14:54:28 +00001613IRStmt* IRStmt_Dirty ( IRDirty* d )
1614{
1615 IRStmt* s = LibVEX_Alloc(sizeof(IRStmt));
1616 s->tag = Ist_Dirty;
1617 s->Ist.Dirty.details = d;
1618 return s;
1619}
sewardjc4356f02007-11-09 21:15:04 +00001620IRStmt* IRStmt_MBE ( IRMBusEvent event )
sewardj3e838932005-01-07 12:09:15 +00001621{
sewardjc4356f02007-11-09 21:15:04 +00001622 IRStmt* s = LibVEX_Alloc(sizeof(IRStmt));
1623 s->tag = Ist_MBE;
1624 s->Ist.MBE.event = event;
1625 return s;
sewardj3e838932005-01-07 12:09:15 +00001626}
sewardj893aada2004-11-29 19:57:54 +00001627IRStmt* IRStmt_Exit ( IRExpr* guard, IRJumpKind jk, IRConst* dst ) {
sewardj0276d4b2004-11-15 15:30:21 +00001628 IRStmt* s = LibVEX_Alloc(sizeof(IRStmt));
1629 s->tag = Ist_Exit;
1630 s->Ist.Exit.guard = guard;
sewardj893aada2004-11-29 19:57:54 +00001631 s->Ist.Exit.jk = jk;
sewardj0276d4b2004-11-15 15:30:21 +00001632 s->Ist.Exit.dst = dst;
sewardj64e1d652004-07-12 14:00:46 +00001633 return s;
1634}
sewardje3d0d2e2004-06-27 10:42:44 +00001635
sewardj695cff92004-10-13 14:50:14 +00001636
1637/* Constructors -- IRTypeEnv */
1638
1639IRTypeEnv* emptyIRTypeEnv ( void )
1640{
1641 IRTypeEnv* env = LibVEX_Alloc(sizeof(IRTypeEnv));
1642 env->types = LibVEX_Alloc(8 * sizeof(IRType));
1643 env->types_size = 8;
1644 env->types_used = 0;
1645 return env;
1646}
1647
1648
sewardjdd40fdf2006-12-24 02:20:24 +00001649/* Constructors -- IRSB */
sewardje3d0d2e2004-06-27 10:42:44 +00001650
sewardjdd40fdf2006-12-24 02:20:24 +00001651IRSB* emptyIRSB ( void )
sewardjd7cb8532004-08-17 23:59:23 +00001652{
sewardjdd40fdf2006-12-24 02:20:24 +00001653 IRSB* bb = LibVEX_Alloc(sizeof(IRSB));
sewardjd7cb8532004-08-17 23:59:23 +00001654 bb->tyenv = emptyIRTypeEnv();
1655 bb->stmts_used = 0;
1656 bb->stmts_size = 8;
1657 bb->stmts = LibVEX_Alloc(bb->stmts_size * sizeof(IRStmt*));
1658 bb->next = NULL;
1659 bb->jumpkind = Ijk_Boring;
sewardje3d0d2e2004-06-27 10:42:44 +00001660 return bb;
sewardjec6ad592004-06-20 12:26:53 +00001661}
1662
sewardj695cff92004-10-13 14:50:14 +00001663
1664/*---------------------------------------------------------------*/
1665/*--- (Deep) copy constructors. These make complete copies ---*/
1666/*--- the original, which can be modified without affecting ---*/
1667/*--- the original. ---*/
1668/*---------------------------------------------------------------*/
1669
1670/* Copying IR Expr vectors (for call args). */
1671
1672/* Shallow copy of an IRExpr vector */
1673
sewardjdd40fdf2006-12-24 02:20:24 +00001674IRExpr** shallowCopyIRExprVec ( IRExpr** vec )
sewardjd7cb8532004-08-17 23:59:23 +00001675{
sewardj695cff92004-10-13 14:50:14 +00001676 Int i;
1677 IRExpr** newvec;
1678 for (i = 0; vec[i]; i++)
1679 ;
1680 newvec = LibVEX_Alloc((i+1)*sizeof(IRExpr*));
1681 for (i = 0; vec[i]; i++)
1682 newvec[i] = vec[i];
1683 newvec[i] = NULL;
1684 return newvec;
1685}
1686
1687/* Deep copy of an IRExpr vector */
1688
sewardjdd40fdf2006-12-24 02:20:24 +00001689IRExpr** deepCopyIRExprVec ( IRExpr** vec )
sewardj695cff92004-10-13 14:50:14 +00001690{
1691 Int i;
sewardjdd40fdf2006-12-24 02:20:24 +00001692 IRExpr** newvec = shallowCopyIRExprVec( vec );
sewardj695cff92004-10-13 14:50:14 +00001693 for (i = 0; newvec[i]; i++)
sewardjdd40fdf2006-12-24 02:20:24 +00001694 newvec[i] = deepCopyIRExpr(newvec[i]);
sewardj695cff92004-10-13 14:50:14 +00001695 return newvec;
1696}
1697
1698/* Deep copy constructors for all heap-allocated IR types follow. */
1699
sewardjdd40fdf2006-12-24 02:20:24 +00001700IRConst* deepCopyIRConst ( IRConst* c )
sewardj695cff92004-10-13 14:50:14 +00001701{
1702 switch (c->tag) {
sewardjba999312004-11-15 15:21:17 +00001703 case Ico_U1: return IRConst_U1(c->Ico.U1);
sewardj695cff92004-10-13 14:50:14 +00001704 case Ico_U8: return IRConst_U8(c->Ico.U8);
1705 case Ico_U16: return IRConst_U16(c->Ico.U16);
1706 case Ico_U32: return IRConst_U32(c->Ico.U32);
1707 case Ico_U64: return IRConst_U64(c->Ico.U64);
1708 case Ico_F64: return IRConst_F64(c->Ico.F64);
1709 case Ico_F64i: return IRConst_F64i(c->Ico.F64i);
sewardj1e6ad742004-12-02 16:16:11 +00001710 case Ico_V128: return IRConst_V128(c->Ico.V128);
sewardjdd40fdf2006-12-24 02:20:24 +00001711 default: vpanic("deepCopyIRConst");
sewardjd7cb8532004-08-17 23:59:23 +00001712 }
sewardj695cff92004-10-13 14:50:14 +00001713}
1714
sewardjdd40fdf2006-12-24 02:20:24 +00001715IRCallee* deepCopyIRCallee ( IRCallee* ce )
sewardj8ea867b2004-10-30 19:03:02 +00001716{
sewardj43c56462004-11-06 12:17:57 +00001717 IRCallee* ce2 = mkIRCallee(ce->regparms, ce->name, ce->addr);
1718 ce2->mcx_mask = ce->mcx_mask;
1719 return ce2;
sewardj8ea867b2004-10-30 19:03:02 +00001720}
1721
sewardjdd40fdf2006-12-24 02:20:24 +00001722IRRegArray* deepCopyIRRegArray ( IRRegArray* d )
sewardj695cff92004-10-13 14:50:14 +00001723{
sewardjdd40fdf2006-12-24 02:20:24 +00001724 return mkIRRegArray(d->base, d->elemTy, d->nElems);
sewardj695cff92004-10-13 14:50:14 +00001725}
1726
sewardjdd40fdf2006-12-24 02:20:24 +00001727IRExpr* deepCopyIRExpr ( IRExpr* e )
sewardj695cff92004-10-13 14:50:14 +00001728{
1729 switch (e->tag) {
1730 case Iex_Get:
1731 return IRExpr_Get(e->Iex.Get.offset, e->Iex.Get.ty);
1732 case Iex_GetI:
sewardjdd40fdf2006-12-24 02:20:24 +00001733 return IRExpr_GetI(deepCopyIRRegArray(e->Iex.GetI.descr),
1734 deepCopyIRExpr(e->Iex.GetI.ix),
sewardj695cff92004-10-13 14:50:14 +00001735 e->Iex.GetI.bias);
sewardjdd40fdf2006-12-24 02:20:24 +00001736 case Iex_RdTmp:
1737 return IRExpr_RdTmp(e->Iex.RdTmp.tmp);
sewardj1a866b42006-02-09 02:54:03 +00001738 case Iex_Qop:
1739 return IRExpr_Qop(e->Iex.Qop.op,
sewardjdd40fdf2006-12-24 02:20:24 +00001740 deepCopyIRExpr(e->Iex.Qop.arg1),
1741 deepCopyIRExpr(e->Iex.Qop.arg2),
1742 deepCopyIRExpr(e->Iex.Qop.arg3),
1743 deepCopyIRExpr(e->Iex.Qop.arg4));
sewardjb183b852006-02-03 16:08:03 +00001744 case Iex_Triop:
1745 return IRExpr_Triop(e->Iex.Triop.op,
sewardjdd40fdf2006-12-24 02:20:24 +00001746 deepCopyIRExpr(e->Iex.Triop.arg1),
1747 deepCopyIRExpr(e->Iex.Triop.arg2),
1748 deepCopyIRExpr(e->Iex.Triop.arg3));
sewardj695cff92004-10-13 14:50:14 +00001749 case Iex_Binop:
1750 return IRExpr_Binop(e->Iex.Binop.op,
sewardjdd40fdf2006-12-24 02:20:24 +00001751 deepCopyIRExpr(e->Iex.Binop.arg1),
1752 deepCopyIRExpr(e->Iex.Binop.arg2));
sewardj695cff92004-10-13 14:50:14 +00001753 case Iex_Unop:
1754 return IRExpr_Unop(e->Iex.Unop.op,
sewardjdd40fdf2006-12-24 02:20:24 +00001755 deepCopyIRExpr(e->Iex.Unop.arg));
sewardjaf1ceca2005-06-30 23:31:27 +00001756 case Iex_Load:
sewardje768e922009-11-26 17:17:37 +00001757 return IRExpr_Load(e->Iex.Load.end,
sewardjaf1ceca2005-06-30 23:31:27 +00001758 e->Iex.Load.ty,
sewardjdd40fdf2006-12-24 02:20:24 +00001759 deepCopyIRExpr(e->Iex.Load.addr));
sewardj695cff92004-10-13 14:50:14 +00001760 case Iex_Const:
sewardjdd40fdf2006-12-24 02:20:24 +00001761 return IRExpr_Const(deepCopyIRConst(e->Iex.Const.con));
sewardj695cff92004-10-13 14:50:14 +00001762 case Iex_CCall:
sewardjdd40fdf2006-12-24 02:20:24 +00001763 return IRExpr_CCall(deepCopyIRCallee(e->Iex.CCall.cee),
sewardj695cff92004-10-13 14:50:14 +00001764 e->Iex.CCall.retty,
sewardjdd40fdf2006-12-24 02:20:24 +00001765 deepCopyIRExprVec(e->Iex.CCall.args));
sewardj695cff92004-10-13 14:50:14 +00001766
1767 case Iex_Mux0X:
sewardjdd40fdf2006-12-24 02:20:24 +00001768 return IRExpr_Mux0X(deepCopyIRExpr(e->Iex.Mux0X.cond),
1769 deepCopyIRExpr(e->Iex.Mux0X.expr0),
1770 deepCopyIRExpr(e->Iex.Mux0X.exprX));
sewardj695cff92004-10-13 14:50:14 +00001771 default:
sewardjdd40fdf2006-12-24 02:20:24 +00001772 vpanic("deepCopyIRExpr");
sewardj695cff92004-10-13 14:50:14 +00001773 }
1774}
1775
sewardjdd40fdf2006-12-24 02:20:24 +00001776IRDirty* deepCopyIRDirty ( IRDirty* d )
sewardj695cff92004-10-13 14:50:14 +00001777{
1778 Int i;
1779 IRDirty* d2 = emptyIRDirty();
sewardjdd40fdf2006-12-24 02:20:24 +00001780 d2->cee = deepCopyIRCallee(d->cee);
1781 d2->guard = deepCopyIRExpr(d->guard);
1782 d2->args = deepCopyIRExprVec(d->args);
sewardj695cff92004-10-13 14:50:14 +00001783 d2->tmp = d->tmp;
1784 d2->mFx = d->mFx;
sewardjdd40fdf2006-12-24 02:20:24 +00001785 d2->mAddr = d->mAddr==NULL ? NULL : deepCopyIRExpr(d->mAddr);
sewardj695cff92004-10-13 14:50:14 +00001786 d2->mSize = d->mSize;
sewardjc5fc7aa2004-10-27 23:00:55 +00001787 d2->needsBBP = d->needsBBP;
sewardj695cff92004-10-13 14:50:14 +00001788 d2->nFxState = d->nFxState;
1789 for (i = 0; i < d2->nFxState; i++)
1790 d2->fxState[i] = d->fxState[i];
1791 return d2;
1792}
1793
sewardje9d8a262009-07-01 08:06:34 +00001794IRCAS* deepCopyIRCAS ( IRCAS* cas )
1795{
1796 return mkIRCAS( cas->oldHi, cas->oldLo, cas->end,
1797 deepCopyIRExpr(cas->addr),
sewardj05a2c382009-07-17 16:34:30 +00001798 cas->expdHi==NULL ? NULL : deepCopyIRExpr(cas->expdHi),
sewardje9d8a262009-07-01 08:06:34 +00001799 deepCopyIRExpr(cas->expdLo),
sewardj05a2c382009-07-17 16:34:30 +00001800 cas->dataHi==NULL ? NULL : deepCopyIRExpr(cas->dataHi),
sewardje9d8a262009-07-01 08:06:34 +00001801 deepCopyIRExpr(cas->dataLo) );
1802}
1803
sewardjdd40fdf2006-12-24 02:20:24 +00001804IRStmt* deepCopyIRStmt ( IRStmt* s )
sewardj695cff92004-10-13 14:50:14 +00001805{
1806 switch (s->tag) {
sewardjd2445f62005-03-21 00:15:53 +00001807 case Ist_NoOp:
1808 return IRStmt_NoOp();
sewardj5a9ffab2005-05-12 17:55:01 +00001809 case Ist_AbiHint:
sewardjdd40fdf2006-12-24 02:20:24 +00001810 return IRStmt_AbiHint(deepCopyIRExpr(s->Ist.AbiHint.base),
sewardj478646f2008-05-01 20:13:04 +00001811 s->Ist.AbiHint.len,
1812 deepCopyIRExpr(s->Ist.AbiHint.nia));
sewardjf1689312005-03-16 18:19:10 +00001813 case Ist_IMark:
1814 return IRStmt_IMark(s->Ist.IMark.addr, s->Ist.IMark.len);
sewardj695cff92004-10-13 14:50:14 +00001815 case Ist_Put:
1816 return IRStmt_Put(s->Ist.Put.offset,
sewardjdd40fdf2006-12-24 02:20:24 +00001817 deepCopyIRExpr(s->Ist.Put.data));
sewardj695cff92004-10-13 14:50:14 +00001818 case Ist_PutI:
sewardjdd40fdf2006-12-24 02:20:24 +00001819 return IRStmt_PutI(deepCopyIRRegArray(s->Ist.PutI.descr),
1820 deepCopyIRExpr(s->Ist.PutI.ix),
sewardj695cff92004-10-13 14:50:14 +00001821 s->Ist.PutI.bias,
sewardjdd40fdf2006-12-24 02:20:24 +00001822 deepCopyIRExpr(s->Ist.PutI.data));
1823 case Ist_WrTmp:
1824 return IRStmt_WrTmp(s->Ist.WrTmp.tmp,
1825 deepCopyIRExpr(s->Ist.WrTmp.data));
sewardjaf1ceca2005-06-30 23:31:27 +00001826 case Ist_Store:
1827 return IRStmt_Store(s->Ist.Store.end,
sewardjdd40fdf2006-12-24 02:20:24 +00001828 deepCopyIRExpr(s->Ist.Store.addr),
1829 deepCopyIRExpr(s->Ist.Store.data));
sewardje9d8a262009-07-01 08:06:34 +00001830 case Ist_CAS:
1831 return IRStmt_CAS(deepCopyIRCAS(s->Ist.CAS.details));
sewardje768e922009-11-26 17:17:37 +00001832 case Ist_LLSC:
1833 return IRStmt_LLSC(s->Ist.LLSC.end,
1834 s->Ist.LLSC.result,
1835 deepCopyIRExpr(s->Ist.LLSC.addr),
1836 s->Ist.LLSC.storedata
1837 ? deepCopyIRExpr(s->Ist.LLSC.storedata)
1838 : NULL);
sewardj695cff92004-10-13 14:50:14 +00001839 case Ist_Dirty:
sewardjdd40fdf2006-12-24 02:20:24 +00001840 return IRStmt_Dirty(deepCopyIRDirty(s->Ist.Dirty.details));
sewardjc4356f02007-11-09 21:15:04 +00001841 case Ist_MBE:
1842 return IRStmt_MBE(s->Ist.MBE.event);
sewardj695cff92004-10-13 14:50:14 +00001843 case Ist_Exit:
sewardjdd40fdf2006-12-24 02:20:24 +00001844 return IRStmt_Exit(deepCopyIRExpr(s->Ist.Exit.guard),
sewardj893aada2004-11-29 19:57:54 +00001845 s->Ist.Exit.jk,
sewardjdd40fdf2006-12-24 02:20:24 +00001846 deepCopyIRConst(s->Ist.Exit.dst));
sewardj695cff92004-10-13 14:50:14 +00001847 default:
sewardjdd40fdf2006-12-24 02:20:24 +00001848 vpanic("deepCopyIRStmt");
sewardj695cff92004-10-13 14:50:14 +00001849 }
1850}
1851
sewardjdd40fdf2006-12-24 02:20:24 +00001852IRTypeEnv* deepCopyIRTypeEnv ( IRTypeEnv* src )
sewardj695cff92004-10-13 14:50:14 +00001853{
1854 Int i;
1855 IRTypeEnv* dst = LibVEX_Alloc(sizeof(IRTypeEnv));
1856 dst->types_size = src->types_size;
1857 dst->types_used = src->types_used;
1858 dst->types = LibVEX_Alloc(dst->types_size * sizeof(IRType));
1859 for (i = 0; i < src->types_used; i++)
1860 dst->types[i] = src->types[i];
1861 return dst;
1862}
1863
sewardjdd40fdf2006-12-24 02:20:24 +00001864IRSB* deepCopyIRSB ( IRSB* bb )
sewardj695cff92004-10-13 14:50:14 +00001865{
1866 Int i;
1867 IRStmt** sts2;
sewardjdd40fdf2006-12-24 02:20:24 +00001868 IRSB* bb2 = deepCopyIRSBExceptStmts(bb);
sewardj695cff92004-10-13 14:50:14 +00001869 bb2->stmts_used = bb2->stmts_size = bb->stmts_used;
1870 sts2 = LibVEX_Alloc(bb2->stmts_used * sizeof(IRStmt*));
1871 for (i = 0; i < bb2->stmts_used; i++)
sewardjdd40fdf2006-12-24 02:20:24 +00001872 sts2[i] = deepCopyIRStmt(bb->stmts[i]);
sewardj695cff92004-10-13 14:50:14 +00001873 bb2->stmts = sts2;
sewardj6f2f2832006-11-24 23:32:55 +00001874 return bb2;
1875}
1876
sewardjdd40fdf2006-12-24 02:20:24 +00001877IRSB* deepCopyIRSBExceptStmts ( IRSB* bb )
sewardj6f2f2832006-11-24 23:32:55 +00001878{
sewardjdd40fdf2006-12-24 02:20:24 +00001879 IRSB* bb2 = emptyIRSB();
1880 bb2->tyenv = deepCopyIRTypeEnv(bb->tyenv);
1881 bb2->next = deepCopyIRExpr(bb->next);
sewardj695cff92004-10-13 14:50:14 +00001882 bb2->jumpkind = bb->jumpkind;
1883 return bb2;
sewardjd7cb8532004-08-17 23:59:23 +00001884}
1885
sewardjec6ad592004-06-20 12:26:53 +00001886
sewardjc97096c2004-06-30 09:28:04 +00001887/*---------------------------------------------------------------*/
sewardj6efd4a12004-07-15 03:54:23 +00001888/*--- Primop types ---*/
1889/*---------------------------------------------------------------*/
1890
1891static
sewardjb183b852006-02-03 16:08:03 +00001892void typeOfPrimop ( IROp op,
1893 /*OUTs*/
1894 IRType* t_dst,
sewardj40c80262006-02-08 19:30:46 +00001895 IRType* t_arg1, IRType* t_arg2,
1896 IRType* t_arg3, IRType* t_arg4 )
sewardj6efd4a12004-07-15 03:54:23 +00001897{
sewardjb183b852006-02-03 16:08:03 +00001898# define UNARY(_ta1,_td) \
sewardj6efd4a12004-07-15 03:54:23 +00001899 *t_dst = (_td); *t_arg1 = (_ta1); break
sewardjb183b852006-02-03 16:08:03 +00001900# define BINARY(_ta1,_ta2,_td) \
sewardj6efd4a12004-07-15 03:54:23 +00001901 *t_dst = (_td); *t_arg1 = (_ta1); *t_arg2 = (_ta2); break
sewardjb183b852006-02-03 16:08:03 +00001902# define TERNARY(_ta1,_ta2,_ta3,_td) \
1903 *t_dst = (_td); *t_arg1 = (_ta1); \
1904 *t_arg2 = (_ta2); *t_arg3 = (_ta3); break
sewardj40c80262006-02-08 19:30:46 +00001905# define QUATERNARY(_ta1,_ta2,_ta3,_ta4,_td) \
1906 *t_dst = (_td); *t_arg1 = (_ta1); \
1907 *t_arg2 = (_ta2); *t_arg3 = (_ta3); \
1908 *t_arg4 = (_ta4); break
sewardjb183b852006-02-03 16:08:03 +00001909# define COMPARISON(_ta) \
sewardjba999312004-11-15 15:21:17 +00001910 *t_dst = Ity_I1; *t_arg1 = *t_arg2 = (_ta); break;
sewardjb183b852006-02-03 16:08:03 +00001911# define UNARY_COMPARISON(_ta) \
sewardj0033ddc2005-04-26 23:34:34 +00001912 *t_dst = Ity_I1; *t_arg1 = (_ta); break;
sewardj6efd4a12004-07-15 03:54:23 +00001913
sewardjb183b852006-02-03 16:08:03 +00001914 /* Rounding mode values are always Ity_I32, encoded as per
1915 IRRoundingMode */
1916 const IRType ity_RMode = Ity_I32;
1917
sewardj6efd4a12004-07-15 03:54:23 +00001918 *t_dst = Ity_INVALID;
1919 *t_arg1 = Ity_INVALID;
1920 *t_arg2 = Ity_INVALID;
sewardjb183b852006-02-03 16:08:03 +00001921 *t_arg3 = Ity_INVALID;
sewardj40c80262006-02-08 19:30:46 +00001922 *t_arg4 = Ity_INVALID;
sewardj6efd4a12004-07-15 03:54:23 +00001923 switch (op) {
sewardj17442fe2004-09-20 14:54:28 +00001924 case Iop_Add8: case Iop_Sub8: case Iop_Mul8:
1925 case Iop_Or8: case Iop_And8: case Iop_Xor8:
sewardjb183b852006-02-03 16:08:03 +00001926 BINARY(Ity_I8,Ity_I8, Ity_I8);
sewardj6efd4a12004-07-15 03:54:23 +00001927
sewardj17442fe2004-09-20 14:54:28 +00001928 case Iop_Add16: case Iop_Sub16: case Iop_Mul16:
1929 case Iop_Or16: case Iop_And16: case Iop_Xor16:
sewardjb183b852006-02-03 16:08:03 +00001930 BINARY(Ity_I16,Ity_I16, Ity_I16);
sewardj6efd4a12004-07-15 03:54:23 +00001931
sewardjb51f0f42005-07-18 11:38:02 +00001932 case Iop_CmpORD32U:
1933 case Iop_CmpORD32S:
sewardj17442fe2004-09-20 14:54:28 +00001934 case Iop_Add32: case Iop_Sub32: case Iop_Mul32:
1935 case Iop_Or32: case Iop_And32: case Iop_Xor32:
sewardj478646f2008-05-01 20:13:04 +00001936 case Iop_Max32U:
sewardje2ea1762010-09-22 00:56:37 +00001937 case Iop_Add16x2: case Iop_Sub16x2:
1938 case Iop_QAdd16Sx2: case Iop_QAdd16Ux2:
1939 case Iop_QSub16Sx2: case Iop_QSub16Ux2:
1940 case Iop_HAdd16Ux2: case Iop_HAdd16Sx2:
1941 case Iop_HSub16Ux2: case Iop_HSub16Sx2:
1942 case Iop_Add8x4: case Iop_Sub8x4:
1943 case Iop_QAdd8Sx4: case Iop_QAdd8Ux4:
1944 case Iop_QSub8Sx4: case Iop_QSub8Ux4:
1945 case Iop_HAdd8Ux4: case Iop_HAdd8Sx4:
1946 case Iop_HSub8Ux4: case Iop_HSub8Sx4:
sewardjb183b852006-02-03 16:08:03 +00001947 BINARY(Ity_I32,Ity_I32, Ity_I32);
sewardj6efd4a12004-07-15 03:54:23 +00001948
sewardj17442fe2004-09-20 14:54:28 +00001949 case Iop_Add64: case Iop_Sub64: case Iop_Mul64:
1950 case Iop_Or64: case Iop_And64: case Iop_Xor64:
cerion2831b002005-11-30 19:55:22 +00001951 case Iop_CmpORD64U:
1952 case Iop_CmpORD64S:
sewardj38a3f862005-01-13 15:06:51 +00001953 case Iop_Avg8Ux8: case Iop_Avg16Ux4:
1954 case Iop_Add8x8: case Iop_Add16x4: case Iop_Add32x2:
sewardj2fdd4162010-08-22 12:59:02 +00001955 case Iop_Add32Fx2: case Iop_Sub32Fx2:
sewardj38a3f862005-01-13 15:06:51 +00001956 case Iop_CmpEQ8x8: case Iop_CmpEQ16x4: case Iop_CmpEQ32x2:
1957 case Iop_CmpGT8Sx8: case Iop_CmpGT16Sx4: case Iop_CmpGT32Sx2:
sewardj2fdd4162010-08-22 12:59:02 +00001958 case Iop_CmpGT8Ux8: case Iop_CmpGT16Ux4: case Iop_CmpGT32Ux2:
1959 case Iop_CmpGT32Fx2: case Iop_CmpEQ32Fx2: case Iop_CmpGE32Fx2:
sewardj38a3f862005-01-13 15:06:51 +00001960 case Iop_InterleaveHI8x8: case Iop_InterleaveLO8x8:
1961 case Iop_InterleaveHI16x4: case Iop_InterleaveLO16x4:
1962 case Iop_InterleaveHI32x2: case Iop_InterleaveLO32x2:
sewardj2fdd4162010-08-22 12:59:02 +00001963 case Iop_CatOddLanes8x8: case Iop_CatEvenLanes8x8:
sewardjd166e282008-02-06 11:42:45 +00001964 case Iop_CatOddLanes16x4: case Iop_CatEvenLanes16x4:
sewardj2fdd4162010-08-22 12:59:02 +00001965 case Iop_InterleaveOddLanes8x8: case Iop_InterleaveEvenLanes8x8:
1966 case Iop_InterleaveOddLanes16x4: case Iop_InterleaveEvenLanes16x4:
sewardjd166e282008-02-06 11:42:45 +00001967 case Iop_Perm8x8:
sewardj2fdd4162010-08-22 12:59:02 +00001968 case Iop_Max8Ux8: case Iop_Max16Ux4: case Iop_Max32Ux2:
1969 case Iop_Max8Sx8: case Iop_Max16Sx4: case Iop_Max32Sx2:
1970 case Iop_Max32Fx2: case Iop_Min32Fx2:
1971 case Iop_PwMax32Fx2: case Iop_PwMin32Fx2:
1972 case Iop_Min8Ux8: case Iop_Min16Ux4: case Iop_Min32Ux2:
1973 case Iop_Min8Sx8: case Iop_Min16Sx4: case Iop_Min32Sx2:
1974 case Iop_PwMax8Ux8: case Iop_PwMax16Ux4: case Iop_PwMax32Ux2:
1975 case Iop_PwMax8Sx8: case Iop_PwMax16Sx4: case Iop_PwMax32Sx2:
1976 case Iop_PwMin8Ux8: case Iop_PwMin16Ux4: case Iop_PwMin32Ux2:
1977 case Iop_PwMin8Sx8: case Iop_PwMin16Sx4: case Iop_PwMin32Sx2:
1978 case Iop_Mul8x8: case Iop_Mul16x4: case Iop_Mul32x2:
1979 case Iop_Mul32Fx2:
1980 case Iop_PolynomialMul8x8:
sewardjd166e282008-02-06 11:42:45 +00001981 case Iop_MulHi16Sx4: case Iop_MulHi16Ux4:
sewardj2fdd4162010-08-22 12:59:02 +00001982 case Iop_QDMulHi16Sx4: case Iop_QDMulHi32Sx2:
1983 case Iop_QRDMulHi16Sx4: case Iop_QRDMulHi32Sx2:
sewardj38a3f862005-01-13 15:06:51 +00001984 case Iop_QAdd8Sx8: case Iop_QAdd16Sx4:
sewardj2fdd4162010-08-22 12:59:02 +00001985 case Iop_QAdd32Sx2: case Iop_QAdd64Sx1:
sewardj38a3f862005-01-13 15:06:51 +00001986 case Iop_QAdd8Ux8: case Iop_QAdd16Ux4:
sewardj2fdd4162010-08-22 12:59:02 +00001987 case Iop_QAdd32Ux2: case Iop_QAdd64Ux1:
1988 case Iop_PwAdd8x8: case Iop_PwAdd16x4: case Iop_PwAdd32x2:
1989 case Iop_PwAdd32Fx2:
sewardj38a3f862005-01-13 15:06:51 +00001990 case Iop_QNarrow32Sx2:
1991 case Iop_QNarrow16Sx4: case Iop_QNarrow16Ux4:
1992 case Iop_Sub8x8: case Iop_Sub16x4: case Iop_Sub32x2:
1993 case Iop_QSub8Sx8: case Iop_QSub16Sx4:
sewardj2fdd4162010-08-22 12:59:02 +00001994 case Iop_QSub32Sx2: case Iop_QSub64Sx1:
sewardj38a3f862005-01-13 15:06:51 +00001995 case Iop_QSub8Ux8: case Iop_QSub16Ux4:
sewardj2fdd4162010-08-22 12:59:02 +00001996 case Iop_QSub32Ux2: case Iop_QSub64Ux1:
1997 case Iop_Shl8x8: case Iop_Shl16x4: case Iop_Shl32x2:
1998 case Iop_Shr8x8: case Iop_Shr16x4: case Iop_Shr32x2:
1999 case Iop_Sar8x8: case Iop_Sar16x4: case Iop_Sar32x2:
2000 case Iop_Sal8x8: case Iop_Sal16x4: case Iop_Sal32x2: case Iop_Sal64x1:
2001 case Iop_QShl8x8: case Iop_QShl16x4: case Iop_QShl32x2: case Iop_QShl64x1:
2002 case Iop_QSal8x8: case Iop_QSal16x4: case Iop_QSal32x2: case Iop_QSal64x1:
2003 case Iop_Recps32Fx2:
2004 case Iop_Rsqrts32Fx2:
sewardjb183b852006-02-03 16:08:03 +00002005 BINARY(Ity_I64,Ity_I64, Ity_I64);
sewardj38a3f862005-01-13 15:06:51 +00002006
sewardjd166e282008-02-06 11:42:45 +00002007 case Iop_ShlN32x2: case Iop_ShlN16x4: case Iop_ShlN8x8:
sewardj2fdd4162010-08-22 12:59:02 +00002008 case Iop_ShrN32x2: case Iop_ShrN16x4: case Iop_ShrN8x8:
sewardjd71ba832006-12-27 01:15:29 +00002009 case Iop_SarN32x2: case Iop_SarN16x4: case Iop_SarN8x8:
sewardj2fdd4162010-08-22 12:59:02 +00002010 case Iop_QShlN8x8: case Iop_QShlN16x4:
2011 case Iop_QShlN32x2: case Iop_QShlN64x1:
2012 case Iop_QShlN8Sx8: case Iop_QShlN16Sx4:
2013 case Iop_QShlN32Sx2: case Iop_QShlN64Sx1:
2014 case Iop_QSalN8x8: case Iop_QSalN16x4:
2015 case Iop_QSalN32x2: case Iop_QSalN64x1:
sewardjb183b852006-02-03 16:08:03 +00002016 BINARY(Ity_I64,Ity_I8, Ity_I64);
sewardj6efd4a12004-07-15 03:54:23 +00002017
2018 case Iop_Shl8: case Iop_Shr8: case Iop_Sar8:
sewardjb183b852006-02-03 16:08:03 +00002019 BINARY(Ity_I8,Ity_I8, Ity_I8);
sewardj6efd4a12004-07-15 03:54:23 +00002020 case Iop_Shl16: case Iop_Shr16: case Iop_Sar16:
sewardjb183b852006-02-03 16:08:03 +00002021 BINARY(Ity_I16,Ity_I8, Ity_I16);
sewardj6efd4a12004-07-15 03:54:23 +00002022 case Iop_Shl32: case Iop_Shr32: case Iop_Sar32:
sewardjb183b852006-02-03 16:08:03 +00002023 BINARY(Ity_I32,Ity_I8, Ity_I32);
sewardj6efd4a12004-07-15 03:54:23 +00002024 case Iop_Shl64: case Iop_Shr64: case Iop_Sar64:
sewardjb183b852006-02-03 16:08:03 +00002025 BINARY(Ity_I64,Ity_I8, Ity_I64);
sewardj6efd4a12004-07-15 03:54:23 +00002026
sewardjeb17e492007-08-25 23:07:44 +00002027 case Iop_Not8:
sewardjb183b852006-02-03 16:08:03 +00002028 UNARY(Ity_I8, Ity_I8);
sewardjeb17e492007-08-25 23:07:44 +00002029 case Iop_Not16:
sewardjb183b852006-02-03 16:08:03 +00002030 UNARY(Ity_I16, Ity_I16);
sewardjeb17e492007-08-25 23:07:44 +00002031 case Iop_Not32:
sewardje2ea1762010-09-22 00:56:37 +00002032 case Iop_CmpNEZ16x2: case Iop_CmpNEZ8x4:
sewardjb183b852006-02-03 16:08:03 +00002033 UNARY(Ity_I32, Ity_I32);
sewardj18069182005-01-13 19:16:04 +00002034
sewardj0033ddc2005-04-26 23:34:34 +00002035 case Iop_Not64:
sewardj18069182005-01-13 19:16:04 +00002036 case Iop_CmpNEZ32x2: case Iop_CmpNEZ16x4: case Iop_CmpNEZ8x8:
sewardj2fdd4162010-08-22 12:59:02 +00002037 case Iop_Cnt8x8:
2038 case Iop_Clz8Sx8: case Iop_Clz16Sx4: case Iop_Clz32Sx2:
2039 case Iop_Cls8Sx8: case Iop_Cls16Sx4: case Iop_Cls32Sx2:
2040 case Iop_PwAddL8Ux8: case Iop_PwAddL16Ux4: case Iop_PwAddL32Ux2:
2041 case Iop_PwAddL8Sx8: case Iop_PwAddL16Sx4: case Iop_PwAddL32Sx2:
2042 case Iop_Reverse64_8x8: case Iop_Reverse64_16x4: case Iop_Reverse64_32x2:
2043 case Iop_Reverse32_8x8: case Iop_Reverse32_16x4:
2044 case Iop_Reverse16_8x8:
2045 case Iop_FtoI32Sx2_RZ: case Iop_FtoI32Ux2_RZ:
2046 case Iop_I32StoFx2: case Iop_I32UtoFx2:
2047 case Iop_Recip32x2: case Iop_Recip32Fx2:
2048 case Iop_Abs32Fx2:
2049 case Iop_Rsqrte32Fx2:
2050 case Iop_Rsqrte32x2:
2051 case Iop_Neg32Fx2:
2052 case Iop_Abs8x8: case Iop_Abs16x4: case Iop_Abs32x2:
sewardjb183b852006-02-03 16:08:03 +00002053 UNARY(Ity_I64, Ity_I64);
sewardj6efd4a12004-07-15 03:54:23 +00002054
2055 case Iop_CmpEQ8: case Iop_CmpNE8:
sewardj1fb8c922009-07-12 12:56:53 +00002056 case Iop_CasCmpEQ8: case Iop_CasCmpNE8:
sewardj6efd4a12004-07-15 03:54:23 +00002057 COMPARISON(Ity_I8);
2058 case Iop_CmpEQ16: case Iop_CmpNE16:
sewardj1fb8c922009-07-12 12:56:53 +00002059 case Iop_CasCmpEQ16: case Iop_CasCmpNE16:
sewardj6efd4a12004-07-15 03:54:23 +00002060 COMPARISON(Ity_I16);
2061 case Iop_CmpEQ32: case Iop_CmpNE32:
sewardj1fb8c922009-07-12 12:56:53 +00002062 case Iop_CasCmpEQ32: case Iop_CasCmpNE32:
sewardj17442fe2004-09-20 14:54:28 +00002063 case Iop_CmpLT32S: case Iop_CmpLE32S:
2064 case Iop_CmpLT32U: case Iop_CmpLE32U:
sewardj6efd4a12004-07-15 03:54:23 +00002065 COMPARISON(Ity_I32);
2066 case Iop_CmpEQ64: case Iop_CmpNE64:
sewardj1fb8c922009-07-12 12:56:53 +00002067 case Iop_CasCmpEQ64: case Iop_CasCmpNE64:
sewardj98540072005-04-26 01:52:01 +00002068 case Iop_CmpLT64S: case Iop_CmpLE64S:
2069 case Iop_CmpLT64U: case Iop_CmpLE64U:
sewardj6efd4a12004-07-15 03:54:23 +00002070 COMPARISON(Ity_I64);
2071
sewardj0033ddc2005-04-26 23:34:34 +00002072 case Iop_CmpNEZ8: UNARY_COMPARISON(Ity_I8);
2073 case Iop_CmpNEZ16: UNARY_COMPARISON(Ity_I16);
2074 case Iop_CmpNEZ32: UNARY_COMPARISON(Ity_I32);
2075 case Iop_CmpNEZ64: UNARY_COMPARISON(Ity_I64);
2076
sewardjeb17e492007-08-25 23:07:44 +00002077 case Iop_Left8: UNARY(Ity_I8, Ity_I8);
2078 case Iop_Left16: UNARY(Ity_I16,Ity_I16);
2079 case Iop_CmpwNEZ32: case Iop_Left32: UNARY(Ity_I32,Ity_I32);
2080 case Iop_CmpwNEZ64: case Iop_Left64: UNARY(Ity_I64,Ity_I64);
2081
sewardjb81f8b32004-07-30 10:17:50 +00002082 case Iop_MullU8: case Iop_MullS8:
sewardjb183b852006-02-03 16:08:03 +00002083 BINARY(Ity_I8,Ity_I8, Ity_I16);
sewardjb81f8b32004-07-30 10:17:50 +00002084 case Iop_MullU16: case Iop_MullS16:
sewardjb183b852006-02-03 16:08:03 +00002085 BINARY(Ity_I16,Ity_I16, Ity_I32);
sewardj6d2638e2004-07-15 09:38:27 +00002086 case Iop_MullU32: case Iop_MullS32:
sewardjb183b852006-02-03 16:08:03 +00002087 BINARY(Ity_I32,Ity_I32, Ity_I64);
sewardj9b967672005-02-08 11:13:09 +00002088 case Iop_MullU64: case Iop_MullS64:
sewardjb183b852006-02-03 16:08:03 +00002089 BINARY(Ity_I64,Ity_I64, Ity_I128);
sewardj6d2638e2004-07-15 09:38:27 +00002090
sewardj17442fe2004-09-20 14:54:28 +00002091 case Iop_Clz32: case Iop_Ctz32:
sewardjb183b852006-02-03 16:08:03 +00002092 UNARY(Ity_I32, Ity_I32);
sewardjce646f22004-08-31 23:55:54 +00002093
sewardjf53b7352005-04-06 20:01:56 +00002094 case Iop_Clz64: case Iop_Ctz64:
sewardjb183b852006-02-03 16:08:03 +00002095 UNARY(Ity_I64, Ity_I64);
sewardjf53b7352005-04-06 20:01:56 +00002096
cerion5c8a0cb2005-02-03 13:59:46 +00002097 case Iop_DivU32: case Iop_DivS32:
sewardjb183b852006-02-03 16:08:03 +00002098 BINARY(Ity_I32,Ity_I32, Ity_I32);
cerion5c8a0cb2005-02-03 13:59:46 +00002099
cerionf0de28c2005-12-13 20:21:11 +00002100 case Iop_DivU64: case Iop_DivS64:
sewardjb183b852006-02-03 16:08:03 +00002101 BINARY(Ity_I64,Ity_I64, Ity_I64);
cerionf0de28c2005-12-13 20:21:11 +00002102
sewardj17442fe2004-09-20 14:54:28 +00002103 case Iop_DivModU64to32: case Iop_DivModS64to32:
sewardjb183b852006-02-03 16:08:03 +00002104 BINARY(Ity_I64,Ity_I32, Ity_I64);
sewardj6d2638e2004-07-15 09:38:27 +00002105
sewardj343b9d02005-01-31 18:08:45 +00002106 case Iop_DivModU128to64: case Iop_DivModS128to64:
sewardjb183b852006-02-03 16:08:03 +00002107 BINARY(Ity_I128,Ity_I64, Ity_I128);
sewardj343b9d02005-01-31 18:08:45 +00002108
sewardjb81f8b32004-07-30 10:17:50 +00002109 case Iop_16HIto8: case Iop_16to8:
sewardjb183b852006-02-03 16:08:03 +00002110 UNARY(Ity_I16, Ity_I8);
sewardjb81f8b32004-07-30 10:17:50 +00002111 case Iop_8HLto16:
sewardjb183b852006-02-03 16:08:03 +00002112 BINARY(Ity_I8,Ity_I8, Ity_I16);
sewardjb81f8b32004-07-30 10:17:50 +00002113
sewardj8c7f1ab2004-07-29 20:31:09 +00002114 case Iop_32HIto16: case Iop_32to16:
sewardjb183b852006-02-03 16:08:03 +00002115 UNARY(Ity_I32, Ity_I16);
sewardj8c7f1ab2004-07-29 20:31:09 +00002116 case Iop_16HLto32:
sewardjb183b852006-02-03 16:08:03 +00002117 BINARY(Ity_I16,Ity_I16, Ity_I32);
sewardj8c7f1ab2004-07-29 20:31:09 +00002118
2119 case Iop_64HIto32: case Iop_64to32:
sewardjb183b852006-02-03 16:08:03 +00002120 UNARY(Ity_I64, Ity_I32);
sewardj6d2638e2004-07-15 09:38:27 +00002121 case Iop_32HLto64:
sewardjb183b852006-02-03 16:08:03 +00002122 BINARY(Ity_I32,Ity_I32, Ity_I64);
sewardj6d2638e2004-07-15 09:38:27 +00002123
sewardj9b967672005-02-08 11:13:09 +00002124 case Iop_128HIto64: case Iop_128to64:
sewardjb183b852006-02-03 16:08:03 +00002125 UNARY(Ity_I128, Ity_I64);
sewardj9b967672005-02-08 11:13:09 +00002126 case Iop_64HLto128:
sewardjb183b852006-02-03 16:08:03 +00002127 BINARY(Ity_I64,Ity_I64, Ity_I128);
sewardj9b967672005-02-08 11:13:09 +00002128
sewardjb183b852006-02-03 16:08:03 +00002129 case Iop_Not1: UNARY(Ity_I1, Ity_I1);
2130 case Iop_1Uto8: UNARY(Ity_I1, Ity_I8);
2131 case Iop_1Sto8: UNARY(Ity_I1, Ity_I8);
2132 case Iop_1Sto16: UNARY(Ity_I1, Ity_I16);
2133 case Iop_1Uto32: case Iop_1Sto32: UNARY(Ity_I1, Ity_I32);
2134 case Iop_1Sto64: case Iop_1Uto64: UNARY(Ity_I1, Ity_I64);
2135 case Iop_32to1: UNARY(Ity_I32, Ity_I1);
2136 case Iop_64to1: UNARY(Ity_I64, Ity_I1);
sewardj47341042004-09-19 11:55:46 +00002137
sewardj17442fe2004-09-20 14:54:28 +00002138 case Iop_8Uto32: case Iop_8Sto32:
sewardjb183b852006-02-03 16:08:03 +00002139 UNARY(Ity_I8, Ity_I32);
sewardj47341042004-09-19 11:55:46 +00002140
sewardj17442fe2004-09-20 14:54:28 +00002141 case Iop_8Uto16: case Iop_8Sto16:
sewardjb183b852006-02-03 16:08:03 +00002142 UNARY(Ity_I8, Ity_I16);
sewardj47341042004-09-19 11:55:46 +00002143
sewardj17442fe2004-09-20 14:54:28 +00002144 case Iop_16Uto32: case Iop_16Sto32:
sewardjb183b852006-02-03 16:08:03 +00002145 UNARY(Ity_I16, Ity_I32);
sewardj6d2638e2004-07-15 09:38:27 +00002146
sewardj17442fe2004-09-20 14:54:28 +00002147 case Iop_32Sto64: case Iop_32Uto64:
sewardjb183b852006-02-03 16:08:03 +00002148 UNARY(Ity_I32, Ity_I64);
sewardj17442fe2004-09-20 14:54:28 +00002149
sewardj291a7e82005-04-27 11:42:44 +00002150 case Iop_8Uto64: case Iop_8Sto64:
sewardjb183b852006-02-03 16:08:03 +00002151 UNARY(Ity_I8, Ity_I64);
sewardj291a7e82005-04-27 11:42:44 +00002152
2153 case Iop_16Uto64: case Iop_16Sto64:
sewardj291a7e82005-04-27 11:42:44 +00002154 UNARY(Ity_I16, Ity_I64);
sewardjb183b852006-02-03 16:08:03 +00002155 case Iop_64to16:
2156 UNARY(Ity_I64, Ity_I16);
sewardj291a7e82005-04-27 11:42:44 +00002157
sewardjb183b852006-02-03 16:08:03 +00002158 case Iop_32to8: UNARY(Ity_I32, Ity_I8);
2159 case Iop_64to8: UNARY(Ity_I64, Ity_I8);
sewardj17442fe2004-09-20 14:54:28 +00002160
sewardjb183b852006-02-03 16:08:03 +00002161 case Iop_AddF64: case Iop_SubF64:
2162 case Iop_MulF64: case Iop_DivF64:
2163 case Iop_AddF64r32: case Iop_SubF64r32:
2164 case Iop_MulF64r32: case Iop_DivF64r32:
2165 TERNARY(ity_RMode,Ity_F64,Ity_F64, Ity_F64);
2166
sewardj6c299f32009-12-31 18:00:12 +00002167 case Iop_AddF32: case Iop_SubF32:
2168 case Iop_MulF32: case Iop_DivF32:
2169 TERNARY(ity_RMode,Ity_F32,Ity_F32, Ity_F32);
2170
sewardjb183b852006-02-03 16:08:03 +00002171 case Iop_NegF64: case Iop_AbsF64:
2172 UNARY(Ity_F64, Ity_F64);
2173
sewardj6c299f32009-12-31 18:00:12 +00002174 case Iop_NegF32: case Iop_AbsF32:
2175 UNARY(Ity_F32, Ity_F32);
2176
sewardjb183b852006-02-03 16:08:03 +00002177 case Iop_SqrtF64:
2178 case Iop_SqrtF64r32:
2179 BINARY(ity_RMode,Ity_F64, Ity_F64);
2180
sewardj6c299f32009-12-31 18:00:12 +00002181 case Iop_SqrtF32:
sewardjd15b5972010-06-27 09:06:34 +00002182 case Iop_RoundF32toInt:
sewardj6c299f32009-12-31 18:00:12 +00002183 BINARY(ity_RMode,Ity_F32, Ity_F32);
2184
sewardjbdc7d212004-09-09 02:46:40 +00002185 case Iop_CmpF64:
sewardjb183b852006-02-03 16:08:03 +00002186 BINARY(Ity_F64,Ity_F64, Ity_I32);
sewardj8f3debf2004-09-08 23:42:23 +00002187
sewardj6c299f32009-12-31 18:00:12 +00002188 case Iop_F64toI16S: BINARY(ity_RMode,Ity_F64, Ity_I16);
2189 case Iop_F64toI32S: BINARY(ity_RMode,Ity_F64, Ity_I32);
2190 case Iop_F64toI64S: BINARY(ity_RMode,Ity_F64, Ity_I64);
sewardj8f3debf2004-09-08 23:42:23 +00002191
sewardj6c299f32009-12-31 18:00:12 +00002192 case Iop_F64toI32U: BINARY(ity_RMode,Ity_F64, Ity_I32);
2193
2194 case Iop_I16StoF64: UNARY(Ity_I16, Ity_F64);
2195 case Iop_I32StoF64: UNARY(Ity_I32, Ity_F64);
2196 case Iop_I64StoF64: BINARY(ity_RMode,Ity_I64, Ity_F64);
2197
2198 case Iop_I32UtoF64: UNARY(Ity_I32, Ity_F64);
sewardj3bca9062004-12-04 14:36:09 +00002199
sewardjb183b852006-02-03 16:08:03 +00002200 case Iop_F32toF64: UNARY(Ity_F32, Ity_F64);
2201 case Iop_F64toF32: BINARY(ity_RMode,Ity_F64, Ity_F32);
sewardj4cb918d2004-12-03 19:43:31 +00002202
sewardjb183b852006-02-03 16:08:03 +00002203 case Iop_ReinterpI64asF64: UNARY(Ity_I64, Ity_F64);
2204 case Iop_ReinterpF64asI64: UNARY(Ity_F64, Ity_I64);
2205 case Iop_ReinterpI32asF32: UNARY(Ity_I32, Ity_F32);
sewardjfc1b5412007-01-09 15:20:07 +00002206 case Iop_ReinterpF32asI32: UNARY(Ity_F32, Ity_I32);
sewardj8f3debf2004-09-08 23:42:23 +00002207
sewardjb183b852006-02-03 16:08:03 +00002208 case Iop_AtanF64: case Iop_Yl2xF64: case Iop_Yl2xp1F64:
2209 case Iop_ScaleF64: case Iop_PRemF64: case Iop_PRem1F64:
2210 TERNARY(ity_RMode,Ity_F64,Ity_F64, Ity_F64);
2211
2212 case Iop_PRemC3210F64: case Iop_PRem1C3210F64:
2213 TERNARY(ity_RMode,Ity_F64,Ity_F64, Ity_I32);
2214
2215 case Iop_SinF64: case Iop_CosF64: case Iop_TanF64:
2216 case Iop_2xm1F64:
2217 case Iop_RoundF64toInt: BINARY(ity_RMode,Ity_F64, Ity_F64);
2218
sewardj40c80262006-02-08 19:30:46 +00002219 case Iop_MAddF64: case Iop_MSubF64:
2220 case Iop_MAddF64r32: case Iop_MSubF64r32:
2221 QUATERNARY(ity_RMode,Ity_F64,Ity_F64,Ity_F64, Ity_F64);
2222
sewardjb183b852006-02-03 16:08:03 +00002223 case Iop_Est5FRSqrt:
sewardj0f1ef862008-08-08 08:37:06 +00002224 case Iop_RoundF64toF64_NEAREST: case Iop_RoundF64toF64_NegINF:
2225 case Iop_RoundF64toF64_PosINF: case Iop_RoundF64toF64_ZERO:
sewardjb183b852006-02-03 16:08:03 +00002226 UNARY(Ity_F64, Ity_F64);
2227 case Iop_RoundF64toF32:
2228 BINARY(ity_RMode,Ity_F64, Ity_F64);
2229 case Iop_CalcFPRF:
2230 UNARY(Ity_F64, Ity_I32);
2231 case Iop_TruncF64asF32:
2232 UNARY(Ity_F64, Ity_F32);
sewardjbb53f8c2004-08-14 11:50:01 +00002233
cerionf294eb32005-11-16 17:21:10 +00002234 case Iop_I32UtoFx4:
2235 case Iop_I32StoFx4:
2236 case Iop_QFtoI32Ux4_RZ:
2237 case Iop_QFtoI32Sx4_RZ:
sewardj2fdd4162010-08-22 12:59:02 +00002238 case Iop_FtoI32Ux4_RZ:
2239 case Iop_FtoI32Sx4_RZ:
cerionf294eb32005-11-16 17:21:10 +00002240 case Iop_RoundF32x4_RM:
2241 case Iop_RoundF32x4_RP:
2242 case Iop_RoundF32x4_RN:
2243 case Iop_RoundF32x4_RZ:
sewardj2fdd4162010-08-22 12:59:02 +00002244 case Iop_Abs32Fx4:
2245 case Iop_Rsqrte32Fx4:
2246 case Iop_Rsqrte32x4:
cerionf294eb32005-11-16 17:21:10 +00002247 UNARY(Ity_V128, Ity_V128);
2248
sewardjb183b852006-02-03 16:08:03 +00002249 case Iop_64HLtoV128: BINARY(Ity_I64,Ity_I64, Ity_V128);
sewardj2fdd4162010-08-22 12:59:02 +00002250 case Iop_V128to64: case Iop_V128HIto64:
2251 case Iop_Shorten16x8: case Iop_Shorten32x4: case Iop_Shorten64x2:
2252 case Iop_QShortenU16Ux8: case Iop_QShortenU32Ux4: case Iop_QShortenU64Ux2:
2253 case Iop_QShortenS16Sx8: case Iop_QShortenS32Sx4: case Iop_QShortenS64Sx2:
2254 case Iop_QShortenU16Sx8: case Iop_QShortenU32Sx4: case Iop_QShortenU64Sx2:
2255 case Iop_F32toF16x4:
sewardjb183b852006-02-03 16:08:03 +00002256 UNARY(Ity_V128, Ity_I64);
sewardjc9a43662004-11-30 18:51:59 +00002257
sewardj2fdd4162010-08-22 12:59:02 +00002258 case Iop_Longen8Ux8: case Iop_Longen16Ux4: case Iop_Longen32Ux2:
2259 case Iop_Longen8Sx8: case Iop_Longen16Sx4: case Iop_Longen32Sx2:
2260 case Iop_F16toF32x4:
2261 UNARY(Ity_I64, Ity_V128);
2262
sewardjb183b852006-02-03 16:08:03 +00002263 case Iop_V128to32: UNARY(Ity_V128, Ity_I32);
2264 case Iop_32UtoV128: UNARY(Ity_I32, Ity_V128);
2265 case Iop_64UtoV128: UNARY(Ity_I64, Ity_V128);
2266 case Iop_SetV128lo32: BINARY(Ity_V128,Ity_I32, Ity_V128);
2267 case Iop_SetV128lo64: BINARY(Ity_V128,Ity_I64, Ity_V128);
sewardj129b3d92004-12-05 15:42:05 +00002268
sewardjb183b852006-02-03 16:08:03 +00002269 case Iop_Dup8x16: UNARY(Ity_I8, Ity_V128);
2270 case Iop_Dup16x8: UNARY(Ity_I16, Ity_V128);
2271 case Iop_Dup32x4: UNARY(Ity_I32, Ity_V128);
sewardj2fdd4162010-08-22 12:59:02 +00002272 case Iop_Dup8x8: UNARY(Ity_I8, Ity_I64);
2273 case Iop_Dup16x4: UNARY(Ity_I16, Ity_I64);
2274 case Iop_Dup32x2: UNARY(Ity_I32, Ity_I64);
cerionf887b3e2005-09-13 16:34:28 +00002275
sewardj1e6ad742004-12-02 16:16:11 +00002276 case Iop_CmpEQ32Fx4: case Iop_CmpLT32Fx4:
sewardj636ad762004-12-07 11:16:04 +00002277 case Iop_CmpEQ64Fx2: case Iop_CmpLT64Fx2:
sewardj1e6ad742004-12-02 16:16:11 +00002278 case Iop_CmpLE32Fx4: case Iop_CmpUN32Fx4:
sewardj636ad762004-12-07 11:16:04 +00002279 case Iop_CmpLE64Fx2: case Iop_CmpUN64Fx2:
cerion206c3642005-11-14 00:35:59 +00002280 case Iop_CmpGT32Fx4: case Iop_CmpGE32Fx4:
sewardj1e6ad742004-12-02 16:16:11 +00002281 case Iop_CmpEQ32F0x4: case Iop_CmpLT32F0x4:
sewardj636ad762004-12-07 11:16:04 +00002282 case Iop_CmpEQ64F0x2: case Iop_CmpLT64F0x2:
sewardj1e6ad742004-12-02 16:16:11 +00002283 case Iop_CmpLE32F0x4: case Iop_CmpUN32F0x4:
sewardj636ad762004-12-07 11:16:04 +00002284 case Iop_CmpLE64F0x2: case Iop_CmpUN64F0x2:
sewardj1e6ad742004-12-02 16:16:11 +00002285 case Iop_Add32Fx4: case Iop_Add32F0x4:
sewardj636ad762004-12-07 11:16:04 +00002286 case Iop_Add64Fx2: case Iop_Add64F0x2:
sewardj176a59c2004-12-03 20:08:31 +00002287 case Iop_Div32Fx4: case Iop_Div32F0x4:
sewardj636ad762004-12-07 11:16:04 +00002288 case Iop_Div64Fx2: case Iop_Div64F0x2:
sewardj176a59c2004-12-03 20:08:31 +00002289 case Iop_Max32Fx4: case Iop_Max32F0x4:
sewardj2fdd4162010-08-22 12:59:02 +00002290 case Iop_PwMax32Fx4: case Iop_PwMin32Fx4:
sewardj636ad762004-12-07 11:16:04 +00002291 case Iop_Max64Fx2: case Iop_Max64F0x2:
sewardj176a59c2004-12-03 20:08:31 +00002292 case Iop_Min32Fx4: case Iop_Min32F0x4:
sewardj636ad762004-12-07 11:16:04 +00002293 case Iop_Min64Fx2: case Iop_Min64F0x2:
sewardj9636b442004-12-04 01:38:37 +00002294 case Iop_Mul32Fx4: case Iop_Mul32F0x4:
sewardj636ad762004-12-07 11:16:04 +00002295 case Iop_Mul64Fx2: case Iop_Mul64F0x2:
sewardjc1e7dfc2004-12-05 19:29:45 +00002296 case Iop_Sub32Fx4: case Iop_Sub32F0x4:
sewardj636ad762004-12-07 11:16:04 +00002297 case Iop_Sub64Fx2: case Iop_Sub64F0x2:
sewardjf0c1c582005-02-07 23:47:38 +00002298 case Iop_AndV128: case Iop_OrV128: case Iop_XorV128:
sewardj164f9272004-12-09 00:39:32 +00002299 case Iop_Add8x16: case Iop_Add16x8:
2300 case Iop_Add32x4: case Iop_Add64x2:
sewardj2fdd4162010-08-22 12:59:02 +00002301 case Iop_QAdd8Ux16: case Iop_QAdd16Ux8:
2302 case Iop_QAdd32Ux4: //case Iop_QAdd64Ux2:
2303 case Iop_QAdd8Sx16: case Iop_QAdd16Sx8:
2304 case Iop_QAdd32Sx4: case Iop_QAdd64Sx2:
2305 case Iop_PwAdd8x16: case Iop_PwAdd16x8: case Iop_PwAdd32x4:
sewardj164f9272004-12-09 00:39:32 +00002306 case Iop_Sub8x16: case Iop_Sub16x8:
2307 case Iop_Sub32x4: case Iop_Sub64x2:
sewardj2fdd4162010-08-22 12:59:02 +00002308 case Iop_QSub8Ux16: case Iop_QSub16Ux8:
2309 case Iop_QSub32Ux4: //case Iop_QSub64Ux2:
2310 case Iop_QSub8Sx16: case Iop_QSub16Sx8:
2311 case Iop_QSub32Sx4: case Iop_QSub64Sx2:
2312 case Iop_Mul8x16: case Iop_Mul16x8: case Iop_Mul32x4:
2313 case Iop_PolynomialMul8x16:
cerionf887b3e2005-09-13 16:34:28 +00002314 case Iop_MulHi16Ux8: case Iop_MulHi32Ux4:
2315 case Iop_MulHi16Sx8: case Iop_MulHi32Sx4:
sewardj2fdd4162010-08-22 12:59:02 +00002316 case Iop_QDMulHi16Sx8: case Iop_QDMulHi32Sx4:
2317 case Iop_QRDMulHi16Sx8: case Iop_QRDMulHi32Sx4:
cerion1ac656a2005-11-04 19:44:48 +00002318 case Iop_MullEven8Ux16: case Iop_MullEven16Ux8:
2319 case Iop_MullEven8Sx16: case Iop_MullEven16Sx8:
cerionf887b3e2005-09-13 16:34:28 +00002320 case Iop_Avg8Ux16: case Iop_Avg16Ux8: case Iop_Avg32Ux4:
2321 case Iop_Avg8Sx16: case Iop_Avg16Sx8: case Iop_Avg32Sx4:
2322 case Iop_Max8Sx16: case Iop_Max16Sx8: case Iop_Max32Sx4:
2323 case Iop_Max8Ux16: case Iop_Max16Ux8: case Iop_Max32Ux4:
2324 case Iop_Min8Sx16: case Iop_Min16Sx8: case Iop_Min32Sx4:
2325 case Iop_Min8Ux16: case Iop_Min16Ux8: case Iop_Min32Ux4:
sewardj164f9272004-12-09 00:39:32 +00002326 case Iop_CmpEQ8x16: case Iop_CmpEQ16x8: case Iop_CmpEQ32x4:
2327 case Iop_CmpGT8Sx16: case Iop_CmpGT16Sx8: case Iop_CmpGT32Sx4:
sewardj69d98e32010-06-18 08:17:41 +00002328 case Iop_CmpGT64Sx2:
cerionf887b3e2005-09-13 16:34:28 +00002329 case Iop_CmpGT8Ux16: case Iop_CmpGT16Ux8: case Iop_CmpGT32Ux4:
sewardj2fdd4162010-08-22 12:59:02 +00002330 case Iop_Shl8x16: case Iop_Shl16x8: case Iop_Shl32x4: case Iop_Shl64x2:
2331 case Iop_QShl8x16: case Iop_QShl16x8: case Iop_QShl32x4: case Iop_QShl64x2:
2332 case Iop_QSal8x16: case Iop_QSal16x8: case Iop_QSal32x4: case Iop_QSal64x2:
2333 case Iop_Shr8x16: case Iop_Shr16x8: case Iop_Shr32x4: case Iop_Shr64x2:
2334 case Iop_Sar8x16: case Iop_Sar16x8: case Iop_Sar32x4: case Iop_Sar64x2:
2335 case Iop_Sal8x16: case Iop_Sal16x8: case Iop_Sal32x4: case Iop_Sal64x2:
sewardj1bee5612005-11-10 18:10:58 +00002336 case Iop_Rol8x16: case Iop_Rol16x8: case Iop_Rol32x4:
cerion9e7677b2005-09-13 17:25:41 +00002337 case Iop_QNarrow16Ux8: case Iop_QNarrow32Ux4:
sewardj164f9272004-12-09 00:39:32 +00002338 case Iop_QNarrow16Sx8: case Iop_QNarrow32Sx4:
sewardj1bee5612005-11-10 18:10:58 +00002339 case Iop_Narrow16x8: case Iop_Narrow32x4:
sewardj164f9272004-12-09 00:39:32 +00002340 case Iop_InterleaveHI8x16: case Iop_InterleaveHI16x8:
2341 case Iop_InterleaveHI32x4: case Iop_InterleaveHI64x2:
sewardj2fdd4162010-08-22 12:59:02 +00002342 case Iop_InterleaveLO8x16: case Iop_InterleaveLO16x8:
sewardj164f9272004-12-09 00:39:32 +00002343 case Iop_InterleaveLO32x4: case Iop_InterleaveLO64x2:
sewardj2fdd4162010-08-22 12:59:02 +00002344 case Iop_CatOddLanes8x16: case Iop_CatEvenLanes8x16:
2345 case Iop_CatOddLanes16x8: case Iop_CatEvenLanes16x8:
2346 case Iop_CatOddLanes32x4: case Iop_CatEvenLanes32x4:
2347 case Iop_InterleaveOddLanes8x16: case Iop_InterleaveEvenLanes8x16:
2348 case Iop_InterleaveOddLanes16x8: case Iop_InterleaveEvenLanes16x8:
2349 case Iop_InterleaveOddLanes32x4: case Iop_InterleaveEvenLanes32x4:
sewardjdc1f9132005-10-22 12:49:49 +00002350 case Iop_Perm8x16:
sewardj2fdd4162010-08-22 12:59:02 +00002351 case Iop_Recps32Fx4:
2352 case Iop_Rsqrts32Fx4:
sewardjb183b852006-02-03 16:08:03 +00002353 BINARY(Ity_V128,Ity_V128, Ity_V128);
sewardjc9a43662004-11-30 18:51:59 +00002354
sewardj2fdd4162010-08-22 12:59:02 +00002355 case Iop_PolynomialMull8x8:
2356 case Iop_Mull8Ux8: case Iop_Mull8Sx8:
2357 case Iop_Mull16Ux4: case Iop_Mull16Sx4:
2358 case Iop_Mull32Ux2: case Iop_Mull32Sx2:
2359 BINARY(Ity_I64, Ity_I64, Ity_V128);
2360
sewardjf0c1c582005-02-07 23:47:38 +00002361 case Iop_NotV128:
sewardj0bd7ce62004-12-05 02:47:40 +00002362 case Iop_Recip32Fx4: case Iop_Recip32F0x4:
sewardj2fdd4162010-08-22 12:59:02 +00002363 case Iop_Recip32x4:
sewardj636ad762004-12-07 11:16:04 +00002364 case Iop_Recip64Fx2: case Iop_Recip64F0x2:
sewardjc1e7dfc2004-12-05 19:29:45 +00002365 case Iop_RSqrt32Fx4: case Iop_RSqrt32F0x4:
sewardj636ad762004-12-07 11:16:04 +00002366 case Iop_RSqrt64Fx2: case Iop_RSqrt64F0x2:
sewardjc1e7dfc2004-12-05 19:29:45 +00002367 case Iop_Sqrt32Fx4: case Iop_Sqrt32F0x4:
sewardj636ad762004-12-07 11:16:04 +00002368 case Iop_Sqrt64Fx2: case Iop_Sqrt64F0x2:
sewardj2e383862004-12-12 16:46:47 +00002369 case Iop_CmpNEZ8x16: case Iop_CmpNEZ16x8:
sewardj109ffdb2004-12-10 21:45:38 +00002370 case Iop_CmpNEZ32x4: case Iop_CmpNEZ64x2:
sewardj2fdd4162010-08-22 12:59:02 +00002371 case Iop_Cnt8x16:
2372 case Iop_Clz8Sx16: case Iop_Clz16Sx8: case Iop_Clz32Sx4:
2373 case Iop_Cls8Sx16: case Iop_Cls16Sx8: case Iop_Cls32Sx4:
2374 case Iop_PwAddL8Ux16: case Iop_PwAddL16Ux8: case Iop_PwAddL32Ux4:
2375 case Iop_PwAddL8Sx16: case Iop_PwAddL16Sx8: case Iop_PwAddL32Sx4:
2376 case Iop_Reverse64_8x16: case Iop_Reverse64_16x8: case Iop_Reverse64_32x4:
2377 case Iop_Reverse32_8x16: case Iop_Reverse32_16x8:
2378 case Iop_Reverse16_8x16:
2379 case Iop_Neg32Fx4:
2380 case Iop_Abs8x16: case Iop_Abs16x8: case Iop_Abs32x4:
sewardj0bd7ce62004-12-05 02:47:40 +00002381 UNARY(Ity_V128, Ity_V128);
2382
cerionf887b3e2005-09-13 16:34:28 +00002383 case Iop_ShlV128: case Iop_ShrV128:
sewardjb183b852006-02-03 16:08:03 +00002384 case Iop_ShlN8x16: case Iop_ShlN16x8:
2385 case Iop_ShlN32x4: case Iop_ShlN64x2:
2386 case Iop_ShrN8x16: case Iop_ShrN16x8:
2387 case Iop_ShrN32x4: case Iop_ShrN64x2:
sewardj2fdd4162010-08-22 12:59:02 +00002388 case Iop_SarN8x16: case Iop_SarN16x8:
2389 case Iop_SarN32x4: case Iop_SarN64x2:
2390 case Iop_QShlN8x16: case Iop_QShlN16x8:
2391 case Iop_QShlN32x4: case Iop_QShlN64x2:
2392 case Iop_QShlN8Sx16: case Iop_QShlN16Sx8:
2393 case Iop_QShlN32Sx4: case Iop_QShlN64Sx2:
2394 case Iop_QSalN8x16: case Iop_QSalN16x8:
2395 case Iop_QSalN32x4: case Iop_QSalN64x2:
sewardjb183b852006-02-03 16:08:03 +00002396 BINARY(Ity_V128,Ity_I8, Ity_V128);
sewardj164f9272004-12-09 00:39:32 +00002397
sewardj2fdd4162010-08-22 12:59:02 +00002398 case Iop_F32ToFixed32Ux4_RZ:
2399 case Iop_F32ToFixed32Sx4_RZ:
2400 case Iop_Fixed32UToF32x4_RN:
2401 case Iop_Fixed32SToF32x4_RN:
2402 BINARY(Ity_V128, Ity_I8, Ity_V128);
2403
2404 case Iop_F32ToFixed32Ux2_RZ:
2405 case Iop_F32ToFixed32Sx2_RZ:
2406 case Iop_Fixed32UToF32x2_RN:
2407 case Iop_Fixed32SToF32x2_RN:
2408 BINARY(Ity_I64, Ity_I8, Ity_I64);
2409
2410 case Iop_GetElem8x16:
2411 BINARY(Ity_V128, Ity_I8, Ity_I8);
2412 case Iop_GetElem16x8:
2413 BINARY(Ity_V128, Ity_I8, Ity_I16);
2414 case Iop_GetElem32x4:
2415 BINARY(Ity_V128, Ity_I8, Ity_I32);
2416 case Iop_GetElem64x2:
2417 BINARY(Ity_V128, Ity_I8, Ity_I64);
2418 case Iop_GetElem8x8:
2419 BINARY(Ity_I64, Ity_I8, Ity_I8);
2420 case Iop_GetElem16x4:
2421 BINARY(Ity_I64, Ity_I8, Ity_I16);
2422 case Iop_GetElem32x2:
2423 BINARY(Ity_I64, Ity_I8, Ity_I32);
2424 case Iop_SetElem8x8:
2425 TERNARY(Ity_I64, Ity_I8, Ity_I8, Ity_I64);
2426 case Iop_SetElem16x4:
2427 TERNARY(Ity_I64, Ity_I8, Ity_I16, Ity_I64);
2428 case Iop_SetElem32x2:
2429 TERNARY(Ity_I64, Ity_I8, Ity_I32, Ity_I64);
2430
2431 case Iop_Extract64:
2432 TERNARY(Ity_I64, Ity_I64, Ity_I8, Ity_I64);
2433 case Iop_ExtractV128:
2434 TERNARY(Ity_V128, Ity_V128, Ity_I8, Ity_V128);
2435
2436 case Iop_QDMulLong16Sx4: case Iop_QDMulLong32Sx2:
2437 BINARY(Ity_I64, Ity_I64, Ity_V128);
2438
sewardj6efd4a12004-07-15 03:54:23 +00002439 default:
2440 ppIROp(op);
2441 vpanic("typeOfPrimop");
2442 }
2443# undef UNARY
2444# undef BINARY
sewardjb183b852006-02-03 16:08:03 +00002445# undef TERNARY
sewardj6efd4a12004-07-15 03:54:23 +00002446# undef COMPARISON
sewardj0033ddc2005-04-26 23:34:34 +00002447# undef UNARY_COMPARISON
sewardj6efd4a12004-07-15 03:54:23 +00002448}
2449
2450
2451/*---------------------------------------------------------------*/
sewardj695cff92004-10-13 14:50:14 +00002452/*--- Helper functions for the IR -- IR Basic Blocks ---*/
sewardjc97096c2004-06-30 09:28:04 +00002453/*---------------------------------------------------------------*/
2454
sewardjdd40fdf2006-12-24 02:20:24 +00002455void addStmtToIRSB ( IRSB* bb, IRStmt* st )
sewardjd7cb8532004-08-17 23:59:23 +00002456{
2457 Int i;
sewardj695cff92004-10-13 14:50:14 +00002458 if (bb->stmts_used == bb->stmts_size) {
2459 IRStmt** stmts2 = LibVEX_Alloc(2 * bb->stmts_size * sizeof(IRStmt*));
2460 for (i = 0; i < bb->stmts_size; i++)
2461 stmts2[i] = bb->stmts[i];
2462 bb->stmts = stmts2;
2463 bb->stmts_size *= 2;
2464 }
2465 vassert(bb->stmts_used < bb->stmts_size);
2466 bb->stmts[bb->stmts_used] = st;
2467 bb->stmts_used++;
sewardjd7cb8532004-08-17 23:59:23 +00002468}
2469
sewardj695cff92004-10-13 14:50:14 +00002470
2471/*---------------------------------------------------------------*/
2472/*--- Helper functions for the IR -- IR Type Environments ---*/
2473/*---------------------------------------------------------------*/
2474
sewardjd7cb8532004-08-17 23:59:23 +00002475/* Allocate a new IRTemp, given its type. */
sewardje3d0d2e2004-06-27 10:42:44 +00002476
sewardje539a402004-07-14 18:24:17 +00002477IRTemp newIRTemp ( IRTypeEnv* env, IRType ty )
sewardjc97096c2004-06-30 09:28:04 +00002478{
sewardj35421a32004-07-05 13:12:34 +00002479 vassert(env);
sewardje539a402004-07-14 18:24:17 +00002480 vassert(env->types_used >= 0);
2481 vassert(env->types_size >= 0);
2482 vassert(env->types_used <= env->types_size);
2483 if (env->types_used < env->types_size) {
2484 env->types[env->types_used] = ty;
2485 return env->types_used++;
sewardjc97096c2004-06-30 09:28:04 +00002486 } else {
2487 Int i;
sewardje539a402004-07-14 18:24:17 +00002488 Int new_size = env->types_size==0 ? 8 : 2*env->types_size;
2489 IRType* new_types
2490 = LibVEX_Alloc(new_size * sizeof(IRType));
2491 for (i = 0; i < env->types_used; i++)
2492 new_types[i] = env->types[i];
2493 env->types = new_types;
2494 env->types_size = new_size;
2495 return newIRTemp(env, ty);
sewardjc97096c2004-06-30 09:28:04 +00002496 }
2497}
2498
2499
sewardj17442fe2004-09-20 14:54:28 +00002500/*---------------------------------------------------------------*/
2501/*--- Helper functions for the IR -- finding types of exprs ---*/
2502/*---------------------------------------------------------------*/
2503
sewardjedeb4c42004-09-21 23:39:25 +00002504inline
sewardj17442fe2004-09-20 14:54:28 +00002505IRType typeOfIRTemp ( IRTypeEnv* env, IRTemp tmp )
sewardjc97096c2004-06-30 09:28:04 +00002506{
sewardje539a402004-07-14 18:24:17 +00002507 vassert(tmp >= 0);
2508 vassert(tmp < env->types_used);
2509 return env->types[tmp];
sewardjc97096c2004-06-30 09:28:04 +00002510}
2511
2512
sewardj6efd4a12004-07-15 03:54:23 +00002513IRType typeOfIRConst ( IRConst* con )
2514{
2515 switch (con->tag) {
sewardjba999312004-11-15 15:21:17 +00002516 case Ico_U1: return Ity_I1;
sewardj207557a2004-08-27 12:00:18 +00002517 case Ico_U8: return Ity_I8;
2518 case Ico_U16: return Ity_I16;
2519 case Ico_U32: return Ity_I32;
2520 case Ico_U64: return Ity_I64;
2521 case Ico_F64: return Ity_F64;
sewardj17442fe2004-09-20 14:54:28 +00002522 case Ico_F64i: return Ity_F64;
sewardj1e6ad742004-12-02 16:16:11 +00002523 case Ico_V128: return Ity_V128;
sewardj6efd4a12004-07-15 03:54:23 +00002524 default: vpanic("typeOfIRConst");
2525 }
2526}
2527
sewardjc97096c2004-06-30 09:28:04 +00002528IRType typeOfIRExpr ( IRTypeEnv* tyenv, IRExpr* e )
2529{
sewardj40c80262006-02-08 19:30:46 +00002530 IRType t_dst, t_arg1, t_arg2, t_arg3, t_arg4;
sewardjedeb4c42004-09-21 23:39:25 +00002531 start:
sewardjc97096c2004-06-30 09:28:04 +00002532 switch (e->tag) {
sewardjaf1ceca2005-06-30 23:31:27 +00002533 case Iex_Load:
2534 return e->Iex.Load.ty;
sewardjfbcaf332004-07-08 01:46:01 +00002535 case Iex_Get:
2536 return e->Iex.Get.ty;
sewardjbb53f8c2004-08-14 11:50:01 +00002537 case Iex_GetI:
sewardj2d3f77c2004-09-22 23:49:09 +00002538 return e->Iex.GetI.descr->elemTy;
sewardjdd40fdf2006-12-24 02:20:24 +00002539 case Iex_RdTmp:
2540 return typeOfIRTemp(tyenv, e->Iex.RdTmp.tmp);
sewardjc97096c2004-06-30 09:28:04 +00002541 case Iex_Const:
sewardj695cff92004-10-13 14:50:14 +00002542 return typeOfIRConst(e->Iex.Const.con);
sewardj40c80262006-02-08 19:30:46 +00002543 case Iex_Qop:
2544 typeOfPrimop(e->Iex.Qop.op,
2545 &t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4);
2546 return t_dst;
sewardjb183b852006-02-03 16:08:03 +00002547 case Iex_Triop:
sewardj40c80262006-02-08 19:30:46 +00002548 typeOfPrimop(e->Iex.Triop.op,
2549 &t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4);
sewardjb183b852006-02-03 16:08:03 +00002550 return t_dst;
sewardjc97096c2004-06-30 09:28:04 +00002551 case Iex_Binop:
sewardj40c80262006-02-08 19:30:46 +00002552 typeOfPrimop(e->Iex.Binop.op,
2553 &t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4);
sewardj6efd4a12004-07-15 03:54:23 +00002554 return t_dst;
2555 case Iex_Unop:
sewardj40c80262006-02-08 19:30:46 +00002556 typeOfPrimop(e->Iex.Unop.op,
2557 &t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4);
sewardj6efd4a12004-07-15 03:54:23 +00002558 return t_dst;
2559 case Iex_CCall:
2560 return e->Iex.CCall.retty;
sewardj4042c7e2004-07-18 01:28:30 +00002561 case Iex_Mux0X:
sewardjedeb4c42004-09-21 23:39:25 +00002562 e = e->Iex.Mux0X.expr0;
2563 goto start;
2564 /* return typeOfIRExpr(tyenv, e->Iex.Mux0X.expr0); */
sewardj443cd9d2004-07-18 23:06:45 +00002565 case Iex_Binder:
2566 vpanic("typeOfIRExpr: Binder is not a valid expression");
sewardjc97096c2004-06-30 09:28:04 +00002567 default:
sewardj6efd4a12004-07-15 03:54:23 +00002568 ppIRExpr(e);
2569 vpanic("typeOfIRExpr");
sewardjc97096c2004-06-30 09:28:04 +00002570 }
sewardjc97096c2004-06-30 09:28:04 +00002571}
sewardj887a11a2004-07-05 17:26:47 +00002572
sewardj6d2638e2004-07-15 09:38:27 +00002573/* Is this any value actually in the enumeration 'IRType' ? */
sewardj496a58d2005-03-20 18:44:44 +00002574Bool isPlausibleIRType ( IRType ty )
sewardj6d2638e2004-07-15 09:38:27 +00002575{
2576 switch (ty) {
sewardjba999312004-11-15 15:21:17 +00002577 case Ity_INVALID: case Ity_I1:
sewardj9b967672005-02-08 11:13:09 +00002578 case Ity_I8: case Ity_I16: case Ity_I32:
2579 case Ity_I64: case Ity_I128:
sewardjbb53f8c2004-08-14 11:50:01 +00002580 case Ity_F32: case Ity_F64:
sewardjc9a43662004-11-30 18:51:59 +00002581 case Ity_V128:
sewardj6d2638e2004-07-15 09:38:27 +00002582 return True;
2583 default:
2584 return False;
2585 }
2586}
2587
sewardj6efd4a12004-07-15 03:54:23 +00002588
sewardj887a11a2004-07-05 17:26:47 +00002589/*---------------------------------------------------------------*/
sewardjcf787902004-11-03 09:08:33 +00002590/*--- Sanity checking -- FLATNESS ---*/
2591/*---------------------------------------------------------------*/
2592
2593/* Check that the canonical flatness constraints hold on an
2594 IRStmt. The only place where any expression is allowed to be
2595 non-atomic is the RHS of IRStmt_Tmp. */
2596
2597/* Relies on:
2598 inline static Bool isAtom ( IRExpr* e ) {
sewardjdd40fdf2006-12-24 02:20:24 +00002599 return e->tag == Iex_RdTmp || e->tag == Iex_Const;
sewardjcf787902004-11-03 09:08:33 +00002600 }
2601*/
2602
2603Bool isFlatIRStmt ( IRStmt* st )
2604{
2605 Int i;
2606 IRExpr* e;
2607 IRDirty* di;
sewardje9d8a262009-07-01 08:06:34 +00002608 IRCAS* cas;
sewardjcf787902004-11-03 09:08:33 +00002609
2610 switch (st->tag) {
sewardj5a9ffab2005-05-12 17:55:01 +00002611 case Ist_AbiHint:
sewardj478646f2008-05-01 20:13:04 +00002612 return isIRAtom(st->Ist.AbiHint.base)
2613 && isIRAtom(st->Ist.AbiHint.nia);
sewardjcf787902004-11-03 09:08:33 +00002614 case Ist_Put:
sewardj496a58d2005-03-20 18:44:44 +00002615 return isIRAtom(st->Ist.Put.data);
sewardjcf787902004-11-03 09:08:33 +00002616 case Ist_PutI:
sewardj496a58d2005-03-20 18:44:44 +00002617 return toBool( isIRAtom(st->Ist.PutI.ix)
2618 && isIRAtom(st->Ist.PutI.data) );
sewardjdd40fdf2006-12-24 02:20:24 +00002619 case Ist_WrTmp:
sewardjcf787902004-11-03 09:08:33 +00002620 /* This is the only interesting case. The RHS can be any
2621 expression, *but* all its subexpressions *must* be
2622 atoms. */
sewardjdd40fdf2006-12-24 02:20:24 +00002623 e = st->Ist.WrTmp.data;
sewardjcf787902004-11-03 09:08:33 +00002624 switch (e->tag) {
2625 case Iex_Binder: return True;
2626 case Iex_Get: return True;
sewardj496a58d2005-03-20 18:44:44 +00002627 case Iex_GetI: return isIRAtom(e->Iex.GetI.ix);
sewardjdd40fdf2006-12-24 02:20:24 +00002628 case Iex_RdTmp: return True;
sewardj40c80262006-02-08 19:30:46 +00002629 case Iex_Qop: return toBool(
2630 isIRAtom(e->Iex.Qop.arg1)
2631 && isIRAtom(e->Iex.Qop.arg2)
2632 && isIRAtom(e->Iex.Qop.arg3)
2633 && isIRAtom(e->Iex.Qop.arg4));
sewardjb183b852006-02-03 16:08:03 +00002634 case Iex_Triop: return toBool(
2635 isIRAtom(e->Iex.Triop.arg1)
2636 && isIRAtom(e->Iex.Triop.arg2)
2637 && isIRAtom(e->Iex.Triop.arg3));
sewardja98bf492005-02-07 01:39:17 +00002638 case Iex_Binop: return toBool(
sewardj496a58d2005-03-20 18:44:44 +00002639 isIRAtom(e->Iex.Binop.arg1)
2640 && isIRAtom(e->Iex.Binop.arg2));
2641 case Iex_Unop: return isIRAtom(e->Iex.Unop.arg);
sewardjaf1ceca2005-06-30 23:31:27 +00002642 case Iex_Load: return isIRAtom(e->Iex.Load.addr);
sewardjcf787902004-11-03 09:08:33 +00002643 case Iex_Const: return True;
2644 case Iex_CCall: for (i = 0; e->Iex.CCall.args[i]; i++)
sewardj496a58d2005-03-20 18:44:44 +00002645 if (!isIRAtom(e->Iex.CCall.args[i]))
sewardjcf787902004-11-03 09:08:33 +00002646 return False;
2647 return True;
sewardja98bf492005-02-07 01:39:17 +00002648 case Iex_Mux0X: return toBool (
sewardj496a58d2005-03-20 18:44:44 +00002649 isIRAtom(e->Iex.Mux0X.cond)
2650 && isIRAtom(e->Iex.Mux0X.expr0)
2651 && isIRAtom(e->Iex.Mux0X.exprX));
sewardjcf787902004-11-03 09:08:33 +00002652 default: vpanic("isFlatIRStmt(e)");
2653 }
2654 /*notreached*/
2655 vassert(0);
sewardjaf1ceca2005-06-30 23:31:27 +00002656 case Ist_Store:
2657 return toBool( isIRAtom(st->Ist.Store.addr)
2658 && isIRAtom(st->Ist.Store.data) );
sewardje9d8a262009-07-01 08:06:34 +00002659 case Ist_CAS:
2660 cas = st->Ist.CAS.details;
2661 return toBool( isIRAtom(cas->addr)
2662 && (cas->expdHi ? isIRAtom(cas->expdHi) : True)
2663 && isIRAtom(cas->expdLo)
2664 && (cas->dataHi ? isIRAtom(cas->dataHi) : True)
2665 && isIRAtom(cas->dataLo) );
sewardje768e922009-11-26 17:17:37 +00002666 case Ist_LLSC:
2667 return toBool( isIRAtom(st->Ist.LLSC.addr)
2668 && (st->Ist.LLSC.storedata
2669 ? isIRAtom(st->Ist.LLSC.storedata) : True) );
sewardjcf787902004-11-03 09:08:33 +00002670 case Ist_Dirty:
2671 di = st->Ist.Dirty.details;
sewardj496a58d2005-03-20 18:44:44 +00002672 if (!isIRAtom(di->guard))
sewardjcf787902004-11-03 09:08:33 +00002673 return False;
2674 for (i = 0; di->args[i]; i++)
sewardj496a58d2005-03-20 18:44:44 +00002675 if (!isIRAtom(di->args[i]))
sewardjcf787902004-11-03 09:08:33 +00002676 return False;
sewardj496a58d2005-03-20 18:44:44 +00002677 if (di->mAddr && !isIRAtom(di->mAddr))
sewardjcf787902004-11-03 09:08:33 +00002678 return False;
2679 return True;
sewardjd2445f62005-03-21 00:15:53 +00002680 case Ist_NoOp:
sewardjf1689312005-03-16 18:19:10 +00002681 case Ist_IMark:
sewardjc4356f02007-11-09 21:15:04 +00002682 case Ist_MBE:
sewardj3e838932005-01-07 12:09:15 +00002683 return True;
sewardjcf787902004-11-03 09:08:33 +00002684 case Ist_Exit:
sewardj496a58d2005-03-20 18:44:44 +00002685 return isIRAtom(st->Ist.Exit.guard);
sewardjcf787902004-11-03 09:08:33 +00002686 default:
2687 vpanic("isFlatIRStmt(st)");
2688 }
2689}
2690
2691
2692/*---------------------------------------------------------------*/
sewardje539a402004-07-14 18:24:17 +00002693/*--- Sanity checking ---*/
2694/*---------------------------------------------------------------*/
2695
2696/* Checks:
2697
2698 Everything is type-consistent. No ill-typed anything.
sewardj35439212004-07-14 22:36:10 +00002699 The target address at the end of the BB is a 32- or 64-
2700 bit expression, depending on the guest's word size.
sewardje539a402004-07-14 18:24:17 +00002701
2702 Each temp is assigned only once, before its uses.
sewardjc13e2ed2004-10-31 21:44:54 +00002703*/
2704
2705static inline Int countArgs ( IRExpr** args )
2706{
2707 Int i;
2708 for (i = 0; args[i]; i++)
2709 ;
2710 return i;
2711}
sewardje539a402004-07-14 18:24:17 +00002712
sewardj35439212004-07-14 22:36:10 +00002713static
2714__attribute((noreturn))
sewardjdd40fdf2006-12-24 02:20:24 +00002715void sanityCheckFail ( IRSB* bb, IRStmt* stmt, HChar* what )
sewardje539a402004-07-14 18:24:17 +00002716{
sewardj35439212004-07-14 22:36:10 +00002717 vex_printf("\nIR SANITY CHECK FAILURE\n\n");
sewardjdd40fdf2006-12-24 02:20:24 +00002718 ppIRSB(bb);
sewardj35439212004-07-14 22:36:10 +00002719 if (stmt) {
2720 vex_printf("\nIN STATEMENT:\n\n");
2721 ppIRStmt(stmt);
2722 }
2723 vex_printf("\n\nERROR = %s\n\n", what );
2724 vpanic("sanityCheckFail: exiting due to bad IR");
2725}
2726
sewardjdd40fdf2006-12-24 02:20:24 +00002727static Bool saneIRRegArray ( IRRegArray* arr )
sewardj2d3f77c2004-09-22 23:49:09 +00002728{
2729 if (arr->base < 0 || arr->base > 10000 /* somewhat arbitrary */)
2730 return False;
sewardjba999312004-11-15 15:21:17 +00002731 if (arr->elemTy == Ity_I1)
sewardj2d3f77c2004-09-22 23:49:09 +00002732 return False;
2733 if (arr->nElems <= 0 || arr->nElems > 500 /* somewhat arbitrary */)
2734 return False;
2735 return True;
2736}
2737
sewardj8ea867b2004-10-30 19:03:02 +00002738static Bool saneIRCallee ( IRCallee* cee )
2739{
2740 if (cee->name == NULL)
2741 return False;
2742 if (cee->addr == 0)
2743 return False;
sewardj77352542004-10-30 20:39:01 +00002744 if (cee->regparms < 0 || cee->regparms > 3)
sewardj8ea867b2004-10-30 19:03:02 +00002745 return False;
2746 return True;
2747}
2748
sewardj49bfe672004-11-15 15:46:26 +00002749static Bool saneIRConst ( IRConst* con )
2750{
2751 switch (con->tag) {
2752 case Ico_U1:
sewardja98bf492005-02-07 01:39:17 +00002753 return toBool( con->Ico.U1 == True || con->Ico.U1 == False );
sewardj49bfe672004-11-15 15:46:26 +00002754 default:
2755 /* Is there anything we can meaningfully check? I don't
2756 think so. */
2757 return True;
2758 }
2759}
sewardj35439212004-07-14 22:36:10 +00002760
2761/* Traverse a Stmt/Expr, inspecting IRTemp uses. Report any out of
2762 range ones. Report any which are read and for which the current
2763 def_count is zero. */
2764
2765static
sewardjdd40fdf2006-12-24 02:20:24 +00002766void useBeforeDef_Temp ( IRSB* bb, IRStmt* stmt, IRTemp tmp, Int* def_counts )
sewardj17442fe2004-09-20 14:54:28 +00002767{
2768 if (tmp < 0 || tmp >= bb->tyenv->types_used)
2769 sanityCheckFail(bb,stmt, "out of range Temp in IRExpr");
2770 if (def_counts[tmp] < 1)
2771 sanityCheckFail(bb,stmt, "IRTemp use before def in IRExpr");
2772}
2773
2774static
sewardjdd40fdf2006-12-24 02:20:24 +00002775void useBeforeDef_Expr ( IRSB* bb, IRStmt* stmt, IRExpr* expr, Int* def_counts )
sewardj35439212004-07-14 22:36:10 +00002776{
2777 Int i;
2778 switch (expr->tag) {
2779 case Iex_Get:
2780 break;
sewardjbb53f8c2004-08-14 11:50:01 +00002781 case Iex_GetI:
sewardjeeac8412004-11-02 00:26:55 +00002782 useBeforeDef_Expr(bb,stmt,expr->Iex.GetI.ix,def_counts);
sewardjbb53f8c2004-08-14 11:50:01 +00002783 break;
sewardjdd40fdf2006-12-24 02:20:24 +00002784 case Iex_RdTmp:
2785 useBeforeDef_Temp(bb,stmt,expr->Iex.RdTmp.tmp,def_counts);
sewardj35439212004-07-14 22:36:10 +00002786 break;
sewardj40c80262006-02-08 19:30:46 +00002787 case Iex_Qop:
2788 useBeforeDef_Expr(bb,stmt,expr->Iex.Qop.arg1,def_counts);
2789 useBeforeDef_Expr(bb,stmt,expr->Iex.Qop.arg2,def_counts);
2790 useBeforeDef_Expr(bb,stmt,expr->Iex.Qop.arg3,def_counts);
2791 useBeforeDef_Expr(bb,stmt,expr->Iex.Qop.arg4,def_counts);
2792 break;
sewardjb183b852006-02-03 16:08:03 +00002793 case Iex_Triop:
2794 useBeforeDef_Expr(bb,stmt,expr->Iex.Triop.arg1,def_counts);
2795 useBeforeDef_Expr(bb,stmt,expr->Iex.Triop.arg2,def_counts);
2796 useBeforeDef_Expr(bb,stmt,expr->Iex.Triop.arg3,def_counts);
2797 break;
sewardj35439212004-07-14 22:36:10 +00002798 case Iex_Binop:
2799 useBeforeDef_Expr(bb,stmt,expr->Iex.Binop.arg1,def_counts);
2800 useBeforeDef_Expr(bb,stmt,expr->Iex.Binop.arg2,def_counts);
2801 break;
2802 case Iex_Unop:
2803 useBeforeDef_Expr(bb,stmt,expr->Iex.Unop.arg,def_counts);
2804 break;
sewardjaf1ceca2005-06-30 23:31:27 +00002805 case Iex_Load:
2806 useBeforeDef_Expr(bb,stmt,expr->Iex.Load.addr,def_counts);
sewardj35439212004-07-14 22:36:10 +00002807 break;
2808 case Iex_Const:
2809 break;
2810 case Iex_CCall:
2811 for (i = 0; expr->Iex.CCall.args[i]; i++)
2812 useBeforeDef_Expr(bb,stmt,expr->Iex.CCall.args[i],def_counts);
2813 break;
sewardj4042c7e2004-07-18 01:28:30 +00002814 case Iex_Mux0X:
2815 useBeforeDef_Expr(bb,stmt,expr->Iex.Mux0X.cond,def_counts);
2816 useBeforeDef_Expr(bb,stmt,expr->Iex.Mux0X.expr0,def_counts);
2817 useBeforeDef_Expr(bb,stmt,expr->Iex.Mux0X.exprX,def_counts);
sewardjeeb9ef82004-07-15 12:39:03 +00002818 break;
2819 default:
2820 vpanic("useBeforeDef_Expr");
sewardj35439212004-07-14 22:36:10 +00002821 }
2822}
2823
2824static
sewardjdd40fdf2006-12-24 02:20:24 +00002825void useBeforeDef_Stmt ( IRSB* bb, IRStmt* stmt, Int* def_counts )
sewardj35439212004-07-14 22:36:10 +00002826{
sewardj17442fe2004-09-20 14:54:28 +00002827 Int i;
2828 IRDirty* d;
sewardje9d8a262009-07-01 08:06:34 +00002829 IRCAS* cas;
sewardj35439212004-07-14 22:36:10 +00002830 switch (stmt->tag) {
sewardjf1689312005-03-16 18:19:10 +00002831 case Ist_IMark:
2832 break;
sewardj5a9ffab2005-05-12 17:55:01 +00002833 case Ist_AbiHint:
2834 useBeforeDef_Expr(bb,stmt,stmt->Ist.AbiHint.base,def_counts);
sewardj478646f2008-05-01 20:13:04 +00002835 useBeforeDef_Expr(bb,stmt,stmt->Ist.AbiHint.nia,def_counts);
sewardj5a9ffab2005-05-12 17:55:01 +00002836 break;
sewardj35439212004-07-14 22:36:10 +00002837 case Ist_Put:
sewardj6d076362004-09-23 11:06:17 +00002838 useBeforeDef_Expr(bb,stmt,stmt->Ist.Put.data,def_counts);
sewardj35439212004-07-14 22:36:10 +00002839 break;
sewardjd1725d12004-08-12 20:46:53 +00002840 case Ist_PutI:
sewardjeeac8412004-11-02 00:26:55 +00002841 useBeforeDef_Expr(bb,stmt,stmt->Ist.PutI.ix,def_counts);
sewardj2d3f77c2004-09-22 23:49:09 +00002842 useBeforeDef_Expr(bb,stmt,stmt->Ist.PutI.data,def_counts);
sewardjd1725d12004-08-12 20:46:53 +00002843 break;
sewardjdd40fdf2006-12-24 02:20:24 +00002844 case Ist_WrTmp:
2845 useBeforeDef_Expr(bb,stmt,stmt->Ist.WrTmp.data,def_counts);
sewardj35439212004-07-14 22:36:10 +00002846 break;
sewardjaf1ceca2005-06-30 23:31:27 +00002847 case Ist_Store:
2848 useBeforeDef_Expr(bb,stmt,stmt->Ist.Store.addr,def_counts);
2849 useBeforeDef_Expr(bb,stmt,stmt->Ist.Store.data,def_counts);
sewardj35439212004-07-14 22:36:10 +00002850 break;
sewardje9d8a262009-07-01 08:06:34 +00002851 case Ist_CAS:
2852 cas = stmt->Ist.CAS.details;
2853 useBeforeDef_Expr(bb,stmt,cas->addr,def_counts);
2854 if (cas->expdHi)
2855 useBeforeDef_Expr(bb,stmt,cas->expdHi,def_counts);
2856 useBeforeDef_Expr(bb,stmt,cas->expdLo,def_counts);
2857 if (cas->dataHi)
2858 useBeforeDef_Expr(bb,stmt,cas->dataHi,def_counts);
2859 useBeforeDef_Expr(bb,stmt,cas->dataLo,def_counts);
2860 break;
sewardje768e922009-11-26 17:17:37 +00002861 case Ist_LLSC:
2862 useBeforeDef_Expr(bb,stmt,stmt->Ist.LLSC.addr,def_counts);
2863 if (stmt->Ist.LLSC.storedata != NULL)
2864 useBeforeDef_Expr(bb,stmt,stmt->Ist.LLSC.storedata,def_counts);
2865 break;
sewardj17442fe2004-09-20 14:54:28 +00002866 case Ist_Dirty:
2867 d = stmt->Ist.Dirty.details;
2868 for (i = 0; d->args[i] != NULL; i++)
2869 useBeforeDef_Expr(bb,stmt,d->args[i],def_counts);
2870 if (d->mFx != Ifx_None)
2871 useBeforeDef_Expr(bb,stmt,d->mAddr,def_counts);
2872 break;
sewardjd2445f62005-03-21 00:15:53 +00002873 case Ist_NoOp:
sewardjc4356f02007-11-09 21:15:04 +00002874 case Ist_MBE:
sewardj3e838932005-01-07 12:09:15 +00002875 break;
sewardj35439212004-07-14 22:36:10 +00002876 case Ist_Exit:
sewardj0276d4b2004-11-15 15:30:21 +00002877 useBeforeDef_Expr(bb,stmt,stmt->Ist.Exit.guard,def_counts);
sewardj35439212004-07-14 22:36:10 +00002878 break;
2879 default:
2880 vpanic("useBeforeDef_Stmt");
2881 }
2882}
2883
sewardj6efd4a12004-07-15 03:54:23 +00002884static
sewardjdd40fdf2006-12-24 02:20:24 +00002885void tcExpr ( IRSB* bb, IRStmt* stmt, IRExpr* expr, IRType gWordTy )
sewardj6efd4a12004-07-15 03:54:23 +00002886{
2887 Int i;
sewardj40c80262006-02-08 19:30:46 +00002888 IRType t_dst, t_arg1, t_arg2, t_arg3, t_arg4;
sewardj6efd4a12004-07-15 03:54:23 +00002889 IRTypeEnv* tyenv = bb->tyenv;
2890 switch (expr->tag) {
2891 case Iex_Get:
sewardjdd40fdf2006-12-24 02:20:24 +00002892 case Iex_RdTmp:
sewardj6efd4a12004-07-15 03:54:23 +00002893 break;
sewardjbb53f8c2004-08-14 11:50:01 +00002894 case Iex_GetI:
sewardjeeac8412004-11-02 00:26:55 +00002895 tcExpr(bb,stmt, expr->Iex.GetI.ix, gWordTy );
2896 if (typeOfIRExpr(tyenv,expr->Iex.GetI.ix) != Ity_I32)
2897 sanityCheckFail(bb,stmt,"IRExpr.GetI.ix: not :: Ity_I32");
sewardjdd40fdf2006-12-24 02:20:24 +00002898 if (!saneIRRegArray(expr->Iex.GetI.descr))
sewardj2d3f77c2004-09-22 23:49:09 +00002899 sanityCheckFail(bb,stmt,"IRExpr.GetI.descr: invalid descr");
sewardjbb53f8c2004-08-14 11:50:01 +00002900 break;
sewardj40c80262006-02-08 19:30:46 +00002901 case Iex_Qop: {
2902 IRType ttarg1, ttarg2, ttarg3, ttarg4;
2903 tcExpr(bb,stmt, expr->Iex.Qop.arg1, gWordTy );
2904 tcExpr(bb,stmt, expr->Iex.Qop.arg2, gWordTy );
2905 tcExpr(bb,stmt, expr->Iex.Qop.arg3, gWordTy );
2906 tcExpr(bb,stmt, expr->Iex.Qop.arg4, gWordTy );
2907 typeOfPrimop(expr->Iex.Qop.op,
2908 &t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4);
2909 if (t_arg1 == Ity_INVALID || t_arg2 == Ity_INVALID
2910 || t_arg3 == Ity_INVALID || t_arg4 == Ity_INVALID) {
2911 vex_printf(" op name: " );
2912 ppIROp(expr->Iex.Qop.op);
2913 vex_printf("\n");
2914 sanityCheckFail(bb,stmt,
2915 "Iex.Qop: wrong arity op\n"
2916 "... name of op precedes BB printout\n");
2917 }
2918 ttarg1 = typeOfIRExpr(tyenv, expr->Iex.Qop.arg1);
2919 ttarg2 = typeOfIRExpr(tyenv, expr->Iex.Qop.arg2);
2920 ttarg3 = typeOfIRExpr(tyenv, expr->Iex.Qop.arg3);
2921 ttarg4 = typeOfIRExpr(tyenv, expr->Iex.Qop.arg4);
2922 if (t_arg1 != ttarg1 || t_arg2 != ttarg2
2923 || t_arg3 != ttarg3 || t_arg4 != ttarg4) {
2924 vex_printf(" op name: ");
2925 ppIROp(expr->Iex.Qop.op);
2926 vex_printf("\n");
2927 vex_printf(" op type is (");
2928 ppIRType(t_arg1);
2929 vex_printf(",");
2930 ppIRType(t_arg2);
2931 vex_printf(",");
2932 ppIRType(t_arg3);
2933 vex_printf(",");
2934 ppIRType(t_arg4);
2935 vex_printf(") -> ");
2936 ppIRType (t_dst);
2937 vex_printf("\narg tys are (");
2938 ppIRType(ttarg1);
2939 vex_printf(",");
2940 ppIRType(ttarg2);
2941 vex_printf(",");
2942 ppIRType(ttarg3);
2943 vex_printf(",");
2944 ppIRType(ttarg4);
2945 vex_printf(")\n");
2946 sanityCheckFail(bb,stmt,
2947 "Iex.Qop: arg tys don't match op tys\n"
2948 "... additional details precede BB printout\n");
2949 }
2950 break;
2951 }
sewardjb183b852006-02-03 16:08:03 +00002952 case Iex_Triop: {
2953 IRType ttarg1, ttarg2, ttarg3;
2954 tcExpr(bb,stmt, expr->Iex.Triop.arg1, gWordTy );
2955 tcExpr(bb,stmt, expr->Iex.Triop.arg2, gWordTy );
2956 tcExpr(bb,stmt, expr->Iex.Triop.arg3, gWordTy );
sewardj40c80262006-02-08 19:30:46 +00002957 typeOfPrimop(expr->Iex.Triop.op,
2958 &t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4);
sewardjb183b852006-02-03 16:08:03 +00002959 if (t_arg1 == Ity_INVALID || t_arg2 == Ity_INVALID
sewardj40c80262006-02-08 19:30:46 +00002960 || t_arg3 == Ity_INVALID || t_arg4 != Ity_INVALID) {
sewardjb183b852006-02-03 16:08:03 +00002961 vex_printf(" op name: " );
2962 ppIROp(expr->Iex.Triop.op);
2963 vex_printf("\n");
2964 sanityCheckFail(bb,stmt,
2965 "Iex.Triop: wrong arity op\n"
2966 "... name of op precedes BB printout\n");
2967 }
2968 ttarg1 = typeOfIRExpr(tyenv, expr->Iex.Triop.arg1);
2969 ttarg2 = typeOfIRExpr(tyenv, expr->Iex.Triop.arg2);
2970 ttarg3 = typeOfIRExpr(tyenv, expr->Iex.Triop.arg3);
2971 if (t_arg1 != ttarg1 || t_arg2 != ttarg2 || t_arg3 != ttarg3) {
2972 vex_printf(" op name: ");
2973 ppIROp(expr->Iex.Triop.op);
2974 vex_printf("\n");
2975 vex_printf(" op type is (");
2976 ppIRType(t_arg1);
2977 vex_printf(",");
2978 ppIRType(t_arg2);
2979 vex_printf(",");
2980 ppIRType(t_arg3);
2981 vex_printf(") -> ");
2982 ppIRType (t_dst);
2983 vex_printf("\narg tys are (");
2984 ppIRType(ttarg1);
2985 vex_printf(",");
2986 ppIRType(ttarg2);
2987 vex_printf(",");
2988 ppIRType(ttarg3);
2989 vex_printf(")\n");
2990 sanityCheckFail(bb,stmt,
2991 "Iex.Triop: arg tys don't match op tys\n"
2992 "... additional details precede BB printout\n");
2993 }
2994 break;
2995 }
sewardj6d2638e2004-07-15 09:38:27 +00002996 case Iex_Binop: {
2997 IRType ttarg1, ttarg2;
sewardj6efd4a12004-07-15 03:54:23 +00002998 tcExpr(bb,stmt, expr->Iex.Binop.arg1, gWordTy );
2999 tcExpr(bb,stmt, expr->Iex.Binop.arg2, gWordTy );
sewardj40c80262006-02-08 19:30:46 +00003000 typeOfPrimop(expr->Iex.Binop.op,
3001 &t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4);
sewardjb183b852006-02-03 16:08:03 +00003002 if (t_arg1 == Ity_INVALID || t_arg2 == Ity_INVALID
sewardj40c80262006-02-08 19:30:46 +00003003 || t_arg3 != Ity_INVALID || t_arg4 != Ity_INVALID) {
sewardj8f3debf2004-09-08 23:42:23 +00003004 vex_printf(" op name: " );
3005 ppIROp(expr->Iex.Binop.op);
3006 vex_printf("\n");
3007 sanityCheckFail(bb,stmt,
3008 "Iex.Binop: wrong arity op\n"
3009 "... name of op precedes BB printout\n");
3010 }
sewardj6d2638e2004-07-15 09:38:27 +00003011 ttarg1 = typeOfIRExpr(tyenv, expr->Iex.Binop.arg1);
3012 ttarg2 = typeOfIRExpr(tyenv, expr->Iex.Binop.arg2);
3013 if (t_arg1 != ttarg1 || t_arg2 != ttarg2) {
3014 vex_printf(" op name: ");
3015 ppIROp(expr->Iex.Binop.op);
3016 vex_printf("\n");
3017 vex_printf(" op type is (");
3018 ppIRType(t_arg1);
3019 vex_printf(",");
3020 ppIRType(t_arg2);
3021 vex_printf(") -> ");
3022 ppIRType (t_dst);
3023 vex_printf("\narg tys are (");
3024 ppIRType(ttarg1);
3025 vex_printf(",");
3026 ppIRType(ttarg2);
3027 vex_printf(")\n");
3028 sanityCheckFail(bb,stmt,
3029 "Iex.Binop: arg tys don't match op tys\n"
3030 "... additional details precede BB printout\n");
sewardj695cff92004-10-13 14:50:14 +00003031 }
sewardj6efd4a12004-07-15 03:54:23 +00003032 break;
sewardj6d2638e2004-07-15 09:38:27 +00003033 }
sewardj6efd4a12004-07-15 03:54:23 +00003034 case Iex_Unop:
3035 tcExpr(bb,stmt, expr->Iex.Unop.arg, gWordTy );
sewardj40c80262006-02-08 19:30:46 +00003036 typeOfPrimop(expr->Iex.Binop.op,
3037 &t_dst, &t_arg1, &t_arg2, &t_arg3, &t_arg4);
sewardjb183b852006-02-03 16:08:03 +00003038 if (t_arg1 == Ity_INVALID || t_arg2 != Ity_INVALID
sewardj40c80262006-02-08 19:30:46 +00003039 || t_arg3 != Ity_INVALID || t_arg4 != Ity_INVALID)
sewardj6efd4a12004-07-15 03:54:23 +00003040 sanityCheckFail(bb,stmt,"Iex.Unop: wrong arity op");
3041 if (t_arg1 != typeOfIRExpr(tyenv, expr->Iex.Unop.arg))
3042 sanityCheckFail(bb,stmt,"Iex.Unop: arg ty doesn't match op ty");
3043 break;
sewardjaf1ceca2005-06-30 23:31:27 +00003044 case Iex_Load:
3045 tcExpr(bb,stmt, expr->Iex.Load.addr, gWordTy);
3046 if (typeOfIRExpr(tyenv, expr->Iex.Load.addr) != gWordTy)
3047 sanityCheckFail(bb,stmt,"Iex.Load.addr: not :: guest word type");
3048 if (expr->Iex.Load.end != Iend_LE && expr->Iex.Load.end != Iend_BE)
3049 sanityCheckFail(bb,stmt,"Iex.Load.end: bogus endianness");
sewardj6efd4a12004-07-15 03:54:23 +00003050 break;
3051 case Iex_CCall:
sewardjc13e2ed2004-10-31 21:44:54 +00003052 if (!saneIRCallee(expr->Iex.CCall.cee))
3053 sanityCheckFail(bb,stmt,"Iex.CCall.cee: bad IRCallee");
sewardjcf787902004-11-03 09:08:33 +00003054 if (expr->Iex.CCall.cee->regparms > countArgs(expr->Iex.CCall.args))
sewardjc13e2ed2004-10-31 21:44:54 +00003055 sanityCheckFail(bb,stmt,"Iex.CCall.cee: #regparms > #args");
sewardj43c56462004-11-06 12:17:57 +00003056 for (i = 0; expr->Iex.CCall.args[i]; i++) {
3057 if (i >= 32)
3058 sanityCheckFail(bb,stmt,"Iex.CCall: > 32 args");
sewardj6efd4a12004-07-15 03:54:23 +00003059 tcExpr(bb,stmt, expr->Iex.CCall.args[i], gWordTy);
sewardj43c56462004-11-06 12:17:57 +00003060 }
sewardjba999312004-11-15 15:21:17 +00003061 if (expr->Iex.CCall.retty == Ity_I1)
3062 sanityCheckFail(bb,stmt,"Iex.CCall.retty: cannot return :: Ity_I1");
sewardj6efd4a12004-07-15 03:54:23 +00003063 for (i = 0; expr->Iex.CCall.args[i]; i++)
sewardjba999312004-11-15 15:21:17 +00003064 if (typeOfIRExpr(tyenv, expr->Iex.CCall.args[i]) == Ity_I1)
3065 sanityCheckFail(bb,stmt,"Iex.CCall.arg: arg :: Ity_I1");
sewardj6efd4a12004-07-15 03:54:23 +00003066 break;
3067 case Iex_Const:
sewardj49bfe672004-11-15 15:46:26 +00003068 if (!saneIRConst(expr->Iex.Const.con))
3069 sanityCheckFail(bb,stmt,"Iex.Const.con: invalid const");
sewardj6efd4a12004-07-15 03:54:23 +00003070 break;
sewardj4042c7e2004-07-18 01:28:30 +00003071 case Iex_Mux0X:
3072 tcExpr(bb,stmt, expr->Iex.Mux0X.cond, gWordTy);
3073 tcExpr(bb,stmt, expr->Iex.Mux0X.expr0, gWordTy);
3074 tcExpr(bb,stmt, expr->Iex.Mux0X.exprX, gWordTy);
3075 if (typeOfIRExpr(tyenv, expr->Iex.Mux0X.cond) != Ity_I8)
3076 sanityCheckFail(bb,stmt,"Iex.Mux0X.cond: cond :: Ity_I8");
3077 if (typeOfIRExpr(tyenv, expr->Iex.Mux0X.expr0)
3078 != typeOfIRExpr(tyenv, expr->Iex.Mux0X.exprX))
3079 sanityCheckFail(bb,stmt,"Iex.Mux0X: expr0/exprX mismatch");
sewardjeeb9ef82004-07-15 12:39:03 +00003080 break;
3081 default:
sewardj6efd4a12004-07-15 03:54:23 +00003082 vpanic("tcExpr");
3083 }
3084}
3085
3086
3087static
sewardjdd40fdf2006-12-24 02:20:24 +00003088void tcStmt ( IRSB* bb, IRStmt* stmt, IRType gWordTy )
sewardj6efd4a12004-07-15 03:54:23 +00003089{
sewardj17442fe2004-09-20 14:54:28 +00003090 Int i;
3091 IRDirty* d;
sewardje9d8a262009-07-01 08:06:34 +00003092 IRCAS* cas;
3093 IRType tyExpd, tyData;
sewardj6efd4a12004-07-15 03:54:23 +00003094 IRTypeEnv* tyenv = bb->tyenv;
3095 switch (stmt->tag) {
sewardjf1689312005-03-16 18:19:10 +00003096 case Ist_IMark:
3097 /* Somewhat heuristic, but rule out totally implausible
3098 instruction sizes. */
3099 if (stmt->Ist.IMark.len < 0 || stmt->Ist.IMark.len > 20)
3100 sanityCheckFail(bb,stmt,"IRStmt.IMark.len: implausible");
3101 break;
sewardj5a9ffab2005-05-12 17:55:01 +00003102 case Ist_AbiHint:
3103 if (typeOfIRExpr(tyenv, stmt->Ist.AbiHint.base) != gWordTy)
3104 sanityCheckFail(bb,stmt,"IRStmt.AbiHint.base: "
3105 "not :: guest word type");
sewardj478646f2008-05-01 20:13:04 +00003106 if (typeOfIRExpr(tyenv, stmt->Ist.AbiHint.nia) != gWordTy)
3107 sanityCheckFail(bb,stmt,"IRStmt.AbiHint.nia: "
3108 "not :: guest word type");
sewardj5a9ffab2005-05-12 17:55:01 +00003109 break;
sewardj6efd4a12004-07-15 03:54:23 +00003110 case Ist_Put:
sewardj6d076362004-09-23 11:06:17 +00003111 tcExpr( bb, stmt, stmt->Ist.Put.data, gWordTy );
sewardjba999312004-11-15 15:21:17 +00003112 if (typeOfIRExpr(tyenv,stmt->Ist.Put.data) == Ity_I1)
3113 sanityCheckFail(bb,stmt,"IRStmt.Put.data: cannot Put :: Ity_I1");
sewardj2d3f77c2004-09-22 23:49:09 +00003114 break;
sewardjd1725d12004-08-12 20:46:53 +00003115 case Ist_PutI:
sewardj2d3f77c2004-09-22 23:49:09 +00003116 tcExpr( bb, stmt, stmt->Ist.PutI.data, gWordTy );
sewardjeeac8412004-11-02 00:26:55 +00003117 tcExpr( bb, stmt, stmt->Ist.PutI.ix, gWordTy );
sewardjba999312004-11-15 15:21:17 +00003118 if (typeOfIRExpr(tyenv,stmt->Ist.PutI.data) == Ity_I1)
3119 sanityCheckFail(bb,stmt,"IRStmt.PutI.data: cannot PutI :: Ity_I1");
sewardj6d076362004-09-23 11:06:17 +00003120 if (typeOfIRExpr(tyenv,stmt->Ist.PutI.data)
3121 != stmt->Ist.PutI.descr->elemTy)
3122 sanityCheckFail(bb,stmt,"IRStmt.PutI.data: data ty != elem ty");
sewardjeeac8412004-11-02 00:26:55 +00003123 if (typeOfIRExpr(tyenv,stmt->Ist.PutI.ix) != Ity_I32)
3124 sanityCheckFail(bb,stmt,"IRStmt.PutI.ix: not :: Ity_I32");
sewardjdd40fdf2006-12-24 02:20:24 +00003125 if (!saneIRRegArray(stmt->Ist.PutI.descr))
sewardj2d3f77c2004-09-22 23:49:09 +00003126 sanityCheckFail(bb,stmt,"IRStmt.PutI.descr: invalid descr");
3127 break;
sewardjdd40fdf2006-12-24 02:20:24 +00003128 case Ist_WrTmp:
3129 tcExpr( bb, stmt, stmt->Ist.WrTmp.data, gWordTy );
3130 if (typeOfIRTemp(tyenv, stmt->Ist.WrTmp.tmp)
3131 != typeOfIRExpr(tyenv, stmt->Ist.WrTmp.data))
sewardj6d2638e2004-07-15 09:38:27 +00003132 sanityCheckFail(bb,stmt,"IRStmt.Put.Tmp: tmp and expr do not match");
sewardj6efd4a12004-07-15 03:54:23 +00003133 break;
sewardjaf1ceca2005-06-30 23:31:27 +00003134 case Ist_Store:
3135 tcExpr( bb, stmt, stmt->Ist.Store.addr, gWordTy );
3136 tcExpr( bb, stmt, stmt->Ist.Store.data, gWordTy );
3137 if (typeOfIRExpr(tyenv, stmt->Ist.Store.addr) != gWordTy)
3138 sanityCheckFail(bb,stmt,"IRStmt.Store.addr: not :: guest word type");
3139 if (typeOfIRExpr(tyenv, stmt->Ist.Store.data) == Ity_I1)
3140 sanityCheckFail(bb,stmt,"IRStmt.Store.data: cannot Store :: Ity_I1");
3141 if (stmt->Ist.Store.end != Iend_LE && stmt->Ist.Store.end != Iend_BE)
3142 sanityCheckFail(bb,stmt,"Ist.Store.end: bogus endianness");
sewardje9d8a262009-07-01 08:06:34 +00003143 break;
3144 case Ist_CAS:
3145 cas = stmt->Ist.CAS.details;
3146 /* make sure it's definitely either a CAS or a DCAS */
3147 if (cas->oldHi == IRTemp_INVALID
3148 && cas->expdHi == NULL && cas->dataHi == NULL) {
3149 /* fine; it's a single cas */
3150 }
3151 else
3152 if (cas->oldHi != IRTemp_INVALID
3153 && cas->expdHi != NULL && cas->dataHi != NULL) {
3154 /* fine; it's a double cas */
3155 }
3156 else {
3157 /* it's some el-mutanto hybrid */
3158 goto bad_cas;
3159 }
3160 /* check the address type */
3161 tcExpr( bb, stmt, cas->addr, gWordTy );
3162 if (typeOfIRExpr(tyenv, cas->addr) != gWordTy) goto bad_cas;
3163 /* check types on the {old,expd,data}Lo components agree */
3164 tyExpd = typeOfIRExpr(tyenv, cas->expdLo);
3165 tyData = typeOfIRExpr(tyenv, cas->dataLo);
3166 if (tyExpd != tyData) goto bad_cas;
3167 if (tyExpd != typeOfIRTemp(tyenv, cas->oldLo))
3168 goto bad_cas;
3169 /* check the base element type is sane */
3170 if (tyExpd == Ity_I8 || tyExpd == Ity_I16 || tyExpd == Ity_I32
3171 || (gWordTy == Ity_I64 && tyExpd == Ity_I64)) {
3172 /* fine */
3173 } else {
3174 goto bad_cas;
3175 }
3176 /* If it's a DCAS, check types on the {old,expd,data}Hi
3177 components too */
3178 if (cas->oldHi != IRTemp_INVALID) {
3179 tyExpd = typeOfIRExpr(tyenv, cas->expdHi);
3180 tyData = typeOfIRExpr(tyenv, cas->dataHi);
3181 if (tyExpd != tyData) goto bad_cas;
3182 if (tyExpd != typeOfIRTemp(tyenv, cas->oldHi))
3183 goto bad_cas;
3184 /* and finally check that oldLo and oldHi have the same
3185 type. This forces equivalence amongst all 6 types. */
3186 if (typeOfIRTemp(tyenv, cas->oldHi)
3187 != typeOfIRTemp(tyenv, cas->oldLo))
3188 goto bad_cas;
3189 }
3190 break;
3191 bad_cas:
3192 sanityCheckFail(bb,stmt,"IRStmt.CAS: ill-formed");
sewardj6efd4a12004-07-15 03:54:23 +00003193 break;
sewardje768e922009-11-26 17:17:37 +00003194 case Ist_LLSC: {
3195 IRType tyRes;
3196 if (typeOfIRExpr(tyenv, stmt->Ist.LLSC.addr) != gWordTy)
3197 sanityCheckFail(bb,stmt,"IRStmt.LLSC.addr: not :: guest word type");
3198 if (stmt->Ist.LLSC.end != Iend_LE && stmt->Ist.LLSC.end != Iend_BE)
3199 sanityCheckFail(bb,stmt,"Ist.LLSC.end: bogus endianness");
3200 tyRes = typeOfIRTemp(tyenv, stmt->Ist.LLSC.result);
3201 if (stmt->Ist.LLSC.storedata == NULL) {
3202 /* it's a LL */
sewardj6c299f32009-12-31 18:00:12 +00003203 if (tyRes != Ity_I64 && tyRes != Ity_I32 && tyRes != Ity_I8)
sewardje768e922009-11-26 17:17:37 +00003204 sanityCheckFail(bb,stmt,"Ist.LLSC(LL).result :: bogus");
3205 } else {
3206 /* it's a SC */
3207 if (tyRes != Ity_I1)
3208 sanityCheckFail(bb,stmt,"Ist.LLSC(SC).result: not :: Ity_I1");
3209 tyData = typeOfIRExpr(tyenv, stmt->Ist.LLSC.storedata);
sewardj6c299f32009-12-31 18:00:12 +00003210 if (tyData != Ity_I64 && tyData != Ity_I32 && tyData != Ity_I8)
3211 sanityCheckFail(bb,stmt,
3212 "Ist.LLSC(SC).result :: storedata bogus");
sewardje768e922009-11-26 17:17:37 +00003213 }
3214 break;
3215 }
sewardj17442fe2004-09-20 14:54:28 +00003216 case Ist_Dirty:
3217 /* Mostly check for various kinds of ill-formed dirty calls. */
3218 d = stmt->Ist.Dirty.details;
sewardj8ea867b2004-10-30 19:03:02 +00003219 if (d->cee == NULL) goto bad_dirty;
3220 if (!saneIRCallee(d->cee)) goto bad_dirty;
sewardjcf787902004-11-03 09:08:33 +00003221 if (d->cee->regparms > countArgs(d->args)) goto bad_dirty;
sewardj17442fe2004-09-20 14:54:28 +00003222 if (d->mFx == Ifx_None) {
3223 if (d->mAddr != NULL || d->mSize != 0)
3224 goto bad_dirty;
3225 } else {
3226 if (d->mAddr == NULL || d->mSize == 0)
3227 goto bad_dirty;
3228 }
3229 if (d->nFxState < 0 || d->nFxState > VEX_N_FXSTATE)
3230 goto bad_dirty;
sewardjc5fc7aa2004-10-27 23:00:55 +00003231 if (d->nFxState == 0 && d->needsBBP)
3232 goto bad_dirty;
sewardj17442fe2004-09-20 14:54:28 +00003233 for (i = 0; i < d->nFxState; i++) {
3234 if (d->fxState[i].fx == Ifx_None) goto bad_dirty;
3235 if (d->fxState[i].size <= 0) goto bad_dirty;
3236 }
3237 /* check types, minimally */
sewardjb8385d82004-11-02 01:34:15 +00003238 if (d->guard == NULL) goto bad_dirty;
sewardj49bfe672004-11-15 15:46:26 +00003239 tcExpr( bb, stmt, d->guard, gWordTy );
sewardjba999312004-11-15 15:21:17 +00003240 if (typeOfIRExpr(tyenv, d->guard) != Ity_I1)
3241 sanityCheckFail(bb,stmt,"IRStmt.Dirty.guard not :: Ity_I1");
sewardj92d168d2004-11-15 14:22:12 +00003242 if (d->tmp != IRTemp_INVALID
sewardjba999312004-11-15 15:21:17 +00003243 && typeOfIRTemp(tyenv, d->tmp) == Ity_I1)
3244 sanityCheckFail(bb,stmt,"IRStmt.Dirty.dst :: Ity_I1");
sewardj17442fe2004-09-20 14:54:28 +00003245 for (i = 0; d->args[i] != NULL; i++) {
sewardj43c56462004-11-06 12:17:57 +00003246 if (i >= 32)
3247 sanityCheckFail(bb,stmt,"IRStmt.Dirty: > 32 args");
sewardjba999312004-11-15 15:21:17 +00003248 if (typeOfIRExpr(tyenv, d->args[i]) == Ity_I1)
3249 sanityCheckFail(bb,stmt,"IRStmt.Dirty.arg[i] :: Ity_I1");
sewardj17442fe2004-09-20 14:54:28 +00003250 }
3251 break;
3252 bad_dirty:
3253 sanityCheckFail(bb,stmt,"IRStmt.Dirty: ill-formed");
sewardje9d8a262009-07-01 08:06:34 +00003254 break;
sewardjd2445f62005-03-21 00:15:53 +00003255 case Ist_NoOp:
sewardjc4356f02007-11-09 21:15:04 +00003256 break;
3257 case Ist_MBE:
3258 switch (stmt->Ist.MBE.event) {
sewardje9d8a262009-07-01 08:06:34 +00003259 case Imbe_Fence:
sewardjc4356f02007-11-09 21:15:04 +00003260 break;
3261 default: sanityCheckFail(bb,stmt,"IRStmt.MBE.event: unknown");
3262 break;
3263 }
sewardj3e838932005-01-07 12:09:15 +00003264 break;
sewardj6efd4a12004-07-15 03:54:23 +00003265 case Ist_Exit:
sewardj0276d4b2004-11-15 15:30:21 +00003266 tcExpr( bb, stmt, stmt->Ist.Exit.guard, gWordTy );
3267 if (typeOfIRExpr(tyenv,stmt->Ist.Exit.guard) != Ity_I1)
3268 sanityCheckFail(bb,stmt,"IRStmt.Exit.guard: not :: Ity_I1");
sewardj49bfe672004-11-15 15:46:26 +00003269 if (!saneIRConst(stmt->Ist.Exit.dst))
3270 sanityCheckFail(bb,stmt,"IRStmt.Exit.dst: bad dst");
sewardj6efd4a12004-07-15 03:54:23 +00003271 if (typeOfIRConst(stmt->Ist.Exit.dst) != gWordTy)
3272 sanityCheckFail(bb,stmt,"IRStmt.Exit.dst: not :: guest word type");
3273 break;
3274 default:
3275 vpanic("tcStmt");
3276 }
3277}
3278
sewardjdd40fdf2006-12-24 02:20:24 +00003279void sanityCheckIRSB ( IRSB* bb, HChar* caller,
sewardjb9230752004-12-29 19:25:06 +00003280 Bool require_flat, IRType guest_word_size )
sewardj35439212004-07-14 22:36:10 +00003281{
3282 Int i;
3283 IRStmt* stmt;
3284 Int n_temps = bb->tyenv->types_used;
3285 Int* def_counts = LibVEX_Alloc(n_temps * sizeof(Int));
3286
sewardjb9230752004-12-29 19:25:06 +00003287 if (0)
3288 vex_printf("sanityCheck: %s\n", caller);
3289
sewardj35439212004-07-14 22:36:10 +00003290 vassert(guest_word_size == Ity_I32
sewardj695cff92004-10-13 14:50:14 +00003291 || guest_word_size == Ity_I64);
sewardj35439212004-07-14 22:36:10 +00003292
sewardjd7cb8532004-08-17 23:59:23 +00003293 if (bb->stmts_used < 0 || bb->stmts_size < 8
3294 || bb->stmts_used > bb->stmts_size)
3295 /* this BB is so strange we can't even print it */
sewardjdd40fdf2006-12-24 02:20:24 +00003296 vpanic("sanityCheckIRSB: stmts array limits wierd");
sewardjd7cb8532004-08-17 23:59:23 +00003297
sewardj6d2638e2004-07-15 09:38:27 +00003298 /* Ensure each temp has a plausible type. */
3299 for (i = 0; i < n_temps; i++) {
sewardj17442fe2004-09-20 14:54:28 +00003300 IRType ty = typeOfIRTemp(bb->tyenv,(IRTemp)i);
sewardj496a58d2005-03-20 18:44:44 +00003301 if (!isPlausibleIRType(ty)) {
sewardj6d2638e2004-07-15 09:38:27 +00003302 vex_printf("Temp t%d declared with implausible type 0x%x\n",
3303 i, (UInt)ty);
3304 sanityCheckFail(bb,NULL,"Temp declared with implausible type");
3305 }
3306 }
sewardj35439212004-07-14 22:36:10 +00003307
sewardjb9230752004-12-29 19:25:06 +00003308 /* Check for flatness, if required. */
3309 if (require_flat) {
3310 for (i = 0; i < bb->stmts_used; i++) {
3311 stmt = bb->stmts[i];
3312 if (!stmt)
sewardjd2445f62005-03-21 00:15:53 +00003313 sanityCheckFail(bb, stmt, "IRStmt: is NULL");
sewardjb9230752004-12-29 19:25:06 +00003314 if (!isFlatIRStmt(stmt))
3315 sanityCheckFail(bb, stmt, "IRStmt: is not flat");
3316 }
sewardj496a58d2005-03-20 18:44:44 +00003317 if (!isIRAtom(bb->next))
sewardjb9230752004-12-29 19:25:06 +00003318 sanityCheckFail(bb, NULL, "bb->next is not an atom");
3319 }
3320
sewardj35439212004-07-14 22:36:10 +00003321 /* Count the defs of each temp. Only one def is allowed.
3322 Also, check that each used temp has already been defd. */
sewardj6d2638e2004-07-15 09:38:27 +00003323
3324 for (i = 0; i < n_temps; i++)
3325 def_counts[i] = 0;
3326
sewardjd7cb8532004-08-17 23:59:23 +00003327 for (i = 0; i < bb->stmts_used; i++) {
sewardje9d8a262009-07-01 08:06:34 +00003328 IRDirty* d;
3329 IRCAS* cas;
sewardjd7cb8532004-08-17 23:59:23 +00003330 stmt = bb->stmts[i];
sewardje9d8a262009-07-01 08:06:34 +00003331 /* Check any temps used by this statement. */
sewardj35439212004-07-14 22:36:10 +00003332 useBeforeDef_Stmt(bb,stmt,def_counts);
sewardj17442fe2004-09-20 14:54:28 +00003333
sewardje9d8a262009-07-01 08:06:34 +00003334 /* Now make note of any temps defd by this statement. */
3335 switch (stmt->tag) {
3336 case Ist_WrTmp:
sewardjdd40fdf2006-12-24 02:20:24 +00003337 if (stmt->Ist.WrTmp.tmp < 0 || stmt->Ist.WrTmp.tmp >= n_temps)
sewardj17442fe2004-09-20 14:54:28 +00003338 sanityCheckFail(bb, stmt,
3339 "IRStmt.Tmp: destination tmp is out of range");
sewardjdd40fdf2006-12-24 02:20:24 +00003340 def_counts[stmt->Ist.WrTmp.tmp]++;
3341 if (def_counts[stmt->Ist.WrTmp.tmp] > 1)
sewardj17442fe2004-09-20 14:54:28 +00003342 sanityCheckFail(bb, stmt,
sewardjcf787902004-11-03 09:08:33 +00003343 "IRStmt.Tmp: destination tmp is assigned more than once");
sewardje9d8a262009-07-01 08:06:34 +00003344 break;
3345 case Ist_Store:
sewardje9d8a262009-07-01 08:06:34 +00003346 break;
3347 case Ist_Dirty:
3348 if (stmt->Ist.Dirty.details->tmp != IRTemp_INVALID) {
3349 d = stmt->Ist.Dirty.details;
3350 if (d->tmp < 0 || d->tmp >= n_temps)
3351 sanityCheckFail(bb, stmt,
3352 "IRStmt.Dirty: destination tmp is out of range");
3353 def_counts[d->tmp]++;
3354 if (def_counts[d->tmp] > 1)
3355 sanityCheckFail(bb, stmt,
3356 "IRStmt.Dirty: destination tmp is assigned more than once");
3357 }
3358 break;
3359 case Ist_CAS:
3360 cas = stmt->Ist.CAS.details;
sewardje9d8a262009-07-01 08:06:34 +00003361 if (cas->oldHi != IRTemp_INVALID) {
3362 if (cas->oldHi < 0 || cas->oldHi >= n_temps)
3363 sanityCheckFail(bb, stmt,
3364 "IRStmt.CAS: destination tmpHi is out of range");
3365 def_counts[cas->oldHi]++;
3366 if (def_counts[cas->oldHi] > 1)
3367 sanityCheckFail(bb, stmt,
3368 "IRStmt.CAS: destination tmpHi is assigned more than once");
3369 }
3370 if (cas->oldLo < 0 || cas->oldLo >= n_temps)
sewardje768e922009-11-26 17:17:37 +00003371 sanityCheckFail(bb, stmt,
3372 "IRStmt.CAS: destination tmpLo is out of range");
3373 def_counts[cas->oldLo]++;
3374 if (def_counts[cas->oldLo] > 1)
3375 sanityCheckFail(bb, stmt,
3376 "IRStmt.CAS: destination tmpLo is assigned more than once");
3377 break;
3378 case Ist_LLSC:
3379 if (stmt->Ist.LLSC.result < 0 || stmt->Ist.LLSC.result >= n_temps)
3380 sanityCheckFail(bb, stmt,
3381 "IRStmt.LLSC: destination tmp is out of range");
3382 def_counts[stmt->Ist.LLSC.result]++;
3383 if (def_counts[stmt->Ist.LLSC.result] > 1)
3384 sanityCheckFail(bb, stmt,
3385 "IRStmt.LLSC: destination tmp is assigned more than once");
3386 break;
sewardje9d8a262009-07-01 08:06:34 +00003387 default:
sewardje768e922009-11-26 17:17:37 +00003388 /* explicitly handle the rest, so as to keep gcc quiet */
3389 break;
sewardj35439212004-07-14 22:36:10 +00003390 }
3391 }
3392
sewardj6efd4a12004-07-15 03:54:23 +00003393 /* Typecheck everything. */
sewardjd7cb8532004-08-17 23:59:23 +00003394 for (i = 0; i < bb->stmts_used; i++)
sewardj39e3f242004-08-18 16:54:52 +00003395 if (bb->stmts[i])
3396 tcStmt( bb, bb->stmts[i], guest_word_size );
sewardj6efd4a12004-07-15 03:54:23 +00003397 if (typeOfIRExpr(bb->tyenv,bb->next) != guest_word_size)
3398 sanityCheckFail(bb, NULL, "bb->next field has wrong type");
sewardje539a402004-07-14 18:24:17 +00003399}
3400
sewardj4345f7a2004-09-22 19:49:27 +00003401/*---------------------------------------------------------------*/
3402/*--- Misc helper functions ---*/
3403/*---------------------------------------------------------------*/
3404
3405Bool eqIRConst ( IRConst* c1, IRConst* c2 )
3406{
3407 if (c1->tag != c2->tag)
3408 return False;
3409
3410 switch (c1->tag) {
sewardja98bf492005-02-07 01:39:17 +00003411 case Ico_U1: return toBool( (1 & c1->Ico.U1) == (1 & c2->Ico.U1) );
3412 case Ico_U8: return toBool( c1->Ico.U8 == c2->Ico.U8 );
3413 case Ico_U16: return toBool( c1->Ico.U16 == c2->Ico.U16 );
3414 case Ico_U32: return toBool( c1->Ico.U32 == c2->Ico.U32 );
3415 case Ico_U64: return toBool( c1->Ico.U64 == c2->Ico.U64 );
3416 case Ico_F64: return toBool( c1->Ico.F64 == c2->Ico.F64 );
sewardj0da5eb82007-01-27 00:46:28 +00003417 case Ico_F64i: return toBool( c1->Ico.F64i == c2->Ico.F64i );
3418 case Ico_V128: return toBool( c1->Ico.V128 == c2->Ico.V128 );
sewardj4345f7a2004-09-22 19:49:27 +00003419 default: vpanic("eqIRConst");
3420 }
3421}
3422
sewardjdd40fdf2006-12-24 02:20:24 +00003423Bool eqIRRegArray ( IRRegArray* descr1, IRRegArray* descr2 )
sewardje98dcf22004-10-04 09:15:11 +00003424{
sewardja98bf492005-02-07 01:39:17 +00003425 return toBool( descr1->base == descr2->base
3426 && descr1->elemTy == descr2->elemTy
3427 && descr1->nElems == descr2->nElems );
sewardje98dcf22004-10-04 09:15:11 +00003428}
3429
sewardj2d3f77c2004-09-22 23:49:09 +00003430Int sizeofIRType ( IRType ty )
3431{
3432 switch (ty) {
sewardjc9a43662004-11-30 18:51:59 +00003433 case Ity_I8: return 1;
3434 case Ity_I16: return 2;
3435 case Ity_I32: return 4;
3436 case Ity_I64: return 8;
3437 case Ity_F32: return 4;
3438 case Ity_F64: return 8;
3439 case Ity_V128: return 16;
sewardj2d3f77c2004-09-22 23:49:09 +00003440 default: vex_printf("\n"); ppIRType(ty); vex_printf("\n");
3441 vpanic("sizeofIRType");
3442 }
3443}
3444
sewardj49651f42004-10-28 22:11:04 +00003445IRExpr* mkIRExpr_HWord ( HWord hw )
3446{
sewardjf9655262004-10-31 20:02:16 +00003447 vassert(sizeof(void*) == sizeof(HWord));
sewardj49651f42004-10-28 22:11:04 +00003448 if (sizeof(HWord) == 4)
3449 return IRExpr_Const(IRConst_U32((UInt)hw));
3450 if (sizeof(HWord) == 8)
sewardjf9655262004-10-31 20:02:16 +00003451 return IRExpr_Const(IRConst_U64((ULong)hw));
sewardj49651f42004-10-28 22:11:04 +00003452 vpanic("mkIRExpr_HWord");
3453}
sewardj6efd4a12004-07-15 03:54:23 +00003454
sewardj2d49b432005-02-01 00:37:06 +00003455IRDirty* unsafeIRDirty_0_N ( Int regparms, HChar* name, void* addr,
sewardjf9655262004-10-31 20:02:16 +00003456 IRExpr** args )
3457{
3458 IRDirty* d = emptyIRDirty();
sewardjb8385d82004-11-02 01:34:15 +00003459 d->cee = mkIRCallee ( regparms, name, addr );
sewardjba999312004-11-15 15:21:17 +00003460 d->guard = IRExpr_Const(IRConst_U1(True));
sewardjb8385d82004-11-02 01:34:15 +00003461 d->args = args;
sewardjf9655262004-10-31 20:02:16 +00003462 return d;
3463}
3464
3465IRDirty* unsafeIRDirty_1_N ( IRTemp dst,
sewardj2d49b432005-02-01 00:37:06 +00003466 Int regparms, HChar* name, void* addr,
sewardjf9655262004-10-31 20:02:16 +00003467 IRExpr** args )
3468{
3469 IRDirty* d = emptyIRDirty();
sewardjb8385d82004-11-02 01:34:15 +00003470 d->cee = mkIRCallee ( regparms, name, addr );
sewardjba999312004-11-15 15:21:17 +00003471 d->guard = IRExpr_Const(IRConst_U1(True));
sewardjb8385d82004-11-02 01:34:15 +00003472 d->args = args;
3473 d->tmp = dst;
sewardjf9655262004-10-31 20:02:16 +00003474 return d;
3475}
3476
3477IRExpr* mkIRExprCCall ( IRType retty,
sewardj2d49b432005-02-01 00:37:06 +00003478 Int regparms, HChar* name, void* addr,
sewardjf9655262004-10-31 20:02:16 +00003479 IRExpr** args )
3480{
3481 return IRExpr_CCall ( mkIRCallee ( regparms, name, addr ),
3482 retty, args );
3483}
3484
sewardj496a58d2005-03-20 18:44:44 +00003485Bool eqIRAtom ( IRExpr* a1, IRExpr* a2 )
3486{
3487 vassert(isIRAtom(a1));
3488 vassert(isIRAtom(a2));
sewardjdd40fdf2006-12-24 02:20:24 +00003489 if (a1->tag == Iex_RdTmp && a2->tag == Iex_RdTmp)
3490 return toBool(a1->Iex.RdTmp.tmp == a2->Iex.RdTmp.tmp);
sewardj496a58d2005-03-20 18:44:44 +00003491 if (a1->tag == Iex_Const && a2->tag == Iex_Const)
3492 return eqIRConst(a1->Iex.Const.con, a2->Iex.Const.con);
3493 return False;
3494}
3495
sewardje539a402004-07-14 18:24:17 +00003496/*---------------------------------------------------------------*/
sewardjcef7d3e2009-07-02 12:21:59 +00003497/*--- end ir_defs.c ---*/
sewardj887a11a2004-07-05 17:26:47 +00003498/*---------------------------------------------------------------*/