]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - sim/common/sim-types.h
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / sim / common / sim-types.h
1 /* The common simulator framework for GDB, the GNU Debugger.
2
3 Copyright 2002-2024 Free Software Foundation, Inc.
4
5 Contributed by Andrew Cagney and Red Hat.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22
23 #ifndef SIM_TYPES_H
24 #define SIM_TYPES_H
25
26 #ifdef SIM_COMMON_BUILD
27 #error "This header is unusable in common builds due to reliance on SIM_AC_OPTION_BITSIZE"
28 #endif
29
30 #include <stdint.h>
31
32 #include "symcat.h"
33
34 /* INTEGER QUANTITIES:
35
36 TYPES:
37
38 intNN_t Signed type of the given bit size
39 uintNN_t The corresponding unsigned type
40
41 signed128 Non-standard type for 128-bit integers.
42 unsigned128 Likewise, but unsigned.
43
44 SIZES
45
46 *NN Size based on the number of bits
47 *_NN Size according to the number of bytes
48 *_word Size based on the target architecture's word
49 word size (32/64 bits)
50 *_cell Size based on the target architecture's
51 IEEE 1275 cell size (almost always 32 bits)
52
53 */
54
55
56 /* bit based */
57
58 #ifdef _MSC_VER
59 # define UNSIGNED32(X) (X##ui32)
60 # define UNSIGNED64(X) (X##ui64)
61 # define SIGNED32(X) (X##i32)
62 # define SIGNED64(X) (X##i64)
63 #else
64 # define UNSIGNED32(X) ((uint32_t) X##UL)
65 # define UNSIGNED64(X) ((uint64_t) X##ULL)
66 # define SIGNED32(X) ((int32_t) X##L)
67 # define SIGNED64(X) ((int64_t) X##LL)
68 #endif
69
70 typedef struct { uint64_t a[2]; } unsigned128;
71 typedef struct { int64_t a[2]; } signed128;
72
73
74 /* byte based */
75
76 typedef int8_t signed_1;
77 typedef int16_t signed_2;
78 typedef int32_t signed_4;
79 typedef int64_t signed_8;
80 typedef signed128 signed_16;
81
82 typedef uint8_t unsigned_1;
83 typedef uint16_t unsigned_2;
84 typedef uint32_t unsigned_4;
85 typedef uint64_t unsigned_8;
86 typedef unsigned128 unsigned_16;
87
88
89 /* Macros for printf. Usage is restricted to this header. */
90 #define SIM_PRI_TB(t, b) XCONCAT3 (PRI,t,b)
91
92
93 /* for general work, the following are defined */
94 /* unsigned: >= 32 bits */
95 /* signed: >= 32 bits */
96 /* long: >= 32 bits, sign undefined */
97 /* int: small indicator */
98
99 /* target architecture based */
100 #if (WITH_TARGET_WORD_BITSIZE == 64)
101 typedef uint64_t unsigned_word;
102 typedef int64_t signed_word;
103 #endif
104 #if (WITH_TARGET_WORD_BITSIZE == 32)
105 typedef uint32_t unsigned_word;
106 typedef int32_t signed_word;
107 #endif
108 #if (WITH_TARGET_WORD_BITSIZE == 16)
109 typedef uint16_t unsigned_word;
110 typedef int16_t signed_word;
111 #endif
112
113 #define PRI_TW(t) SIM_PRI_TB (t, WITH_TARGET_WORD_BITSIZE)
114 #define PRIiTW PRI_TW (i)
115 #define PRIxTW PRI_TW (x)
116
117
118 /* Other instructions */
119 #if (WITH_TARGET_ADDRESS_BITSIZE == 64)
120 typedef uint64_t unsigned_address;
121 typedef int64_t signed_address;
122 #endif
123 #if (WITH_TARGET_ADDRESS_BITSIZE == 32)
124 typedef uint32_t unsigned_address;
125 typedef int32_t signed_address;
126 #endif
127 #if (WITH_TARGET_ADDRESS_BITSIZE == 16)
128 typedef uint16_t unsigned_address;
129 typedef int16_t signed_address;
130 #endif
131 typedef unsigned_address address_word;
132
133 #define PRI_TA(t) SIM_PRI_TB (t, WITH_TARGET_ADDRESS_BITSIZE)
134 #define PRIiTA PRI_TA (i)
135 #define PRIxTA PRI_TA (x)
136
137
138 /* IEEE 1275 cell size */
139 #if (WITH_TARGET_CELL_BITSIZE == 64)
140 typedef uint64_t unsigned_cell;
141 typedef int64_t signed_cell;
142 #endif
143 #if (WITH_TARGET_CELL_BITSIZE == 32)
144 typedef uint32_t unsigned_cell;
145 typedef int32_t signed_cell;
146 #endif
147 typedef signed_cell cell_word; /* cells are normally signed */
148
149 #define PRI_TC(t) SIM_PRI_TB (t, WITH_TARGET_CELL_BITSIZE)
150 #define PRIiTC PRI_TC (i)
151 #define PRIxTC PRI_TC (x)
152
153
154 /* Floating point registers */
155 #if (WITH_TARGET_FLOATING_POINT_BITSIZE == 64)
156 typedef uint64_t fp_word;
157 #endif
158 #if (WITH_TARGET_FLOATING_POINT_BITSIZE == 32)
159 typedef uint32_t fp_word;
160 #endif
161
162 #define PRI_TF(t) SIM_PRI_TB (t, WITH_TARGET_FLOATING_POINT_BITSIZE)
163 #define PRIiTF PRI_TF (i)
164 #define PRIxTF PRI_TF (x)
165
166 #endif