xref: /freebsd/sys/arm/include/acle-compat.h (revision 8aac90f18aef7c9eea906c3ff9a001ca7b94f375)
1 /*
2  * Copyright (c) 2014 ARM Ltd
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. The name of the company may not be used to endorse or promote
14  *    products derived from this software without specific prior written
15  *    permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
18  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef __ARM_ARCH
30 
31 /* ACLE standardises a set of pre-defines that describe the ARM architecture.
32    These were mostly implemented in GCC around GCC-4.8; older versions
33    have no, or only partial support.  To provide a level of backwards
34    compatibility we try to work out what the definitions should be, given
35    the older pre-defines that GCC did produce.  This isn't complete, but
36    it should be enough for use by routines that depend on this header.  */
37 
38 /* No need to handle ARMv8, GCC had ACLE support before that.  */
39 
40 #define __ARM_ACLE 101
41 
42 # ifdef __ARM_ARCH_7__
43 /* The common subset of ARMv7 in all profiles.  */
44 #  define __ARM_ARCH 7
45 #  define __ARM_ARCH_ISA_THUMB 2
46 #  define __ARM_FEATURE_CLZ
47 #  define __ARM_FEATURE_LDREX 7
48 #  define __ARM_FEATURE_UNALIGNED
49 # endif
50 
51 # if defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7R__)
52 #  define __ARM_ARCH 7
53 #  define __ARM_ARCH_ISA_THUMB 2
54 #  define __ARM_ARCH_ISA_ARM
55 #  define __ARM_FEATURE_CLZ
56 #  define __ARM_FEATURE_SIMD32
57 #  define __ARM_FEATURE_DSP
58 #  define __ARM_FEATURE_QBIT
59 #  define __ARM_FEATURE_SAT
60 #  define __ARM_FEATURE_LDREX 15
61 #  define __ARM_FEATURE_UNALIGNED
62 #  ifdef __ARM_ARCH_7A__
63 #   define __ARM_ARCH_PROFILE 'A'
64 #  else
65 #   define __ARM_ARCH_PROFILE 'R'
66 #  endif
67 # endif
68 
69 # ifdef __ARM_ARCH_7EM__
70 #  define __ARM_ARCH 7
71 #  define __ARM_ARCH_ISA_THUMB 2
72 #  define __ARM_FEATURE_CLZ
73 #  define __ARM_FEATURE_SIMD32
74 #  define __ARM_FEATURE_DSP
75 #  define __ARM_FEATURE_QBIT
76 #  define __ARM_FEATURE_SAT
77 #  define __ARM_FEATURE_LDREX 7
78 #  define __ARM_FEATURE_UNALIGNED
79 #  define __ARM_ARCH_PROFILE 'M'
80 # endif
81 
82 # ifdef __ARM_ARCH_7M__
83 #  define __ARM_ARCH 7
84 #  define __ARM_ARCH_ISA_THUMB 2
85 #  define __ARM_FEATURE_CLZ
86 #  define __ARM_FEATURE_QBIT
87 #  define __ARM_FEATURE_SAT
88 #  define __ARM_FEATURE_LDREX 7
89 #  define __ARM_FEATURE_UNALIGNED
90 #  define __ARM_ARCH_PROFILE 'M'
91 # endif
92 
93 # ifdef __ARM_ARCH_6T2__
94 #  define __ARM_ARCH 6
95 #  define __ARM_ARCH_ISA_THUMB 2
96 #  define __ARM_ARCH_ISA_ARM
97 #  define __ARM_FEATURE_CLZ
98 #  define __ARM_FEATURE_SIMD32
99 #  define __ARM_FEATURE_DSP
100 #  define __ARM_FEATURE_QBIT
101 #  define __ARM_FEATURE_SAT
102 #  define __ARM_FEATURE_LDREX 4
103 #  define __ARM_FEATURE_UNALIGNED
104 # endif
105 
106 # ifdef __ARM_ARCH_6M__
107 #  define __ARM_ARCH 6
108 #  define __ARM_ARCH_ISA_THUMB 1
109 #  define __ARM_ARCH_PROFILE 'M'
110 # endif
111 
112 # if defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6J__) \
113   || defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6Z__) \
114   || defined (__ARM_ARCH_6ZK__)
115 #  define __ARM_ARCH 6
116 #  define __ARM_ARCH_ISA_THUMB 1
117 #  define __ARM_ARCH_ISA_ARM
118 #  define __ARM_FEATURE_CLZ
119 #  define __ARM_FEATURE_SIMD32
120 #  define __ARM_FEATURE_DSP
121 #  define __ARM_FEATURE_QBIT
122 #  define __ARM_FEATURE_SAT
123 #  define __ARM_FEATURE_UNALIGNED
124 #  ifndef __thumb__
125 #   if defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6ZK__)
126 #    define __ARM_FEATURE_LDREX 15
127 #   else
128 #    define __ARM_FEATURE_LDREX 4
129 #   endif
130 #  endif
131 # endif
132 
133 # if defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5E__)
134 #  define __ARM_ARCH 5
135 #  define __ARM_ARCH_ISA_ARM
136 #  ifdef __ARM_ARCH_5TE__
137 #   define __ARM_ARCH_ISA_THUMB 1
138 #  endif
139 #  define __ARM_FEATURE_CLZ
140 #  define __ARM_FEATURE_DSP
141 # endif
142 
143 # if defined (__ARM_ARCH_5T__) || defined (__ARM_ARCH_5__)
144 #  define __ARM_ARCH 5
145 #  define __ARM_ARCH_ISA_ARM
146 #  ifdef __ARM_ARCH_5TE__
147 #   define __ARM_ARCH_ISA_THUMB 1
148 #  endif
149 #  define __ARM_FEATURE_CLZ
150 # endif
151 
152 # ifdef __ARM_ARCH_4T__
153 #  define __ARM_ARCH 4
154 #  define __ARM_ARCH_ISA_ARM
155 #  define __ARM_ARCH_ISA_THUMB 1
156 # endif
157 
158 # ifdef __ARM_ARCH_4__
159 #  define __ARM_ARCH 4
160 #  define __ARM_ARCH_ISA_ARM
161 # endif
162 
163 # if defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__)
164 #  define __ARM_ARCH 3
165 #  define __ARM_ARCH_ISA_ARM
166 # endif
167 
168 # ifdef __ARM_ARCH_2__
169 #  define __ARM_ARCH 2
170 #  define __ARM_ARCH_ISA_ARM
171 # endif
172 
173 # ifdef __ARMEB__
174 #  define __ARM_BIG_ENDIAN
175 # endif
176 
177 /* If we still don't know what the target architecture is, then we're
178    probably not using GCC.  */
179 # ifndef __ARM_ARCH
180 #  error Unable to determine architecture version.
181 # endif
182 
183 #endif /* __ARM_ARCH  */
184