]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - sim/common/sim-types.h
sim: common: add PRI printf defines
[thirdparty/binutils-gdb.git] / sim / common / sim-types.h
CommitLineData
b85e4829
AC
1/* The common simulator framework for GDB, the GNU Debugger.
2
32d0add0 3 Copyright 2002-2015 Free Software Foundation, Inc.
b85e4829
AC
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
4744ac1b 11 the Free Software Foundation; either version 3 of the License, or
b85e4829
AC
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
4744ac1b 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
21
22
23#ifndef SIM_TYPES_H
f55b33d5
MF
24#define SIM_TYPES_H
25
26#include <stdint.h>
c906108c
SS
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
c906108c
SS
47/* bit based */
48
f55b33d5
MF
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)
c906108c 54#else
f55b33d5
MF
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)
c906108c
SS
59#endif
60
f55b33d5
MF
61typedef int8_t signed8;
62typedef int16_t signed16;
63typedef int32_t signed32;
64typedef int64_t signed64;
65
66typedef uint8_t unsigned8;
67typedef uint16_t unsigned16;
68typedef uint32_t unsigned32;
69typedef uint64_t unsigned64;
c906108c
SS
70
71typedef struct { unsigned64 a[2]; } unsigned128;
72typedef struct { signed64 a[2]; } signed128;
73
c906108c
SS
74
75/* byte based */
76
77typedef signed8 signed_1;
78typedef signed16 signed_2;
79typedef signed32 signed_4;
80typedef signed64 signed_8;
81typedef signed128 signed_16;
82
83typedef unsigned8 unsigned_1;
84typedef unsigned16 unsigned_2;
85typedef unsigned32 unsigned_4;
86typedef unsigned64 unsigned_8;
87typedef unsigned128 unsigned_16;
88
89
37258e99
MF
90/* Macros for printf. Usage is restricted to this header. */
91#define SIM_PRI_TB(t, b) XCONCAT3 (PRI,t,b)
92
93
c906108c
SS
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)
102typedef unsigned64 unsigned_word;
103typedef signed64 signed_word;
104#endif
105#if (WITH_TARGET_WORD_BITSIZE == 32)
106typedef unsigned32 unsigned_word;
107typedef signed32 signed_word;
108#endif
3c765a54
AC
109#if (WITH_TARGET_WORD_BITSIZE == 16)
110typedef unsigned16 unsigned_word;
111typedef signed16 signed_word;
112#endif
c906108c 113
37258e99
MF
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
c906108c
SS
118
119/* Other instructions */
120#if (WITH_TARGET_ADDRESS_BITSIZE == 64)
121typedef unsigned64 unsigned_address;
122typedef signed64 signed_address;
123#endif
124#if (WITH_TARGET_ADDRESS_BITSIZE == 32)
125typedef unsigned32 unsigned_address;
126typedef signed32 signed_address;
127#endif
3c765a54
AC
128#if (WITH_TARGET_ADDRESS_BITSIZE == 16)
129typedef unsigned16 unsigned_address;
130typedef signed16 signed_address;
131#endif
c906108c
SS
132typedef unsigned_address address_word;
133
37258e99
MF
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
c906108c
SS
138
139/* IEEE 1275 cell size */
140#if (WITH_TARGET_CELL_BITSIZE == 64)
141typedef unsigned64 unsigned_cell;
142typedef signed64 signed_cell;
143#endif
144#if (WITH_TARGET_CELL_BITSIZE == 32)
145typedef unsigned32 unsigned_cell;
146typedef signed32 signed_cell;
147#endif
148typedef signed_cell cell_word; /* cells are normally signed */
149
37258e99
MF
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
c906108c
SS
154
155/* Floating point registers */
156#if (WITH_TARGET_FLOATING_POINT_BITSIZE == 64)
157typedef unsigned64 fp_word;
158#endif
159#if (WITH_TARGET_FLOATING_POINT_BITSIZE == 32)
160typedef unsigned32 fp_word;
161#endif
162
37258e99
MF
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
c906108c 167#endif