1 /* The common simulator framework for GDB, the GNU Debugger.
3 Copyright 2002-2024 Free Software Foundation, Inc.
5 Contributed by Andrew Cagney and Red Hat.
7 This file is part of GDB.
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.
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.
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/>. */
26 #ifdef SIM_COMMON_BUILD
27 #error "This header is unusable in common builds due to reliance on SIM_AC_OPTION_BITSIZE"
34 /* INTEGER QUANTITIES:
38 intNN_t Signed type of the given bit size
39 uintNN_t The corresponding unsigned type
41 signed128 Non-standard type for 128-bit integers.
42 unsigned128 Likewise, but unsigned.
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)
59 # define UNSIGNED32(X) (X##ui32)
60 # define UNSIGNED64(X) (X##ui64)
61 # define SIGNED32(X) (X##i32)
62 # define SIGNED64(X) (X##i64)
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)
70 typedef struct { uint64_t a
[2]; } unsigned128
;
71 typedef struct { int64_t a
[2]; } signed128
;
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
;
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
;
89 /* Macros for printf. Usage is restricted to this header. */
90 #define SIM_PRI_TB(t, b) XCONCAT3 (PRI,t,b)
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 */
99 /* target architecture based */
100 #if (WITH_TARGET_WORD_BITSIZE == 64)
101 typedef uint64_t unsigned_word
;
102 typedef int64_t signed_word
;
104 #if (WITH_TARGET_WORD_BITSIZE == 32)
105 typedef uint32_t unsigned_word
;
106 typedef int32_t signed_word
;
108 #if (WITH_TARGET_WORD_BITSIZE == 16)
109 typedef uint16_t unsigned_word
;
110 typedef int16_t signed_word
;
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)
118 /* Other instructions */
119 #if (WITH_TARGET_ADDRESS_BITSIZE == 64)
120 typedef uint64_t unsigned_address
;
121 typedef int64_t signed_address
;
123 #if (WITH_TARGET_ADDRESS_BITSIZE == 32)
124 typedef uint32_t unsigned_address
;
125 typedef int32_t signed_address
;
127 #if (WITH_TARGET_ADDRESS_BITSIZE == 16)
128 typedef uint16_t unsigned_address
;
129 typedef int16_t signed_address
;
131 typedef unsigned_address address_word
;
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)
138 /* IEEE 1275 cell size */
139 #if (WITH_TARGET_CELL_BITSIZE == 64)
140 typedef uint64_t unsigned_cell
;
141 typedef int64_t signed_cell
;
143 #if (WITH_TARGET_CELL_BITSIZE == 32)
144 typedef uint32_t unsigned_cell
;
145 typedef int32_t signed_cell
;
147 typedef signed_cell cell_word
; /* cells are normally signed */
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)
154 /* Floating point registers */
155 #if (WITH_TARGET_FLOATING_POINT_BITSIZE == 64)
156 typedef uint64_t fp_word
;
158 #if (WITH_TARGET_FLOATING_POINT_BITSIZE == 32)
159 typedef uint32_t fp_word
;
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)