xref: /openbmc/u-boot/arch/arc/lib/libgcc2.h (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
2a67ef280SAlexey Brodkin /*
3a67ef280SAlexey Brodkin  * Copyright (C) 1989-2013 Free Software Foundation, Inc.
4a67ef280SAlexey Brodkin  */
5a67ef280SAlexey Brodkin 
6a67ef280SAlexey Brodkin #ifndef __ASM_LIBGCC_H
7a67ef280SAlexey Brodkin #define __ASM_LIBGCC_H
8a67ef280SAlexey Brodkin 
9a67ef280SAlexey Brodkin #define UNITS_PER_WORD 4	/* for ARC */
10a67ef280SAlexey Brodkin #define BITS_PER_UNIT 8		/* for ARC */
11a67ef280SAlexey Brodkin 
12a67ef280SAlexey Brodkin #define W_TYPE_SIZE (4 * BITS_PER_UNIT)
13a67ef280SAlexey Brodkin 
14a67ef280SAlexey Brodkin #define MIN_UNITS_PER_WORD UNITS_PER_WORD
15a67ef280SAlexey Brodkin 
16a67ef280SAlexey Brodkin /* Work out the largest "word" size that we can deal with on this target.  */
17a67ef280SAlexey Brodkin #if MIN_UNITS_PER_WORD > 4
18a67ef280SAlexey Brodkin # define LIBGCC2_MAX_UNITS_PER_WORD 8
19a67ef280SAlexey Brodkin #elif (MIN_UNITS_PER_WORD > 2 \
20a67ef280SAlexey Brodkin        || (MIN_UNITS_PER_WORD > 1 && __SIZEOF_LONG_LONG__ > 4))
21a67ef280SAlexey Brodkin # define LIBGCC2_MAX_UNITS_PER_WORD 4
22a67ef280SAlexey Brodkin #else
23a67ef280SAlexey Brodkin # define LIBGCC2_MAX_UNITS_PER_WORD MIN_UNITS_PER_WORD
24a67ef280SAlexey Brodkin #endif
25a67ef280SAlexey Brodkin 
26a67ef280SAlexey Brodkin /* Work out what word size we are using for this compilation.
27a67ef280SAlexey Brodkin    The value can be set on the command line.  */
28a67ef280SAlexey Brodkin #ifndef LIBGCC2_UNITS_PER_WORD
29a67ef280SAlexey Brodkin #define LIBGCC2_UNITS_PER_WORD LIBGCC2_MAX_UNITS_PER_WORD
30a67ef280SAlexey Brodkin #endif
31a67ef280SAlexey Brodkin 
32a67ef280SAlexey Brodkin typedef		 int QItype	__attribute__ ((mode (QI)));
33a67ef280SAlexey Brodkin typedef unsigned int UQItype	__attribute__ ((mode (QI)));
34a67ef280SAlexey Brodkin typedef		 int HItype	__attribute__ ((mode (HI)));
35a67ef280SAlexey Brodkin typedef unsigned int UHItype	__attribute__ ((mode (HI)));
36a67ef280SAlexey Brodkin #if MIN_UNITS_PER_WORD > 1
37a67ef280SAlexey Brodkin /* These typedefs are usually forbidden on dsp's with UNITS_PER_WORD 1.  */
38a67ef280SAlexey Brodkin typedef 	 int SItype	__attribute__ ((mode (SI)));
39a67ef280SAlexey Brodkin typedef unsigned int USItype	__attribute__ ((mode (SI)));
40a67ef280SAlexey Brodkin #if __SIZEOF_LONG_LONG__ > 4
41a67ef280SAlexey Brodkin /* These typedefs are usually forbidden on archs with UNITS_PER_WORD 2.  */
42a67ef280SAlexey Brodkin typedef		 int DItype	__attribute__ ((mode (DI)));
43a67ef280SAlexey Brodkin typedef unsigned int UDItype	__attribute__ ((mode (DI)));
44a67ef280SAlexey Brodkin #if MIN_UNITS_PER_WORD > 4
45a67ef280SAlexey Brodkin /* These typedefs are usually forbidden on archs with UNITS_PER_WORD 4.  */
46a67ef280SAlexey Brodkin typedef		 int TItype	__attribute__ ((mode (TI)));
47a67ef280SAlexey Brodkin typedef unsigned int UTItype	__attribute__ ((mode (TI)));
48a67ef280SAlexey Brodkin #endif
49a67ef280SAlexey Brodkin #endif
50a67ef280SAlexey Brodkin #endif
51a67ef280SAlexey Brodkin 
52a67ef280SAlexey Brodkin #if LIBGCC2_UNITS_PER_WORD == 8
53a67ef280SAlexey Brodkin #define W_TYPE_SIZE (8 * BITS_PER_UNIT)
54a67ef280SAlexey Brodkin #define Wtype	DItype
55a67ef280SAlexey Brodkin #define UWtype	UDItype
56a67ef280SAlexey Brodkin #define HWtype	DItype
57a67ef280SAlexey Brodkin #define UHWtype	UDItype
58a67ef280SAlexey Brodkin #define DWtype	TItype
59a67ef280SAlexey Brodkin #define UDWtype	UTItype
60a67ef280SAlexey Brodkin #ifdef LIBGCC2_GNU_PREFIX
61a67ef280SAlexey Brodkin #define __NW(a,b)	__gnu_ ## a ## di ## b
62a67ef280SAlexey Brodkin #define __NDW(a,b)	__gnu_ ## a ## ti ## b
63a67ef280SAlexey Brodkin #else
64a67ef280SAlexey Brodkin #define __NW(a,b)	__ ## a ## di ## b
65a67ef280SAlexey Brodkin #define __NDW(a,b)	__ ## a ## ti ## b
66a67ef280SAlexey Brodkin #endif
67a67ef280SAlexey Brodkin #elif LIBGCC2_UNITS_PER_WORD == 4
68a67ef280SAlexey Brodkin #define W_TYPE_SIZE (4 * BITS_PER_UNIT)
69a67ef280SAlexey Brodkin #define Wtype	SItype
70a67ef280SAlexey Brodkin #define UWtype	USItype
71a67ef280SAlexey Brodkin #define HWtype	SItype
72a67ef280SAlexey Brodkin #define UHWtype	USItype
73a67ef280SAlexey Brodkin #define DWtype	DItype
74a67ef280SAlexey Brodkin #define UDWtype	UDItype
75a67ef280SAlexey Brodkin #ifdef LIBGCC2_GNU_PREFIX
76a67ef280SAlexey Brodkin #define __NW(a,b)	__gnu_ ## a ## si ## b
77a67ef280SAlexey Brodkin #define __NDW(a,b)	__gnu_ ## a ## di ## b
78a67ef280SAlexey Brodkin #else
79a67ef280SAlexey Brodkin #define __NW(a,b)	__ ## a ## si ## b
80a67ef280SAlexey Brodkin #define __NDW(a,b)	__ ## a ## di ## b
81a67ef280SAlexey Brodkin #endif
82a67ef280SAlexey Brodkin #elif LIBGCC2_UNITS_PER_WORD == 2
83a67ef280SAlexey Brodkin #define W_TYPE_SIZE (2 * BITS_PER_UNIT)
84a67ef280SAlexey Brodkin #define Wtype	HItype
85a67ef280SAlexey Brodkin #define UWtype	UHItype
86a67ef280SAlexey Brodkin #define HWtype	HItype
87a67ef280SAlexey Brodkin #define UHWtype	UHItype
88a67ef280SAlexey Brodkin #define DWtype	SItype
89a67ef280SAlexey Brodkin #define UDWtype	USItype
90a67ef280SAlexey Brodkin #ifdef LIBGCC2_GNU_PREFIX
91a67ef280SAlexey Brodkin #define __NW(a,b)	__gnu_ ## a ## hi ## b
92a67ef280SAlexey Brodkin #define __NDW(a,b)	__gnu_ ## a ## si ## b
93a67ef280SAlexey Brodkin #else
94a67ef280SAlexey Brodkin #define __NW(a,b)	__ ## a ## hi ## b
95a67ef280SAlexey Brodkin #define __NDW(a,b)	__ ## a ## si ## b
96a67ef280SAlexey Brodkin #endif
97a67ef280SAlexey Brodkin #else
98a67ef280SAlexey Brodkin #define W_TYPE_SIZE BITS_PER_UNIT
99a67ef280SAlexey Brodkin #define Wtype	QItype
100a67ef280SAlexey Brodkin #define UWtype  UQItype
101a67ef280SAlexey Brodkin #define HWtype	QItype
102a67ef280SAlexey Brodkin #define UHWtype	UQItype
103a67ef280SAlexey Brodkin #define DWtype	HItype
104a67ef280SAlexey Brodkin #define UDWtype	UHItype
105a67ef280SAlexey Brodkin #ifdef LIBGCC2_GNU_PREFIX
106a67ef280SAlexey Brodkin #define __NW(a,b)	__gnu_ ## a ## qi ## b
107a67ef280SAlexey Brodkin #define __NDW(a,b)	__gnu_ ## a ## hi ## b
108a67ef280SAlexey Brodkin #else
109a67ef280SAlexey Brodkin #define __NW(a,b)	__ ## a ## qi ## b
110a67ef280SAlexey Brodkin #define __NDW(a,b)	__ ## a ## hi ## b
111a67ef280SAlexey Brodkin #endif
112a67ef280SAlexey Brodkin #endif
113a67ef280SAlexey Brodkin 
114a67ef280SAlexey Brodkin typedef int shift_count_type __attribute__((mode (__libgcc_shift_count__)));
115a67ef280SAlexey Brodkin 
116a67ef280SAlexey Brodkin #if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
117a67ef280SAlexey Brodkin 	struct DWstruct {Wtype high, low;};
118a67ef280SAlexey Brodkin #else
119a67ef280SAlexey Brodkin 	struct DWstruct {Wtype low, high;};
120a67ef280SAlexey Brodkin #endif
121a67ef280SAlexey Brodkin 
122a67ef280SAlexey Brodkin /* We need this union to unpack/pack DImode values, since we don't have
123a67ef280SAlexey Brodkin    any arithmetic yet.  Incoming DImode parameters are stored into the
124a67ef280SAlexey Brodkin    `ll' field, and the unpacked result is read from the struct `s'.  */
125a67ef280SAlexey Brodkin 
126a67ef280SAlexey Brodkin typedef union {
127a67ef280SAlexey Brodkin 	struct DWstruct s;
128a67ef280SAlexey Brodkin 	DWtype ll;
129a67ef280SAlexey Brodkin } DWunion;
130a67ef280SAlexey Brodkin 
131a67ef280SAlexey Brodkin #endif /* __ASM_LIBGCC_H */
132