Bug 497723 - forgot to restore callgrind output cleanup
[valgrind.git] / VEX / priv / guest_s390_defs.h
bloba64d563ec9e69a4fe9789db155e860e29fb1850c
1 /* -*- mode: C; c-basic-offset: 3; -*- */
3 /*---------------------------------------------------------------*/
4 /*--- begin guest_s390_defs.h ---*/
5 /*---------------------------------------------------------------*/
7 /*
8 This file is part of Valgrind, a dynamic binary instrumentation
9 framework.
11 Copyright IBM Corp. 2010-2020
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
29 /* Contributed by Florian Krohm */
31 #ifndef __VEX_GUEST_S390_DEFS_H
32 #define __VEX_GUEST_S390_DEFS_H
34 #include "libvex_basictypes.h" // offsetof
35 #include "guest_generic_bb_to_IR.h" // DisResult
36 #include "libvex_guest_s390x.h" // VexGuestS390XState
39 /* Convert one s390 insn to IR. See the type DisOneInstrFn in
40 guest_generic_bb_to_IR.h. */
41 DisResult disInstr_S390 ( IRSB* irbb,
42 const UChar* guest_code,
43 Long delta,
44 Addr guest_IP,
45 VexArch guest_arch,
46 const VexArchInfo* archinfo,
47 const VexAbiInfo* abiinfo,
48 VexEndness host_endness,
49 Bool sigill_diag );
51 /* Used by the optimiser to specialise calls to helpers. */
52 IRExpr* guest_s390x_spechelper ( const HChar *function_name,
53 IRExpr **args,
54 IRStmt **precedingStmts,
55 Int n_precedingStmts);
58 /* Describes to the optimiser which part of the guest state require
59 precise memory exceptions. This is logically part of the guest
60 state description. */
61 Bool guest_s390x_state_requires_precise_mem_exns ( Int, Int,
62 VexRegisterUpdates );
64 extern VexGuestLayout s390xGuest_layout;
67 #define S390X_GUEST_OFFSET(x) offsetof(VexGuestS390XState, x)
69 /*------------------------------------------------------------*/
70 /*--- Helper functions. ---*/
71 /*------------------------------------------------------------*/
72 void s390x_dirtyhelper_EX(ULong torun, Addr64 addr);
73 ULong s390x_dirtyhelper_STCK(ULong *addr);
74 ULong s390x_dirtyhelper_STCKF(ULong *addr);
75 ULong s390x_dirtyhelper_STCKE(ULong *addr);
76 void s390x_dirtyhelper_CUxy(UChar *addr, ULong data, ULong num_bytes);
77 ULong s390x_dirtyhelper_vec_op(VexGuestS390XState *guest_state,
78 ULong details);
79 ULong s390_do_cu12_cu14_helper1(UInt byte1, UInt etf3_and_m3_is_1);
80 ULong s390_do_cu12_helper2(UInt byte1, UInt byte2, UInt byte3, UInt byte4,
81 ULong stuff);
82 ULong s390_do_cu14_helper2(UInt byte1, UInt byte2, UInt byte3, UInt byte4,
83 ULong stuff);
84 ULong s390_do_cu21(UInt srcvalue, UInt low_surrogate);
85 ULong s390_do_cu24(UInt srcvalue, UInt low_surrogate);
86 ULong s390_do_cu41(UInt srcvalue);
87 ULong s390_do_cu42(UInt srcvalue);
88 UInt s390_do_cvb(ULong decimal);
89 ULong s390_do_cvd(ULong binary);
90 ULong s390_do_ecag(ULong op2addr);
91 UInt s390_do_pfpo(UInt gpr0);
92 void s390x_dirtyhelper_PPNO_query(VexGuestS390XState *guest_state, ULong r1, ULong r2);
93 ULong s390x_dirtyhelper_PPNO_sha512(VexGuestS390XState *guest_state, ULong r1, ULong r2);
94 void s390x_dirtyhelper_PPNO_sha512_load_param_block( void );
95 /* The various ways to compute the condition code. */
96 enum {
97 S390_CC_OP_BITWISE = 0,
98 S390_CC_OP_SIGNED_COMPARE = 1,
99 S390_CC_OP_UNSIGNED_COMPARE = 2,
100 S390_CC_OP_SIGNED_ADD_32 = 3,
101 S390_CC_OP_SIGNED_ADD_64 = 4,
102 S390_CC_OP_UNSIGNED_ADD_32 = 5,
103 S390_CC_OP_UNSIGNED_ADD_64 = 6,
104 S390_CC_OP_UNSIGNED_ADDC_32 = 7,
105 S390_CC_OP_UNSIGNED_ADDC_64 = 8,
106 S390_CC_OP_SIGNED_SUB_32 = 9,
107 S390_CC_OP_SIGNED_SUB_64 = 10,
108 S390_CC_OP_UNSIGNED_SUB_32 = 11,
109 S390_CC_OP_UNSIGNED_SUB_64 = 12,
110 S390_CC_OP_UNSIGNED_SUBB_32 = 13,
111 S390_CC_OP_UNSIGNED_SUBB_64 = 14,
112 S390_CC_OP_LOAD_AND_TEST = 15,
113 S390_CC_OP_LOAD_POSITIVE_32 = 16,
114 S390_CC_OP_LOAD_POSITIVE_64 = 17,
115 S390_CC_OP_TEST_UNDER_MASK_8 = 18,
116 S390_CC_OP_TEST_UNDER_MASK_16 = 19,
117 S390_CC_OP_SHIFT_LEFT_32 = 20,
118 S390_CC_OP_SHIFT_LEFT_64 = 21,
119 S390_CC_OP_INSERT_CHAR_MASK_32 = 22,
120 S390_CC_OP_BFP_RESULT_32 = 23,
121 S390_CC_OP_BFP_RESULT_64 = 24,
122 S390_CC_OP_BFP_RESULT_128 = 25,
123 S390_CC_OP_BFP_32_TO_INT_32 = 26,
124 S390_CC_OP_BFP_64_TO_INT_32 = 27,
125 S390_CC_OP_BFP_128_TO_INT_32 = 28,
126 S390_CC_OP_BFP_32_TO_INT_64 = 29,
127 S390_CC_OP_BFP_64_TO_INT_64 = 30,
128 S390_CC_OP_BFP_128_TO_INT_64 = 31,
129 S390_CC_OP_BFP_TDC_32 = 32,
130 S390_CC_OP_BFP_TDC_64 = 33,
131 S390_CC_OP_BFP_TDC_128 = 34,
132 S390_CC_OP_SET = 35,
133 S390_CC_OP_BFP_32_TO_UINT_32 = 36,
134 S390_CC_OP_BFP_64_TO_UINT_32 = 37,
135 S390_CC_OP_BFP_128_TO_UINT_32 = 38,
136 S390_CC_OP_BFP_32_TO_UINT_64 = 39,
137 S390_CC_OP_BFP_64_TO_UINT_64 = 40,
138 S390_CC_OP_BFP_128_TO_UINT_64 = 41,
139 S390_CC_OP_DFP_RESULT_64 = 42,
140 S390_CC_OP_DFP_RESULT_128 = 43,
141 S390_CC_OP_DFP_TDC_32 = 44,
142 S390_CC_OP_DFP_TDC_64 = 45,
143 S390_CC_OP_DFP_TDC_128 = 46,
144 S390_CC_OP_DFP_TDG_32 = 47,
145 S390_CC_OP_DFP_TDG_64 = 48,
146 S390_CC_OP_DFP_TDG_128 = 49,
147 S390_CC_OP_DFP_64_TO_UINT_32 = 50,
148 S390_CC_OP_DFP_128_TO_UINT_32 = 51,
149 S390_CC_OP_DFP_64_TO_UINT_64 = 52,
150 S390_CC_OP_DFP_128_TO_UINT_64 = 53,
151 S390_CC_OP_DFP_64_TO_INT_32 = 54,
152 S390_CC_OP_DFP_128_TO_INT_32 = 55,
153 S390_CC_OP_DFP_64_TO_INT_64 = 56,
154 S390_CC_OP_DFP_128_TO_INT_64 = 57,
155 S390_CC_OP_PFPO_32 = 58,
156 S390_CC_OP_PFPO_64 = 59,
157 S390_CC_OP_PFPO_128 = 60,
158 S390_CC_OP_MUL_32 = 61,
159 S390_CC_OP_MUL_64 = 62
162 /*------------------------------------------------------------*/
163 /*--- Thunk layout ---*/
164 /*------------------------------------------------------------*/
167 Z -- value is zero extended to 32 / 64 bit
168 S -- value is sign extended to 32 / 64 bit
169 F -- a binary floating point value
170 D -- a decimal floating point value
172 +--------------------------------+-----------------------+----------------------+-----------------+
173 | op | cc_dep1 | cc_dep2 | cc_ndep |
174 +--------------------------------+-----------------------+----------------------+-----------------+
175 | S390_CC_OP_BITWISE | Z result | | |
176 | S390_CC_OP_SIGNED_COMPARE | S 1st operand | S 2nd operand | |
177 | S390_CC_OP_UNSIGNED_COMPARE | Z 1st operand | Z 2nd operand | |
178 | S390_CC_OP_SIGNED_ADD_32 | S 1st operand | S 2nd operand | |
179 | S390_CC_OP_SIGNED_ADD_64 | S 1st operand | S 2nd operand | |
180 | S390_CC_OP_UNSIGNED_ADD_32 | Z 1st operand | Z 2nd operand | |
181 | S390_CC_OP_UNSIGNED_ADD_64 | Z 1st operand | Z 2nd operand | |
182 | S390_CC_OP_UNSIGNED_ADDC_32 | Z 1st operand | Z 2nd operand | Z carry in |
183 | S390_CC_OP_UNSIGNED_ADDC_64 | Z 1st operand | Z 2nd operand | Z carry in |
184 | S390_CC_OP_SIGNED_SUB_32 | S left operand | S right operand | |
185 | S390_CC_OP_SIGNED_SUB_64 | S left operand | S right operand | |
186 | S390_CC_OP_UNSIGNED_SUB_32 | Z left operand | Z right operand | |
187 | S390_CC_OP_UNSIGNED_SUB_64 | Z left operand | Z right operand | |
188 | S390_CC_OP_UNSIGNED_SUBB_32 | Z left operand | Z right operand | Z borrow in |
189 | S390_CC_OP_UNSIGNED_SUBB_64 | Z left operand | Z right operand | Z borrow in |
190 | S390_CC_OP_LOAD_AND_TEST | S loaded value | | |
191 | S390_CC_OP_LOAD_POSITIVE_32 | S loaded value | | |
192 | S390_CC_OP_LOAD_POSITIVE_64 | S loaded value | | |
193 | S390_CC_OP_TEST_UNDER_MASK_8 | Z tested value | Z mask | |
194 | S390_CC_OP_TEST_UNDER_MASK_16 | Z tested value | Z mask | |
195 | S390_CC_OP_SHIFT_LEFT_32 | Z value to be shifted | Z shift amount | |
196 | S390_CC_OP_SHIFT_LEFT_64 | Z value to be shifted | Z shift amount | |
197 | S390_CC_OP_INSERT_CHAR_MASK_32 | Z result | Z mask | |
198 | S390_CC_OP_BFP_RESULT_32 | F result | | |
199 | S390_CC_OP_BFP_RESULT_64 | F result | | |
200 | S390_CC_OP_BFP_RESULT_128 | F result hi 64 bits | F result low 64 bits | |
201 | S390_CC_OP_BFP_32_TO_INT_32 | F source | Z rounding mode | |
202 | S390_CC_OP_BFP_64_TO_INT_32 | F source | Z rounding mode | |
203 | S390_CC_OP_BFP_128_TO_INT_32 | F source hi 64 bits | F source low 64 bits | Z rounding mode |
204 | S390_CC_OP_BFP_32_TO_INT_64 | F source | Z rounding mode | |
205 | S390_CC_OP_BFP_64_TO_INT_64 | F source | Z rounding mode | |
206 | S390_CC_OP_BFP_128_TO_INT_64 | F source hi 64 bits | F source low 64 bits | Z rounding mode |
207 | S390_CC_OP_BFP_TDC_32 | F value | Z class | |
208 | S390_CC_OP_BFP_TDC_64 | F value | Z class | |
209 | S390_CC_OP_BFP_TDC_128 | F value hi 64 bits | F value low 64 bits | Z class |
210 | S390_CC_OP_SET | Z condition code | | |
211 | S390_CC_OP_BFP_32_TO_UINT_32 | F source | Z rounding mode | |
212 | S390_CC_OP_BFP_64_TO_UINT_32 | F source | Z rounding mode | |
213 | S390_CC_OP_BFP_128_TO_UINT_32 | F source hi 64 bits | F source low 64 bits | Z rounding mode |
214 | S390_CC_OP_BFP_32_TO_UINT_64 | F source | Z rounding mode | |
215 | S390_CC_OP_BFP_64_TO_UINT_64 | F source | Z rounding mode | |
216 | S390_CC_OP_BFP_128_TO_UINT_64 | F source hi 64 bits | F source low 64 bits | Z rounding mode |
217 | S390_CC_OP_DFP_RESULT_64 | D result | | |
218 | S390_CC_OP_DFP_RESULT_128 | D result hi 64 bits | D result low 64 bits | |
219 | S390_CC_OP_DFP_TDC_32 | D value | Z class | |
220 | S390_CC_OP_DFP_TDC_64 | D value | Z class | |
221 | S390_CC_OP_DFP_TDC_128 | D value hi 64 bits | D value low 64 bits | Z class |
222 | S390_CC_OP_DFP_TDG_32 | D value | Z group | |
223 | S390_CC_OP_DFP_TDG_64 | D value | Z group | |
224 | S390_CC_OP_DFP_TDG_128 | D value hi 64 bits | D value low 64 bits | Z group |
225 | S390_CC_OP_DFP_64_TO_UINT_32 | D source | Z rounding mode | |
226 | S390_CC_OP_DFP_128_TO_UINT_32 | D source hi 64 bits | D source low 64 bits | Z rounding mode |
227 | S390_CC_OP_DFP_64_TO_UINT_64 | D source | Z rounding mode | |
228 | S390_CC_OP_DFP_128_TO_UINT_64 | D source hi 64 bits | D source low 64 bits | Z rounding mode |
229 | S390_CC_OP_DFP_64_TO_INT_32 | D source | Z rounding mode | |
230 | S390_CC_OP_DFP_128_TO_INT_32 | D source hi 64 bits | D source low 64 bits | Z rounding mode |
231 | S390_CC_OP_DFP_64_TO_INT_64 | D source | Z rounding mode | |
232 | S390_CC_OP_DFP_128_TO_INT_64 | D source hi 64 bits | D source low 64 bits | Z rounding mode |
233 | S390_CC_OP_PFPO_32 | F|D source | Z GR0 low 32 bits | |
234 | S390_CC_OP_PFPO_64 | F|D source | Z GR0 low 32 bits | |
235 | S390_CC_OP_PFPO_128 | F|D source hi 64 bits | F|D src low 64 bits | Z GR0 low 32 bits |
236 +--------------------------------+-----------------------+----------------------+-----------------+
239 /*------------------------------------------------------------*/
240 /*--- Condition code helpers. ---*/
241 /*------------------------------------------------------------*/
242 UInt s390_calculate_cc(ULong cc_op, ULong cc_dep1, ULong cc_dep2,
243 ULong cc_ndep);
244 UInt s390_calculate_cond(ULong mask, ULong op, ULong dep1, ULong dep2,
245 ULong ndep);
247 /* Size of special instruction preamble */
248 #define S390_SPECIAL_OP_PREAMBLE_SIZE 8
250 /* Size of special instructions */
251 #define S390_SPECIAL_OP_SIZE 2
253 /* Last target instruction for the EX helper */
254 extern ULong last_execute_target;
256 /* Base for relative addressing while processing EX */
257 extern Addr64 guest_IA_rel_base;
259 /*------------------------------------------------------------*/
260 /*--- Vector helpers. ---*/
261 /*------------------------------------------------------------*/
263 /* Vector operatons passed to s390x_dirtyhelper_vec_op(...) helper.
264 Please don't change ordering of elements and append new items
265 before S390_VEC_OP_LAST. */
266 typedef enum {
267 S390_VEC_OP_INVALID = 0,
268 S390_VEC_OP_VPKS,
269 S390_VEC_OP_VPKLS,
270 S390_VEC_OP_VCEQ,
271 S390_VEC_OP_VTM,
272 S390_VEC_OP_VGFM,
273 S390_VEC_OP_VGFMA,
274 S390_VEC_OP_VMAH,
275 S390_VEC_OP_VMALH,
276 S390_VEC_OP_VCH,
277 S390_VEC_OP_VCHL,
278 S390_VEC_OP_VFTCI,
279 S390_VEC_OP_VFMIN,
280 S390_VEC_OP_VFMAX,
281 S390_VEC_OP_VBPERM,
282 S390_VEC_OP_VMSL,
283 S390_VEC_OP_VCNF,
284 S390_VEC_OP_VCLFNH,
285 S390_VEC_OP_VCFN,
286 S390_VEC_OP_VCLFNL,
287 S390_VEC_OP_VCRNF,
288 S390_VEC_OP_LAST // supposed to be the last element in enum
289 } s390x_vec_op_t;
291 /* Arguments of s390x_dirtyhelper_vec_op(...) which are packed into one
292 ULong variable.
294 typedef union {
295 struct {
296 unsigned int op : 8; // should be an element of s390x_vec_op_t
297 unsigned int v1 : 5; // result of operation
298 unsigned int v2 : 5; // argument one of operation
299 unsigned int v3 : 5; // argument two of operation or
300 // zero for unary operations
302 unsigned int v4 : 5; // argument two of operation or
303 // zero for unary and binary operations
305 unsigned int m3 : 4; // field m3 of insn or zero if it's missing
306 unsigned int m4 : 4; // field m4 of insn or zero if it's missing
307 unsigned int m5 : 4; // field m5 of insn or zero if it's missing
308 unsigned int m6 : 4; // field m6 of insn or zero if it's missing
309 unsigned int i3 : 12; // field i3 of insn or zero if it's missing
310 unsigned int read_only: 1; // don't write result to Guest State
311 unsigned int reserved : 7; // reserved for future
313 ULong serialized;
314 } s390x_vec_op_details_t;
316 STATIC_ASSERT(sizeof(s390x_vec_op_details_t) == sizeof(ULong));
318 /* Macro definitions for opcodes that are not generally available.
320 The values to be encoded in those fields must be integer values in
321 hexadecimal notation without a leading 0x.
322 E.g. VRX_VXBD(e7, 1, 0, 3, 0000, 0, 06) is equal to "vl %%v1, 0(%%r3)\n\t"
324 #define VRX_VXBD(op1, v1, x2, b2, d2, rxb, op2) \
325 ".short 0x" #op1 #v1 #x2 "\n\t .int 0x" #b2 #d2 "0" #rxb #op2 "\n\t"
326 #define VRR_VVVMM(op1, v1, v2, v3, m5, m4, rxb, op2) \
327 ".short 0x" #op1 #v1 #v2 "\n\t .int 0x" #v3 "0" #m5 "0" #m4 #rxb #op2 "\n\t"
329 #define VL(v1, x2, b2, d2, rxb) VRX_VXBD(e7, v1, x2, b2, d2, rxb, 06)
330 #define VST(v1, x2, b2, d2, rxb) VRX_VXBD(e7, v1, x2, b2, d2, rxb, 0e)
331 #define VPKS(v1, v2, v3, m4, m5, rxb) VRR_VVVMM(e7, v1, v2, v3, m5, m4, rxb, 97)
332 #define VPKLS(v1, v2, v3, m4, m5, rxb) VRR_VVVMM(e7, v1, v2, v3, m5, m4, rxb, 95)
335 /*---------------------------------------------------------------*/
336 /*--- end guest_s390_defs.h ---*/
337 /*---------------------------------------------------------------*/
339 #endif /* __VEX_GUEST_S390_DEFS_H */