Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / sim / common / sim-types.h
1 /* The common simulator framework for GDB, the GNU Debugger.
2
3 Copyright 2002-2022 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 #include <stdint.h>
27
28 /* INTEGER QUANTITIES:
29
30 TYPES:
31
32 signed* signed type of the given size
33 unsigned* The corresponding insigned type
34
35 SIZES
36
37 *NN Size based on the number of bits
38 *_NN Size according to the number of bytes
39 *_word Size based on the target architecture's word
40 word size (32/64 bits)
41 *_cell Size based on the target architecture's
42 IEEE 1275 cell size (almost always 32 bits)
43
44 */
45
46
47 /* bit based */
48
49 #ifdef _MSC_VER
50 # define UNSIGNED32(X) (X##ui32)
51 # define UNSIGNED64(X) (X##ui64)
52 # define SIGNED32(X) (X##i32)
53 # define SIGNED64(X) (X##i64)
54 #else
55 # define UNSIGNED32(X) ((unsigned32) X##UL)
56 # define UNSIGNED64(X) ((unsigned64) X##ULL)
57 # define SIGNED32(X) ((signed32) X##L)
58 # define SIGNED64(X) ((signed64) X##LL)
59 #endif
60
61 typedef int8_t signed8;
62 typedef int16_t signed16;
63 typedef int32_t signed32;
64 typedef int64_t signed64;
65
66 typedef uint8_t unsigned8;
67 typedef uint16_t unsigned16;
68 typedef uint32_t unsigned32;
69 typedef uint64_t unsigned64;
70
71 typedef struct { unsigned64 a[2]; } unsigned128;
72 typedef struct { signed64 a[2]; } signed128;
73
74
75 /* byte based */
76
77 typedef signed8 signed_1;
78 typedef signed16 signed_2;
79 typedef signed32 signed_4;
80 typedef signed64 signed_8;
81 typedef signed128 signed_16;
82
83 typedef unsigned8 unsigned_1;
84 typedef unsigned16 unsigned_2;
85 typedef unsigned32 unsigned_4;
86 typedef unsigned64 unsigned_8;
87 typedef unsigned128 unsigned_16;
88
89
90 /* Macros for printf. Usage is restricted to this header. */
91 #define SIM_PRI_TB(t, b) XCONCAT3 (PRI,t,b)
92
93
94 /* for general work, the following are defined */
95 /* unsigned: >= 32 bits */
96 /* signed: >= 32 bits */
97 /* long: >= 32 bits, sign undefined */
98 /* int: small indicator */
99
100 /* target architecture based */
101 #if (WITH_TARGET_WORD_BITSIZE == 64)
102 typedef unsigned64 unsigned_word;
103 typedef signed64 signed_word;
104 #endif
105 #if (WITH_TARGET_WORD_BITSIZE == 32)
106 typedef unsigned32 unsigned_word;
107 typedef signed32 signed_word;
108 #endif
109 #if (WITH_TARGET_WORD_BITSIZE == 16)
110 typedef unsigned16 unsigned_word;
111 typedef signed16 signed_word;
112 #endif
113
114 #define PRI_TW(t) SIM_PRI_TB (t, WITH_TARGET_WORD_BITSIZE)
115 #define PRIiTW PRI_TW (i)
116 #define PRIxTW PRI_TW (x)
117
118
119 /* Other instructions */
120 #if (WITH_TARGET_ADDRESS_BITSIZE == 64)
121 typedef unsigned64 unsigned_address;
122 typedef signed64 signed_address;
123 #endif
124 #if (WITH_TARGET_ADDRESS_BITSIZE == 32)
125 typedef unsigned32 unsigned_address;
126 typedef signed32 signed_address;
127 #endif
128 #if (WITH_TARGET_ADDRESS_BITSIZE == 16)
129 typedef unsigned16 unsigned_address;
130 typedef signed16 signed_address;
131 #endif
132 typedef unsigned_address address_word;
133
134 #define PRI_TA(t) SIM_PRI_TB (t, WITH_TARGET_ADDRESS_BITSIZE)
135 #define PRIiTA PRI_TA (i)
136 #define PRIxTA PRI_TA (x)
137
138
139 /* IEEE 1275 cell size */
140 #if (WITH_TARGET_CELL_BITSIZE == 64)
141 typedef unsigned64 unsigned_cell;
142 typedef signed64 signed_cell;
143 #endif
144 #if (WITH_TARGET_CELL_BITSIZE == 32)
145 typedef unsigned32 unsigned_cell;
146 typedef signed32 signed_cell;
147 #endif
148 typedef signed_cell cell_word; /* cells are normally signed */
149
150 #define PRI_TC(t) SIM_PRI_TB (t, WITH_TARGET_CELL_BITSIZE)
151 #define PRIiTC PRI_TC (i)
152 #define PRIxTC PRI_TC (x)
153
154
155 /* Floating point registers */
156 #if (WITH_TARGET_FLOATING_POINT_BITSIZE == 64)
157 typedef unsigned64 fp_word;
158 #endif
159 #if (WITH_TARGET_FLOATING_POINT_BITSIZE == 32)
160 typedef unsigned32 fp_word;
161 #endif
162
163 #define PRI_TF(t) SIM_PRI_TB (t, WITH_TARGET_FLOATING_POINT_BITSIZE)
164 #define PRIiTF PRI_TF (i)
165 #define PRIxTF PRI_TF (x)
166
167 #endif
This page took 0.032946 seconds and 4 git commands to generate.