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 * $FreeBSD$
29 */
30
31#ifndef __ARM_ARCH
32
33/* ACLE standardises a set of pre-defines that describe the ARM architecture.
34   These were mostly implemented in GCC around GCC-4.8; older versions
35   have no, or only partial support.  To provide a level of backwards
36   compatibility we try to work out what the definitions should be, given
37   the older pre-defines that GCC did produce.  This isn't complete, but
38   it should be enough for use by routines that depend on this header.  */
39
40/* No need to handle ARMv8, GCC had ACLE support before that.  */
41
42#define __ARM_ACLE 101
43
44# ifdef __ARM_ARCH_7__
45/* The common subset of ARMv7 in all profiles.  */
46#  define __ARM_ARCH 7
47#  define __ARM_ARCH_ISA_THUMB 2
48#  define __ARM_FEATURE_CLZ
49#  define __ARM_FEATURE_LDREX 7
50#  define __ARM_FEATURE_UNALIGNED
51# endif
52
53# if defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7R__)
54#  define __ARM_ARCH 7
55#  define __ARM_ARCH_ISA_THUMB 2
56#  define __ARM_ARCH_ISA_ARM
57#  define __ARM_FEATURE_CLZ
58#  define __ARM_FEATURE_SIMD32
59#  define __ARM_FEATURE_DSP
60#  define __ARM_FEATURE_QBIT
61#  define __ARM_FEATURE_SAT
62#  define __ARM_FEATURE_LDREX 15
63#  define __ARM_FEATURE_UNALIGNED
64#  ifdef __ARM_ARCH_7A__
65#   define __ARM_ARCH_PROFILE 'A'
66#  else
67#   define __ARM_ARCH_PROFILE 'R'
68#  endif
69# endif
70
71# ifdef __ARM_ARCH_7EM__
72#  define __ARM_ARCH 7
73#  define __ARM_ARCH_ISA_THUMB 2
74#  define __ARM_FEATURE_CLZ
75#  define __ARM_FEATURE_SIMD32
76#  define __ARM_FEATURE_DSP
77#  define __ARM_FEATURE_QBIT
78#  define __ARM_FEATURE_SAT
79#  define __ARM_FEATURE_LDREX 7
80#  define __ARM_FEATURE_UNALIGNED
81#  define __ARM_ARCH_PROFILE 'M'
82# endif
83
84# ifdef __ARM_ARCH_7M__
85#  define __ARM_ARCH 7
86#  define __ARM_ARCH_ISA_THUMB 2
87#  define __ARM_FEATURE_CLZ
88#  define __ARM_FEATURE_QBIT
89#  define __ARM_FEATURE_SAT
90#  define __ARM_FEATURE_LDREX 7
91#  define __ARM_FEATURE_UNALIGNED
92#  define __ARM_ARCH_PROFILE 'M'
93# endif
94
95# ifdef __ARM_ARCH_6T2__
96#  define __ARM_ARCH 6
97#  define __ARM_ARCH_ISA_THUMB 2
98#  define __ARM_ARCH_ISA_ARM
99#  define __ARM_FEATURE_CLZ
100#  define __ARM_FEATURE_SIMD32
101#  define __ARM_FEATURE_DSP
102#  define __ARM_FEATURE_QBIT
103#  define __ARM_FEATURE_SAT
104#  define __ARM_FEATURE_LDREX 4
105#  define __ARM_FEATURE_UNALIGNED
106# endif
107
108# ifdef __ARM_ARCH_6M__
109#  define __ARM_ARCH 6
110#  define __ARM_ARCH_ISA_THUMB 1
111#  define __ARM_ARCH_PROFILE 'M'
112# endif
113
114# if defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6J__) \
115  || defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6Z__) \
116  || defined (__ARM_ARCH_6ZK__)
117#  define __ARM_ARCH 6
118#  define __ARM_ARCH_ISA_THUMB 1
119#  define __ARM_ARCH_ISA_ARM
120#  define __ARM_FEATURE_CLZ
121#  define __ARM_FEATURE_SIMD32
122#  define __ARM_FEATURE_DSP
123#  define __ARM_FEATURE_QBIT
124#  define __ARM_FEATURE_SAT
125#  define __ARM_FEATURE_UNALIGNED
126#  ifndef __thumb__
127#   if defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6ZK__)
128#    define __ARM_FEATURE_LDREX 15
129#   else
130#    define __ARM_FEATURE_LDREX 4
131#   endif
132#  endif
133# endif
134
135# if defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5E__)
136#  define __ARM_ARCH 5
137#  define __ARM_ARCH_ISA_ARM
138#  ifdef __ARM_ARCH_5TE__
139#   define __ARM_ARCH_ISA_THUMB 1
140#  endif
141#  define __ARM_FEATURE_CLZ
142#  define __ARM_FEATURE_DSP
143# endif
144
145# if defined (__ARM_ARCH_5T__) || defined (__ARM_ARCH_5__)
146#  define __ARM_ARCH 5
147#  define __ARM_ARCH_ISA_ARM
148#  ifdef __ARM_ARCH_5TE__
149#   define __ARM_ARCH_ISA_THUMB 1
150#  endif
151#  define __ARM_FEATURE_CLZ
152# endif
153
154# ifdef __ARM_ARCH_4T__
155#  define __ARM_ARCH 4
156#  define __ARM_ARCH_ISA_ARM
157#  define __ARM_ARCH_ISA_THUMB 1
158# endif
159
160# ifdef __ARM_ARCH_4__
161#  define __ARM_ARCH 4
162#  define __ARM_ARCH_ISA_ARM
163# endif
164
165# if defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__)
166#  define __ARM_ARCH 3
167#  define __ARM_ARCH_ISA_ARM
168# endif
169
170# ifdef __ARM_ARCH_2__
171#  define __ARM_ARCH 2
172#  define __ARM_ARCH_ISA_ARM
173# endif
174
175# ifdef __ARMEB__
176#  define __ARM_BIG_ENDIAN
177# endif
178
179/* If we still don't know what the target architecture is, then we're
180   probably not using GCC.  */
181# ifndef __ARM_ARCH
182#  error Unable to determine architecture version.
183# endif
184
185#endif /* __ARM_ARCH  */
186