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