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