Bug 476331 - clean up generated/distributed filter scripts
[valgrind.git] / VEX / priv / host_s390_defs.h
blob375cc8402af4ae0bca6e3c0eba5f085ef7f73323
1 /* -*- mode: C; c-basic-offset: 3; -*- */
3 /*---------------------------------------------------------------*/
4 /*--- begin host_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_HOST_S390_DEFS_H
32 #define __VEX_HOST_S390_DEFS_H
34 #include "libvex_basictypes.h" /* Bool */
35 #include "libvex.h" /* VexArchInfo */
36 #include "host_generic_regs.h" /* HReg */
37 #include "s390_defs.h" /* s390_cc_t */
39 /* --------- Registers --------- */
40 const HChar *s390_hreg_as_string(HReg);
41 HReg s390_hreg_gpr(UInt regno);
42 HReg s390_hreg_fpr(UInt regno);
43 HReg s390_hreg_vr(UInt regno);
45 /* Dedicated registers */
46 HReg s390_hreg_guest_state_pointer(void);
47 HReg s390_hreg_stack_pointer(void);
50 /* Given the index of a function argument, return the number of the
51 general purpose register in which it is being passed. Arguments are
52 counted 0, 1, 2, ... and they are being passed in r2, r3, r4, ... */
53 static __inline__ UInt
54 s390_gprno_from_arg_index(UInt ix)
56 return ix + 2;
59 /* --------- Memory address expressions (amodes). --------- */
61 /* These are the address modes:
62 (1) b12: base register + 12-bit unsigned offset (e.g. RS)
63 (2) b20: base register + 20-bit signed offset (e.g. RSY)
64 (3) bx12: base register + index register + 12-bit unsigned offset (e.g. RX)
65 (4) bx20: base register + index register + 20-bit signed offset (e.g. RXY)
66 fixs390: There is also pc-relative stuff.. e.g. LARL
69 typedef enum {
70 S390_AMODE_B12,
71 S390_AMODE_B20,
72 S390_AMODE_BX12,
73 S390_AMODE_BX20
74 } s390_amode_t;
76 typedef struct {
77 s390_amode_t tag;
78 HReg b;
79 HReg x; /* hregNumber(x) == 0 for S390_AMODE_B12/B20 kinds */
80 Int d; /* 12 bit unsigned or 20 bit signed */
81 } s390_amode;
84 s390_amode *s390_amode_b12(Int d, HReg b);
85 s390_amode *s390_amode_b20(Int d, HReg b);
86 s390_amode *s390_amode_bx12(Int d, HReg b, HReg x);
87 s390_amode *s390_amode_bx20(Int d, HReg b, HReg x);
88 s390_amode *s390_amode_for_guest_state(Int d);
89 s390_amode *s390_amode_for_stack_pointer(Int d);
90 Bool s390_amode_is_sane(const s390_amode *);
92 const HChar *s390_amode_as_string(const s390_amode *);
94 /* ------------- 2nd (right) operand of binary operation ---------------- */
96 typedef enum {
97 S390_OPND_REG,
98 S390_OPND_IMMEDIATE,
99 S390_OPND_AMODE
100 } s390_opnd_t;
103 /* Naming convention for operand locations:
104 R - GPR
105 I - immediate value
106 M - memory (any Amode may be used)
109 /* An operand that is either in a GPR or is addressable via a BX20 amode */
110 typedef struct {
111 s390_opnd_t tag;
112 union {
113 HReg reg;
114 s390_amode *am;
115 ULong imm;
116 } variant;
117 } s390_opnd_RMI;
120 /* The kind of instructions */
121 typedef enum {
122 S390_INSN_LOAD, /* load register from memory */
123 S390_INSN_STORE, /* store register to memory */
124 S390_INSN_MOVE, /* from register to register */
125 S390_INSN_MEMCPY, /* from memory to memory */
126 S390_INSN_COND_MOVE, /* conditonal "move" to register */
127 S390_INSN_LOAD_IMMEDIATE,
128 S390_INSN_ALU,
129 S390_INSN_SMUL, /* signed multiply; n-bit operands; 2n-bit result */
130 S390_INSN_UMUL, /* unsigned multiply; n-bit operands; 2n-bit result */
131 S390_INSN_SDIV, /* signed division; 2n-bit / n-bit -> n-bit quot/rem */
132 S390_INSN_UDIV, /* unsigned division; 2n-bit / n-bit -> n-bit quot/rem */
133 S390_INSN_DIVS, /* n-bit dividend; n-bit divisor; n-bit quot/rem */
134 S390_INSN_CLZ, /* count left-most zeroes */
135 S390_INSN_UNOP,
136 S390_INSN_TEST, /* test operand and set cc */
137 S390_INSN_CC2BOOL,/* convert condition code to 0/1 */
138 S390_INSN_COMPARE,
139 S390_INSN_HELPER_CALL,
140 S390_INSN_CAS, /* compare and swap */
141 S390_INSN_CDAS, /* compare double and swap */
142 S390_INSN_BFP_BINOP, /* Binary floating point */
143 S390_INSN_BFP_UNOP,
144 S390_INSN_BFP_TRIOP,
145 S390_INSN_BFP_COMPARE,
146 S390_INSN_BFP_CONVERT,
147 S390_INSN_DFP_BINOP, /* Decimal floating point */
148 S390_INSN_DFP_UNOP,
149 S390_INSN_DFP_INTOP,
150 S390_INSN_DFP_COMPARE,
151 S390_INSN_DFP_CONVERT,
152 S390_INSN_DFP_REROUND,
153 S390_INSN_FP_CONVERT,
154 S390_INSN_MFENCE,
155 S390_INSN_MIMM, /* Assign an immediate constant to a memory location */
156 S390_INSN_MADD, /* Add a value to a memory location */
157 S390_INSN_SET_FPC_BFPRM, /* Set the bfp rounding mode in the FPC */
158 S390_INSN_SET_FPC_DFPRM, /* Set the dfp rounding mode in the FPC */
159 /* The following 5 insns are mandated by translation chaining */
160 S390_INSN_XDIRECT, /* direct transfer to guest address */
161 S390_INSN_XINDIR, /* indirect transfer to guest address */
162 S390_INSN_XASSISTED, /* assisted transfer to guest address */
163 S390_INSN_EVCHECK, /* Event check */
164 S390_INSN_PROFINC, /* 64-bit profile counter increment */
165 S390_INSN_VEC_AMODEOP,
166 S390_INSN_VEC_AMODEINTOP,
167 S390_INSN_VEC_UNOP,
168 S390_INSN_VEC_BINOP,
169 S390_INSN_VEC_TRIOP,
170 S390_INSN_VEC_REPLICATE
171 } s390_insn_tag;
174 /* The kind of ALU instructions */
175 typedef enum {
176 S390_ALU_ADD,
177 S390_ALU_SUB,
178 S390_ALU_MUL, /* n-bit operands; result is lower n-bit of product */
179 S390_ALU_AND,
180 S390_ALU_OR,
181 S390_ALU_XOR,
182 S390_ALU_ILIH, /* insert low half of 2nd operand into high half of 1st
183 operand */
184 S390_ALU_LSH,
185 S390_ALU_RSH,
186 S390_ALU_RSHA /* arithmetic */
187 } s390_alu_t;
190 /* The kind of unary integer operations */
191 typedef enum {
192 S390_ZERO_EXTEND_8,
193 S390_ZERO_EXTEND_16,
194 S390_ZERO_EXTEND_32,
195 S390_SIGN_EXTEND_8,
196 S390_SIGN_EXTEND_16,
197 S390_SIGN_EXTEND_32,
198 S390_NEGATE,
199 S390_VEC_FILL,
200 S390_VEC_DUPLICATE,
201 S390_VEC_UNPACKLOWS,
202 S390_VEC_UNPACKLOWU,
203 S390_VEC_ABS,
204 S390_VEC_COUNT_LEADING_ZEROES,
205 S390_VEC_COUNT_TRAILING_ZEROES,
206 S390_VEC_COUNT_ONES,
207 S390_VEC_FLOAT_NEG,
208 S390_VEC_FLOAT_ABS,
209 S390_VEC_FLOAT_NABS,
210 S390_VEC_FLOAT_SQRT,
211 S390_UNOP_T_INVALID
212 } s390_unop_t;
214 /* The kind of ternary BFP operations */
215 typedef enum {
216 S390_BFP_MADD,
217 S390_BFP_MSUB,
218 } s390_bfp_triop_t;
220 /* The kind of binary BFP operations */
221 typedef enum {
222 S390_BFP_ADD,
223 S390_BFP_SUB,
224 S390_BFP_MUL,
225 S390_BFP_DIV
226 } s390_bfp_binop_t;
228 /* The kind of unary BFP operations */
229 typedef enum {
230 S390_BFP_ABS,
231 S390_BFP_NABS,
232 S390_BFP_NEG,
233 S390_BFP_SQRT
234 } s390_bfp_unop_t;
236 /* Type conversion operations: to and/or from binary floating point */
237 typedef enum {
238 S390_BFP_I32_TO_F32,
239 S390_BFP_I32_TO_F64,
240 S390_BFP_I32_TO_F128,
241 S390_BFP_I64_TO_F32,
242 S390_BFP_I64_TO_F64,
243 S390_BFP_I64_TO_F128,
244 S390_BFP_U32_TO_F32,
245 S390_BFP_U32_TO_F64,
246 S390_BFP_U32_TO_F128,
247 S390_BFP_U64_TO_F32,
248 S390_BFP_U64_TO_F64,
249 S390_BFP_U64_TO_F128,
250 S390_BFP_F32_TO_I32,
251 S390_BFP_F32_TO_I64,
252 S390_BFP_F32_TO_U32,
253 S390_BFP_F32_TO_U64,
254 S390_BFP_F32_TO_F64,
255 S390_BFP_F32_TO_F128,
256 S390_BFP_F64_TO_I32,
257 S390_BFP_F64_TO_I64,
258 S390_BFP_F64_TO_U32,
259 S390_BFP_F64_TO_U64,
260 S390_BFP_F64_TO_F32,
261 S390_BFP_F64_TO_F128,
262 S390_BFP_F128_TO_I32,
263 S390_BFP_F128_TO_I64,
264 S390_BFP_F128_TO_U32,
265 S390_BFP_F128_TO_U64,
266 S390_BFP_F128_TO_F32,
267 S390_BFP_F128_TO_F64,
268 S390_BFP_F32_TO_F32I,
269 S390_BFP_F64_TO_F64I,
270 S390_BFP_F128_TO_F128I
271 } s390_bfp_conv_t;
273 /* Type conversion operations: to and/or from decimal floating point */
274 typedef enum {
275 S390_DFP_D32_TO_D64,
276 S390_DFP_D64_TO_D32,
277 S390_DFP_D64_TO_D128,
278 S390_DFP_D128_TO_D64,
279 S390_DFP_I32_TO_D64,
280 S390_DFP_I32_TO_D128,
281 S390_DFP_I64_TO_D64,
282 S390_DFP_I64_TO_D128,
283 S390_DFP_U32_TO_D64,
284 S390_DFP_U32_TO_D128,
285 S390_DFP_U64_TO_D64,
286 S390_DFP_U64_TO_D128,
287 S390_DFP_D64_TO_I32,
288 S390_DFP_D64_TO_I64,
289 S390_DFP_D64_TO_U32,
290 S390_DFP_D64_TO_U64,
291 S390_DFP_D128_TO_I32,
292 S390_DFP_D128_TO_I64,
293 S390_DFP_D128_TO_U32,
294 S390_DFP_D128_TO_U64
295 } s390_dfp_conv_t;
297 typedef enum {
298 S390_FP_F32_TO_D32,
299 S390_FP_F32_TO_D64,
300 S390_FP_F32_TO_D128,
301 S390_FP_F64_TO_D32,
302 S390_FP_F64_TO_D64,
303 S390_FP_F64_TO_D128,
304 S390_FP_F128_TO_D32,
305 S390_FP_F128_TO_D64,
306 S390_FP_F128_TO_D128,
307 S390_FP_D32_TO_F32,
308 S390_FP_D32_TO_F64,
309 S390_FP_D32_TO_F128,
310 S390_FP_D64_TO_F32,
311 S390_FP_D64_TO_F64,
312 S390_FP_D64_TO_F128,
313 S390_FP_D128_TO_F32,
314 S390_FP_D128_TO_F64,
315 S390_FP_D128_TO_F128
316 } s390_fp_conv_t;
318 /* The kind of binary DFP operations */
319 typedef enum {
320 S390_DFP_ADD,
321 S390_DFP_SUB,
322 S390_DFP_MUL,
323 S390_DFP_DIV,
324 S390_DFP_QUANTIZE
325 } s390_dfp_binop_t;
327 /* The kind of unary DFP operations */
328 typedef enum {
329 S390_DFP_EXTRACT_EXP_D64,
330 S390_DFP_EXTRACT_EXP_D128,
331 S390_DFP_EXTRACT_SIG_D64,
332 S390_DFP_EXTRACT_SIG_D128,
333 } s390_dfp_unop_t;
335 /* The DFP operations with 2 operands one of them being integer */
336 typedef enum {
337 S390_DFP_SHIFT_LEFT,
338 S390_DFP_SHIFT_RIGHT,
339 S390_DFP_INSERT_EXP
340 } s390_dfp_intop_t;
342 /* The kind of DFP compare operations */
343 typedef enum {
344 S390_DFP_COMPARE,
345 S390_DFP_COMPARE_EXP,
346 } s390_dfp_cmp_t;
348 /* The vector operations with 2 operands one of them being amode */
349 typedef enum {
350 S390_VEC_GET_ELEM,
351 S390_VEC_ELEM_SHL_INT,
352 S390_VEC_ELEM_SHRA_INT,
353 S390_VEC_ELEM_SHRL_INT,
354 S390_VEC_AMODEOP_T_INVALID
355 } s390_vec_amodeop_t;
357 /* The vector operations with three (vector, amode and integer) operands */
358 typedef enum {
359 S390_VEC_SET_ELEM
360 } s390_vec_amodeintop_t;
362 /* The vector operations with two operands */
363 typedef enum {
364 S390_VEC_PACK,
365 S390_VEC_PACK_SATURS,
366 S390_VEC_PACK_SATURU,
367 S390_VEC_COMPARE_EQUAL,
368 S390_VEC_OR,
369 S390_VEC_ORC,
370 S390_VEC_XOR,
371 S390_VEC_AND,
372 S390_VEC_MERGEL,
373 S390_VEC_MERGEH,
374 S390_VEC_NOR,
375 S390_VEC_INT_ADD,
376 S390_VEC_INT_SUB,
377 S390_VEC_MAXU,
378 S390_VEC_MAXS,
379 S390_VEC_MINU,
380 S390_VEC_MINS,
381 S390_VEC_AVGU,
382 S390_VEC_AVGS,
383 S390_VEC_COMPARE_GREATERS,
384 S390_VEC_COMPARE_GREATERU,
385 S390_VEC_INT_MUL_HIGHS,
386 S390_VEC_INT_MUL_HIGHU,
387 S390_VEC_INT_MUL_LOW,
388 S390_VEC_INT_MUL_EVENS,
389 S390_VEC_INT_MUL_EVENU,
390 S390_VEC_ELEM_SHL_V,
391 S390_VEC_ELEM_SHRA_V,
392 S390_VEC_ELEM_SHRL_V,
393 S390_VEC_ELEM_ROLL_V,
395 /* host_s390_isel depends on this order. */
396 S390_VEC_SHL_BITS, S390_VEC_SHL_BYTES,
397 S390_VEC_SHRL_BITS, S390_VEC_SHRL_BYTES,
398 S390_VEC_SHRA_BITS, S390_VEC_SHRA_BYTES,
400 S390_VEC_PWSUM_W,
401 S390_VEC_PWSUM_DW,
402 S390_VEC_PWSUM_QW,
404 S390_VEC_INIT_FROM_GPRS,
405 S390_VEC_INIT_FROM_FPRS,
406 S390_VEC_FLOAT_ADD,
407 S390_VEC_FLOAT_SUB,
408 S390_VEC_FLOAT_MUL,
409 S390_VEC_FLOAT_DIV,
410 S390_VEC_FLOAT_COMPARE_EQUAL,
411 S390_VEC_FLOAT_COMPARE_LESS_OR_EQUAL,
412 S390_VEC_FLOAT_COMPARE_LESS,
413 S390_VEC_BINOP_T_INVALID
414 } s390_vec_binop_t;
416 /* The vector operations with three operands */
417 typedef enum {
418 S390_VEC_PERM,
419 S390_VEC_FLOAT_MADD,
420 S390_VEC_FLOAT_MSUB
421 } s390_vec_triop_t;
423 /* The details of a CDAS insn. Carved out to keep the size of
424 s390_insn low */
425 typedef struct {
426 HReg op1_high;
427 HReg op1_low;
428 s390_amode *op2;
429 HReg op3_high;
430 HReg op3_low;
431 HReg old_mem_high;
432 HReg old_mem_low;
433 HReg scratch;
434 } s390_cdas;
436 /* The details of a binary DFP insn. Carved out to keep the size of
437 s390_insn low */
438 typedef struct {
439 s390_dfp_binop_t tag;
440 s390_dfp_round_t rounding_mode;
441 HReg dst_hi; /* 128-bit result high part; 64-bit result */
442 HReg dst_lo; /* 128-bit result low part */
443 HReg op2_hi; /* 128-bit operand high part; 64-bit opnd 1 */
444 HReg op2_lo; /* 128-bit operand low part */
445 HReg op3_hi; /* 128-bit operand high part; 64-bit opnd 2 */
446 HReg op3_lo; /* 128-bit operand low part */
447 } s390_dfp_binop;
449 typedef struct {
450 s390_fp_conv_t tag;
451 s390_dfp_round_t rounding_mode;
452 HReg dst_hi; /* 128-bit result high part; 32/64-bit result */
453 HReg dst_lo; /* 128-bit result low part */
454 HReg op_hi; /* 128-bit operand high part; 32/64-bit opnd */
455 HReg op_lo; /* 128-bit operand low part */
456 HReg r1; /* clobbered register GPR #1 */
457 } s390_fp_convert;
459 /* Pseudo-insn for representing a helper call.
460 TARGET is the absolute address of the helper function
461 NUM_ARGS says how many arguments are being passed.
462 All arguments have integer type and are being passed according to ABI,
463 i.e. in registers r2, r3, r4, r5, and r6, with argument #0 being
464 passed in r2 and so forth. */
465 typedef struct {
466 s390_cc_t cond : 16;
467 UInt num_args : 16;
468 RetLoc rloc; /* where the return value will be */
469 Addr64 target;
470 const HChar *name; /* callee's name (for debugging) */
471 } s390_helper_call;
473 typedef struct {
474 s390_insn_tag tag;
475 /* Usually, this is the size of the result of an operation.
476 Exceptions are:
477 - for comparisons it is the size of the operand
479 UChar size;
480 union {
481 struct {
482 HReg dst;
483 s390_amode *src;
484 } load;
485 struct {
486 s390_amode *dst;
487 HReg src;
488 } store;
489 struct {
490 HReg dst;
491 HReg src;
492 } move;
493 struct {
494 s390_amode *dst;
495 s390_amode *src;
496 } memcpy;
497 struct {
498 s390_cc_t cond;
499 HReg dst;
500 s390_opnd_RMI src;
501 } cond_move;
502 struct {
503 HReg dst;
504 ULong value; /* not sign extended */
505 } load_immediate;
506 /* add, and, or, xor */
507 struct {
508 s390_alu_t tag;
509 HReg dst; /* op1 */
510 s390_opnd_RMI op2;
511 } alu;
512 struct {
513 HReg dst_hi; /* r10 */
514 HReg dst_lo; /* also op1 r11 */
515 s390_opnd_RMI op2;
516 } mul;
517 struct {
518 HReg op1_hi; /* also remainder r10 */
519 HReg op1_lo; /* also quotient r11 */
520 s390_opnd_RMI op2;
521 } div;
522 struct {
523 HReg rem; /* remainder r10 */
524 HReg op1; /* also quotient r11 */
525 s390_opnd_RMI op2;
526 } divs;
527 struct {
528 HReg num_bits; /* number of leftmost '0' bits r10 */
529 HReg clobber; /* unspecified r11 */
530 s390_opnd_RMI src;
531 } clz;
532 struct {
533 s390_unop_t tag;
534 HReg dst;
535 s390_opnd_RMI src;
536 } unop;
537 struct {
538 Bool signed_comparison;
539 HReg src1;
540 s390_opnd_RMI src2;
541 } compare;
542 struct {
543 s390_opnd_RMI src;
544 } test;
545 /* Convert the condition code to a boolean value. */
546 struct {
547 s390_cc_t cond;
548 HReg dst;
549 } cc2bool;
550 struct {
551 HReg op1;
552 s390_amode *op2;
553 HReg op3;
554 HReg old_mem;
555 } cas;
556 struct {
557 s390_cdas *details;
558 } cdas;
559 struct {
560 s390_helper_call *details;
561 } helper_call;
563 /* Floating point instructions (including conversion to/from floating
564 point
566 128-bit floating point requires register pairs. As the registers
567 in a register pair cannot be chosen independently it would suffice
568 to store only one register of the pair in order to represent it.
569 We chose not to do that as being explicit about all registers
570 helps with debugging and does not require special handling in
571 e.g. s390_insn_get_reg_usage, It'd be all too easy to forget about
572 the "other" register in a pair if it is implicit.
574 The convention for all fp s390_insn is that the _hi register will
575 be used to store the result / operand of a 32/64-bit operation.
576 The _hi register holds the 8 bytes of HIgher significance of a
577 128-bit value (hence the suffix). However, it is the lower numbered
578 register of a register pair. POP says that the lower numbered
579 register is used to identify the pair in an insn encoding. So,
580 when an insn is emitted, only the _hi registers need to be looked
581 at. Nothing special is needed for 128-bit BFP which is nice.
584 /* There are currently no ternary 128-bit BFP operations. */
585 struct {
586 s390_bfp_triop_t tag;
587 HReg dst;
588 HReg op2;
589 HReg op3;
590 } bfp_triop;
591 struct {
592 s390_bfp_binop_t tag;
593 HReg dst_hi; /* 128-bit result high part; 32/64-bit result */
594 HReg dst_lo; /* 128-bit result low part */
595 HReg op2_hi; /* 128-bit operand high part; 32/64-bit opnd */
596 HReg op2_lo; /* 128-bit operand low part */
597 } bfp_binop;
598 struct {
599 s390_bfp_unop_t tag;
600 HReg dst_hi; /* 128-bit result high part; 32/64-bit result */
601 HReg dst_lo; /* 128-bit result low part */
602 HReg op_hi; /* 128-bit operand high part; 32/64-bit opnd */
603 HReg op_lo; /* 128-bit operand low part */
604 } bfp_unop;
605 struct {
606 s390_bfp_conv_t tag;
607 s390_bfp_round_t rounding_mode;
608 HReg dst_hi; /* 128-bit result high part; 32/64-bit result */
609 HReg dst_lo; /* 128-bit result low part */
610 HReg op_hi; /* 128-bit operand high part; 32/64-bit opnd */
611 HReg op_lo; /* 128-bit operand low part */
612 } bfp_convert;
613 struct {
614 HReg dst; /* condition code in s390 encoding */
615 HReg op1_hi; /* 128-bit operand high part; 32/64-bit opnd */
616 HReg op1_lo; /* 128-bit operand low part */
617 HReg op2_hi; /* 128-bit operand high part; 32/64-bit opnd */
618 HReg op2_lo; /* 128-bit operand low part */
619 } bfp_compare;
620 struct {
621 s390_dfp_binop *details;
622 } dfp_binop;
623 struct {
624 s390_dfp_unop_t tag;
625 HReg dst_hi; /* 128-bit result high part; 64-bit result */
626 HReg dst_lo; /* 128-bit result low part */
627 HReg op_hi; /* 128-bit operand high part; 64-bit opnd */
628 HReg op_lo; /* 128-bit operand low part */
629 } dfp_unop;
630 struct {
631 s390_dfp_intop_t tag;
632 HReg dst_hi; /* 128-bit result high part; 64-bit result */
633 HReg dst_lo; /* 128-bit result low part */
634 HReg op2; /* integer operand */
635 HReg op3_hi; /* 128-bit operand high part; 64-bit opnd */
636 HReg op3_lo; /* 128-bit operand low part */
637 } dfp_intop;
638 struct {
639 s390_dfp_conv_t tag;
640 s390_dfp_round_t rounding_mode;
641 HReg dst_hi; /* 128-bit result high part; 64-bit result */
642 HReg dst_lo; /* 128-bit result low part */
643 HReg op_hi; /* 128-bit operand high part; 64-bit opnd */
644 HReg op_lo; /* 128-bit operand low part */
645 } dfp_convert;
646 struct {
647 s390_fp_convert *details;
648 } fp_convert;
649 struct {
650 s390_dfp_cmp_t tag;
651 HReg dst; /* condition code in s390 encoding */
652 HReg op1_hi; /* 128-bit operand high part; 64-bit opnd 1 */
653 HReg op1_lo; /* 128-bit operand low part */
654 HReg op2_hi; /* 128-bit operand high part; 64-bit opnd 2 */
655 HReg op2_lo; /* 128-bit operand low part */
656 } dfp_compare;
657 struct {
658 s390_dfp_round_t rounding_mode;
659 HReg dst_hi; /* 128-bit result high part; 64-bit result */
660 HReg dst_lo; /* 128-bit result low part */
661 HReg op2; /* integer operand */
662 HReg op3_hi; /* 128-bit operand high part; 64-bit opnd */
663 HReg op3_lo; /* 128-bit operand low part */
664 } dfp_reround;
666 /* Miscellaneous */
667 struct {
668 s390_amode *dst;
669 ULong value; /* sign extended */
670 } mimm;
671 struct {
672 s390_amode *dst;
673 UChar delta;
674 ULong value; /* for debugging only */
675 } madd;
676 struct {
677 HReg mode;
678 } set_fpc_bfprm;
679 struct {
680 HReg mode;
681 } set_fpc_dfprm;
683 /* The next 5 entries are generic to support translation chaining */
685 /* Update the guest IA value, then exit requesting to chain
686 to it. May be conditional. */
687 struct {
688 s390_cc_t cond;
689 Bool to_fast_entry; /* chain to the what entry point? */
690 Addr64 dst; /* next guest address */
691 s390_amode *guest_IA;
692 } xdirect;
693 /* Boring transfer to a guest address not known at JIT time.
694 Not chainable. May be conditional. */
695 struct {
696 s390_cc_t cond;
697 HReg dst;
698 s390_amode *guest_IA;
699 } xindir;
700 /* Assisted transfer to a guest address, most general case.
701 Not chainable. May be conditional. */
702 struct {
703 s390_cc_t cond;
704 IRJumpKind kind;
705 HReg dst;
706 s390_amode *guest_IA;
707 } xassisted;
708 struct {
709 /* fixs390: I don't think these are really needed
710 as the gsp and the offset are fixed no ? */
711 s390_amode *counter; /* dispatch counter */
712 s390_amode *fail_addr;
713 } evcheck;
714 struct {
715 /* No fields. The address of the counter to increment is
716 installed later, post-translation, by patching it in,
717 as it is not known at translation time. */
718 } profinc;
719 struct {
720 s390_vec_amodeop_t tag;
721 HReg dst; /* 64-bit result */
722 HReg op1; /* 128-bit operand */
723 s390_amode *op2; /* amode operand */
724 } vec_amodeop;
725 struct {
726 s390_vec_amodeintop_t tag;
727 HReg dst; /* 128-bit result */
728 s390_amode *op2; /* amode operand */
729 HReg op3; /* integer operand */
730 } vec_amodeintop;
731 struct {
732 s390_vec_binop_t tag;
733 HReg dst; /* 128-bit result */
734 HReg op1; /* 128-bit first operand */
735 HReg op2; /* 128-bit second operand */
736 } vec_binop;
737 struct {
738 s390_vec_triop_t tag;
739 HReg dst; /* 128-bit result */
740 HReg op1; /* 128-bit first operand */
741 HReg op2; /* 128-bit second operand */
742 HReg op3; /* 128-bit third operand */
743 } vec_triop;
744 struct {
745 HReg dst; /* 128-bit result */
746 HReg op1; /* 128-bit first operand */
747 UChar idx; /* index of element to replicate */
748 } vec_replicate;
749 } variant;
750 } s390_insn;
752 s390_insn *s390_insn_load(UChar size, HReg dst, s390_amode *src);
753 s390_insn *s390_insn_store(UChar size, s390_amode *dst, HReg src);
754 s390_insn *s390_insn_move(UChar size, HReg dst, HReg src);
755 s390_insn *s390_insn_memcpy(UChar size, s390_amode *dst, s390_amode *src);
756 s390_insn *s390_insn_cond_move(UChar size, s390_cc_t cond, HReg dst,
757 s390_opnd_RMI src);
758 s390_insn *s390_insn_load_immediate(UChar size, HReg dst, ULong val);
759 s390_insn *s390_insn_alu(UChar size, s390_alu_t, HReg dst,
760 s390_opnd_RMI op2);
761 s390_insn *s390_insn_mul(UChar size, HReg dst_hi, HReg dst_lo,
762 s390_opnd_RMI op2, Bool signed_multiply);
763 s390_insn *s390_insn_div(UChar size, HReg op1_hi, HReg op1_lo,
764 s390_opnd_RMI op2, Bool signed_divide);
765 s390_insn *s390_insn_divs(UChar size, HReg rem, HReg op1, s390_opnd_RMI op2);
766 s390_insn *s390_insn_clz(UChar size, HReg num_bits, HReg clobber,
767 s390_opnd_RMI op);
768 s390_insn *s390_insn_cas(UChar size, HReg op1, s390_amode *op2, HReg op3,
769 HReg old);
770 s390_insn *s390_insn_cdas(UChar size, HReg op1_high, HReg op1_low,
771 s390_amode *op2, HReg op3_high, HReg op3_low,
772 HReg old_high, HReg old_low, HReg scratch);
773 s390_insn *s390_insn_unop(UChar size, s390_unop_t tag, HReg dst,
774 s390_opnd_RMI opnd);
775 s390_insn *s390_insn_cc2bool(HReg dst, s390_cc_t src);
776 s390_insn *s390_insn_test(UChar size, s390_opnd_RMI src);
777 s390_insn *s390_insn_compare(UChar size, HReg dst, s390_opnd_RMI opnd,
778 Bool signed_comparison);
779 s390_insn *s390_insn_helper_call(s390_cc_t cond, Addr64 target, UInt num_args,
780 const HChar *name, RetLoc rloc);
781 s390_insn *s390_insn_bfp_triop(UChar size, s390_bfp_triop_t, HReg dst,
782 HReg op2, HReg op3);
783 s390_insn *s390_insn_bfp_binop(UChar size, s390_bfp_binop_t, HReg dst,
784 HReg op2);
785 s390_insn *s390_insn_bfp_unop(UChar size, s390_bfp_unop_t tag, HReg dst,
786 HReg op);
787 s390_insn *s390_insn_bfp_compare(UChar size, HReg dst, HReg op1, HReg op2);
788 s390_insn *s390_insn_bfp_convert(UChar size, s390_bfp_conv_t tag, HReg dst,
789 HReg op, s390_bfp_round_t);
790 s390_insn *s390_insn_bfp128_convert(UChar size, s390_bfp_conv_t tag, HReg dst_hi,
791 HReg dst_lo, HReg op_hi, HReg op_lo,
792 s390_bfp_round_t rounding_mode);
793 s390_insn *s390_insn_bfp128_binop(UChar size, s390_bfp_binop_t, HReg dst_hi,
794 HReg dst_lo, HReg op2_hi, HReg op2_lo);
795 s390_insn *s390_insn_bfp128_unop(UChar size, s390_bfp_unop_t, HReg dst_hi,
796 HReg dst_lo, HReg op_hi, HReg op_lo);
797 s390_insn *s390_insn_bfp128_compare(UChar size, HReg dst, HReg op1_hi,
798 HReg op1_lo, HReg op2_hi, HReg op2_lo);
799 s390_insn *s390_insn_bfp128_convert_to(UChar size, s390_bfp_conv_t,
800 HReg dst_hi, HReg dst_lo, HReg op);
801 s390_insn *s390_insn_bfp128_convert_from(UChar size, s390_bfp_conv_t,
802 HReg dst_hi, HReg dst_lo, HReg op_hi,
803 HReg op_lo, s390_bfp_round_t);
804 s390_insn *s390_insn_dfp_binop(UChar size, s390_dfp_binop_t, HReg dst,
805 HReg op2, HReg op3,
806 s390_dfp_round_t rounding_mode);
807 s390_insn *s390_insn_dfp_unop(UChar size, s390_dfp_unop_t, HReg dst, HReg op);
808 s390_insn *s390_insn_dfp_intop(UChar size, s390_dfp_intop_t, HReg dst,
809 HReg op2, HReg op3);
810 s390_insn *s390_insn_dfp_compare(UChar size, s390_dfp_cmp_t, HReg dst,
811 HReg op1, HReg op2);
812 s390_insn *s390_insn_dfp_convert(UChar size, s390_dfp_conv_t tag, HReg dst,
813 HReg op, s390_dfp_round_t);
814 s390_insn *s390_insn_dfp_reround(UChar size, HReg dst, HReg op2, HReg op3,
815 s390_dfp_round_t);
816 s390_insn *s390_insn_fp_convert(UChar size, s390_fp_conv_t tag,
817 HReg dst, HReg op, HReg r1, s390_dfp_round_t);
818 s390_insn *s390_insn_fp128_convert(UChar size, s390_fp_conv_t tag,
819 HReg dst_hi, HReg dst_lo, HReg op_hi,
820 HReg op_lo, HReg r1, s390_dfp_round_t);
821 s390_insn *s390_insn_dfp128_binop(UChar size, s390_dfp_binop_t, HReg dst_hi,
822 HReg dst_lo, HReg op2_hi, HReg op2_lo,
823 HReg op3_hi, HReg op3_lo,
824 s390_dfp_round_t rounding_mode);
825 s390_insn *s390_insn_dfp128_unop(UChar size, s390_dfp_unop_t, HReg dst,
826 HReg op_hi, HReg op_lo);
827 s390_insn *s390_insn_dfp128_intop(UChar size, s390_dfp_intop_t, HReg dst_hi,
828 HReg dst_lo, HReg op2,
829 HReg op3_hi, HReg op3_lo);
830 s390_insn *s390_insn_dfp128_compare(UChar size, s390_dfp_cmp_t, HReg dst,
831 HReg op1_hi, HReg op1_lo, HReg op2_hi,
832 HReg op2_lo);
833 s390_insn *s390_insn_dfp128_convert_to(UChar size, s390_dfp_conv_t,
834 HReg dst_hi, HReg dst_lo, HReg op);
835 s390_insn *s390_insn_dfp128_convert_from(UChar size, s390_dfp_conv_t,
836 HReg dst_hi, HReg dst_lo, HReg op_hi,
837 HReg op_lo, s390_dfp_round_t);
838 s390_insn *s390_insn_dfp128_reround(UChar size, HReg dst_hi, HReg dst_lo,
839 HReg op2, HReg op3_hi, HReg op3_lo,
840 s390_dfp_round_t);
841 s390_insn *s390_insn_mfence(void);
842 s390_insn *s390_insn_mimm(UChar size, s390_amode *dst, ULong value);
843 s390_insn *s390_insn_madd(UChar size, s390_amode *dst, UChar delta,
844 ULong value);
845 s390_insn *s390_insn_set_fpc_bfprm(UChar size, HReg mode);
846 s390_insn *s390_insn_set_fpc_dfprm(UChar size, HReg mode);
848 /* Five for translation chaining */
849 s390_insn *s390_insn_xdirect(s390_cc_t cond, Addr64 dst, s390_amode *guest_IA,
850 Bool to_fast_entry);
851 s390_insn *s390_insn_xindir(s390_cc_t cond, HReg dst, s390_amode *guest_IA);
852 s390_insn *s390_insn_xassisted(s390_cc_t cond, HReg dst, s390_amode *guest_IA,
853 IRJumpKind kind);
854 s390_insn *s390_insn_evcheck(s390_amode *counter, s390_amode *fail_addr);
855 s390_insn *s390_insn_profinc(void);
856 s390_insn *s390_insn_vec_amodeop(UChar size, s390_vec_amodeop_t, HReg dst,
857 HReg op1, s390_amode* op2);
858 s390_insn *s390_insn_vec_amodeintop(UChar size, s390_vec_amodeintop_t, HReg dst,
859 s390_amode* op2, HReg op3);
860 s390_insn *s390_insn_vec_binop(UChar size, s390_vec_binop_t, HReg dst, HReg op1,
861 HReg op2);
862 s390_insn *s390_insn_vec_triop(UChar size, s390_vec_triop_t, HReg dst, HReg op1,
863 HReg op2, HReg op3);
864 s390_insn *s390_insn_vec_replicate(UChar size, HReg dst, HReg op1, UChar idx);
866 const HChar *s390_insn_as_string(const s390_insn *);
868 /*--------------------------------------------------------*/
869 /* --- Interface exposed to VEX --- */
870 /*--------------------------------------------------------*/
872 void ppS390AMode(const s390_amode *);
873 void ppS390Instr(const s390_insn *, Bool mode64);
874 UInt ppHRegS390(HReg);
876 /* Some functions that insulate the register allocator from details
877 of the underlying instruction set. */
878 void getRegUsage_S390Instr( HRegUsage *, const s390_insn *, Bool );
879 void mapRegs_S390Instr ( HRegRemap *, s390_insn *, Bool );
880 Int emit_S390Instr ( Bool *, UChar *, Int, const s390_insn *, Bool,
881 VexEndness, const void *, const void *,
882 const void *, const void *);
883 const RRegUniverse *getRRegUniverse_S390( void );
884 void genSpill_S390 ( HInstr **, HInstr **, HReg , Int , Bool );
885 void genReload_S390 ( HInstr **, HInstr **, HReg , Int , Bool );
886 HInstr* directReload_S390 ( HInstr *, HReg, Short );
887 extern s390_insn* genMove_S390(HReg from, HReg to, Bool mode64);
888 HInstrArray *iselSB_S390 ( const IRSB *, VexArch, const VexArchInfo *,
889 const VexAbiInfo *, Int, Int, Bool, Bool, Addr);
891 /* Return the number of bytes of code needed for an event check */
892 Int evCheckSzB_S390(void);
894 /* Perform a chaining and unchaining of an XDirect jump. */
895 VexInvalRange chainXDirect_S390(VexEndness endness_host,
896 void *place_to_chain,
897 const void *disp_cp_chain_me_EXPECTED,
898 const void *place_to_jump_to);
900 VexInvalRange unchainXDirect_S390(VexEndness endness_host,
901 void *place_to_unchain,
902 const void *place_to_jump_to_EXPECTED,
903 const void *disp_cp_chain_me);
905 /* Patch the counter location into an existing ProfInc point. */
906 VexInvalRange patchProfInc_S390(VexEndness endness_host,
907 void *code_to_patch,
908 const ULong *location_of_counter);
910 /* KLUDGE: See detailled comment in host_s390_defs.c. */
911 extern UInt s390_host_hwcaps;
913 /* Convenience macros to test installed facilities */
914 #define s390_host_has_ldisp \
915 (s390_host_hwcaps & (VEX_HWCAPS_S390X_LDISP))
916 #define s390_host_has_eimm \
917 (s390_host_hwcaps & (VEX_HWCAPS_S390X_EIMM))
918 #define s390_host_has_gie \
919 (s390_host_hwcaps & (VEX_HWCAPS_S390X_GIE))
920 #define s390_host_has_dfp \
921 (s390_host_hwcaps & (VEX_HWCAPS_S390X_DFP))
922 #define s390_host_has_fgx \
923 (s390_host_hwcaps & (VEX_HWCAPS_S390X_FGX))
924 #define s390_host_has_etf2 \
925 (s390_host_hwcaps & (VEX_HWCAPS_S390X_ETF2))
926 #define s390_host_has_stfle \
927 (s390_host_hwcaps & (VEX_HWCAPS_S390X_STFLE))
928 #define s390_host_has_etf3 \
929 (s390_host_hwcaps & (VEX_HWCAPS_S390X_ETF3))
930 #define s390_host_has_stckf \
931 (s390_host_hwcaps & (VEX_HWCAPS_S390X_STCKF))
932 #define s390_host_has_fpext \
933 (s390_host_hwcaps & (VEX_HWCAPS_S390X_FPEXT))
934 #define s390_host_has_lsc \
935 (s390_host_hwcaps & (VEX_HWCAPS_S390X_LSC))
936 #define s390_host_has_pfpo \
937 (s390_host_hwcaps & (VEX_HWCAPS_S390X_PFPO))
938 #define s390_host_has_vx \
939 (s390_host_hwcaps & (VEX_HWCAPS_S390X_VX))
940 #define s390_host_has_msa5 \
941 (s390_host_hwcaps & (VEX_HWCAPS_S390X_MSA5))
942 #define s390_host_has_lsc2 \
943 (s390_host_hwcaps & (VEX_HWCAPS_S390X_LSC2))
944 #define s390_host_has_vxe \
945 (s390_host_hwcaps & (VEX_HWCAPS_S390X_VXE))
946 #endif /* ndef __VEX_HOST_S390_DEFS_H */
948 /*---------------------------------------------------------------*/
949 /*--- end host_s390_defs.h ---*/
950 /*---------------------------------------------------------------*/