1/* -*- mode: C; c-basic-offset: 3; -*- */
2
3/*---------------------------------------------------------------*/
4/*--- begin                                       s390_defs.h ---*/
5/*---------------------------------------------------------------*/
6
7/*
8   This file is part of Valgrind, a dynamic binary instrumentation
9   framework.
10
11   Copyright IBM Corp. 2010-2013
12
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.
17
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.
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
26   02110-1301, USA.
27
28   The GNU General Public License is contained in the file COPYING.
29*/
30
31#ifndef __VEX_S390_DEFS_H
32#define __VEX_S390_DEFS_H
33
34
35/* Condition code. The encoding of the enumerators matches the value of
36   the mask field in the various branch opcodes. */
37typedef enum {
38   S390_CC_NEVER  =  0,
39   S390_CC_OVFL   =  1,   /* overflow */
40   S390_CC_H      =  2,   /* A > B ; high */
41   S390_CC_NLE    =  3,   /* not low or equal */
42   S390_CC_L      =  4,   /* A < B ; low */
43   S390_CC_NHE    =  5,   /* not high or equal */
44   S390_CC_LH     =  6,   /* low or high */
45   S390_CC_NE     =  7,   /* A != B ; not zero */
46   S390_CC_E      =  8,   /* A == B ; zero */
47   S390_CC_NLH    =  9,   /* not low or high */
48   S390_CC_HE     = 10,   /* A >= B ; high or equal*/
49   S390_CC_NL     = 11,   /* not low */
50   S390_CC_LE     = 12,   /* A <= B ; low or equal */
51   S390_CC_NH     = 13,   /* not high */
52   S390_CC_NO     = 14,   /* not overflow */
53   S390_CC_ALWAYS = 15
54} s390_cc_t;
55
56
57/* Invert the condition code */
58static __inline__ s390_cc_t
59s390_cc_invert(s390_cc_t cond)
60{
61   return S390_CC_ALWAYS - cond;
62}
63
64
65/* BFP Rounding mode as it is encoded in the m3 field of certain
66   instructions (e.g. CFEBR) */
67typedef enum {
68   S390_BFP_ROUND_PER_FPC       = 0,
69   S390_BFP_ROUND_NEAREST_AWAY  = 1,
70   /* 2 is not allowed */
71   S390_BFP_ROUND_PREPARE_SHORT = 3,
72   S390_BFP_ROUND_NEAREST_EVEN  = 4,
73   S390_BFP_ROUND_ZERO          = 5,
74   S390_BFP_ROUND_POSINF        = 6,
75   S390_BFP_ROUND_NEGINF        = 7
76} s390_bfp_round_t;
77
78
79/* BFP Rounding mode as it is encoded in bits [29:31] of the FPC register.
80   Only rounding modes 0..3 are universally supported. Others require
81   additional hardware facilities. */
82typedef enum {
83   S390_FPC_BFP_ROUND_NEAREST_EVEN  = 0,
84   S390_FPC_BFP_ROUND_ZERO          = 1,
85   S390_FPC_BFP_ROUND_POSINF        = 2,
86   S390_FPC_BFP_ROUND_NEGINF        = 3,
87   /* 4,5,6 are not allowed */
88   S390_FPC_BFP_ROUND_PREPARE_SHORT = 7 /* floating point extension facility */
89} s390_fpc_bfp_round_t;
90
91
92/* DFP Rounding mode as it is encoded in the m3 field of certain
93   instructions (e.g. CGDTR) */
94typedef enum {
95   S390_DFP_ROUND_PER_FPC_0             = 0,
96   S390_DFP_ROUND_NEAREST_TIE_AWAY_0_1  = 1,
97   S390_DFP_ROUND_PER_FPC_2             = 2,
98   S390_DFP_ROUND_PREPARE_SHORT_3       = 3,
99   S390_DFP_ROUND_NEAREST_EVEN_4        = 4,
100   S390_DFP_ROUND_ZERO_5                = 5,
101   S390_DFP_ROUND_POSINF_6              = 6,
102   S390_DFP_ROUND_NEGINF_7              = 7,
103   S390_DFP_ROUND_NEAREST_EVEN_8        = 8,
104   S390_DFP_ROUND_ZERO_9                = 9,
105   S390_DFP_ROUND_POSINF_10             = 10,
106   S390_DFP_ROUND_NEGINF_11             = 11,
107   S390_DFP_ROUND_NEAREST_TIE_AWAY_0_12 = 12,
108   S390_DFP_ROUND_NEAREST_TIE_TOWARD_0  = 13,
109   S390_DFP_ROUND_AWAY_0                = 14,
110   S390_DFP_ROUND_PREPARE_SHORT_15      = 15
111} s390_dfp_round_t;
112
113
114/* DFP Rounding mode as it is encoded in bits [25:27] of the FPC register. */
115typedef enum {
116   S390_FPC_DFP_ROUND_NEAREST_EVEN     = 0,
117   S390_FPC_DFP_ROUND_ZERO             = 1,
118   S390_FPC_DFP_ROUND_POSINF           = 2,
119   S390_FPC_DFP_ROUND_NEGINF           = 3,
120   S390_FPC_DFP_ROUND_NEAREST_AWAY_0   = 4,
121   S390_FPC_DFP_ROUND_NEAREST_TOWARD_0 = 5,
122   S390_FPC_DFP_ROUND_AWAY_ZERO        = 6,
123   S390_FPC_DFP_ROUND_PREPARE_SHORT    = 7
124} s390_fpc_dfp_round_t;
125
126/* PFPO function code as it is encoded in bits [33:55] of GR0
127   when PFPO insn is executed. */
128typedef enum {
129   S390_PFPO_F32_TO_D32   = 0x010805,
130   S390_PFPO_F32_TO_D64   = 0x010905,
131   S390_PFPO_F32_TO_D128  = 0x010A05,
132   S390_PFPO_F64_TO_D32   = 0x010806,
133   S390_PFPO_F64_TO_D64   = 0x010906,
134   S390_PFPO_F64_TO_D128  = 0x010A06,
135   S390_PFPO_F128_TO_D32  = 0x010807,
136   S390_PFPO_F128_TO_D64  = 0x010907,
137   S390_PFPO_F128_TO_D128 = 0x010A07,
138   S390_PFPO_D32_TO_F32   = 0x010508,
139   S390_PFPO_D32_TO_F64   = 0x010608,
140   S390_PFPO_D32_TO_F128  = 0x010708,
141   S390_PFPO_D64_TO_F32   = 0x010509,
142   S390_PFPO_D64_TO_F64   = 0x010609,
143   S390_PFPO_D64_TO_F128  = 0x010709,
144   S390_PFPO_D128_TO_F32  = 0x01050A,
145   S390_PFPO_D128_TO_F64  = 0x01060A,
146   S390_PFPO_D128_TO_F128 = 0x01070A
147} s390_pfpo_function_t;
148
149/* The length of the longest mnemonic: locgrnhe */
150#define S390_MAX_MNEMONIC_LEN  8
151
152
153/*---------------------------------------------------------------*/
154/*--- end                                         s390_defs.h ---*/
155/*---------------------------------------------------------------*/
156
157#endif /* __VEX_S390_DEFS_H */
158