]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/arm/arm-c.c
2015-06-04 Andrew MacLeod <amacleod@redhat.com>
[thirdparty/gcc.git] / gcc / config / arm / arm-c.c
1 /* Copyright (C) 2007-2015 Free Software Foundation, Inc.
2
3 This file is part of GCC.
4
5 GCC is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 3, or (at your option) any later
8 version.
9
10 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GCC; see the file COPYING3. If not see
17 <http://www.gnu.org/licenses/>. */
18
19 #include "config.h"
20 #include "system.h"
21 #include "coretypes.h"
22 #include "tm.h"
23 #include "tm_p.h"
24 #include "hash-set.h"
25 #include "vec.h"
26 #include "input.h"
27 #include "alias.h"
28 #include "symtab.h"
29 #include "inchash.h"
30 #include "tree.h"
31 #include "c-family/c-common.h"
32
33 /* Output C specific EABI object attributes. These can not be done in
34 arm.c because they require information from the C frontend. */
35
36 static void
37 arm_output_c_attributes (void)
38 {
39 int wchar_size = (int)(TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT);
40 arm_emit_eabi_attribute ("Tag_ABI_PCS_wchar_t", 18, wchar_size);
41 }
42
43
44 /* Setup so that common code calls arm_output_c_attributes. */
45
46 void
47 arm_lang_object_attributes_init (void)
48 {
49 arm_lang_output_object_attributes_hook = arm_output_c_attributes;
50 }
51
52 #define builtin_define(TXT) cpp_define (pfile, TXT)
53 #define builtin_assert(TXT) cpp_assert (pfile, TXT)
54
55 /* Define or undefine macros based on the current target. If the user does
56 #pragma GCC target, we need to adjust the macros dynamically. */
57
58 static void
59 def_or_undef_macro(struct cpp_reader* pfile, const char *name, bool def_p)
60 {
61 if (def_p)
62 cpp_define (pfile, name);
63 else
64 cpp_undef (pfile, name);
65 }
66
67 void
68 arm_cpu_cpp_builtins (struct cpp_reader * pfile)
69 {
70 int flags = target_flags;
71
72 def_or_undef_macro (pfile, "__ARM_FEATURE_DSP",
73 TARGET_DSP_MULTIPLY_P (flags));
74 def_or_undef_macro (pfile, "__ARM_FEATURE_QBIT",
75 TARGET_ARM_QBIT_P (flags));
76 def_or_undef_macro (pfile, "__ARM_FEATURE_SAT",
77 TARGET_ARM_SAT_P (flags));
78 if (TARGET_CRYPTO)
79 builtin_define ("__ARM_FEATURE_CRYPTO");
80 if (unaligned_access)
81 builtin_define ("__ARM_FEATURE_UNALIGNED");
82 if (TARGET_CRC32)
83 builtin_define ("__ARM_FEATURE_CRC32");
84
85 def_or_undef_macro (pfile, "__ARM_32BIT_STATE", TARGET_32BIT_P (flags));
86
87 if (TARGET_ARM_FEATURE_LDREX_P (flags))
88 builtin_define_with_int_value ("__ARM_FEATURE_LDREX",
89 TARGET_ARM_FEATURE_LDREX_P (flags));
90 else
91 cpp_undef (pfile, "__ARM_FEATURE_LDREX");
92
93 def_or_undef_macro (pfile, "__ARM_FEATURE_CLZ",
94 ((TARGET_ARM_ARCH >= 5 && !TARGET_THUMB_P (flags))
95 || TARGET_ARM_ARCH_ISA_THUMB >=2));
96
97 def_or_undef_macro (pfile, "__ARM_FEATURE_SIMD32", TARGET_INT_SIMD_P (flags));
98
99 builtin_define_with_int_value ("__ARM_SIZEOF_MINIMAL_ENUM",
100 flag_short_enums ? 1 : 4);
101 builtin_define_type_sizeof ("__ARM_SIZEOF_WCHAR_T", wchar_type_node);
102 if (TARGET_ARM_ARCH_PROFILE)
103 builtin_define_with_int_value ("__ARM_ARCH_PROFILE",
104 TARGET_ARM_ARCH_PROFILE);
105
106 /* Define __arm__ even when in thumb mode, for
107 consistency with armcc. */
108 builtin_define ("__arm__");
109 if (TARGET_ARM_ARCH)
110 builtin_define_with_int_value ("__ARM_ARCH", TARGET_ARM_ARCH);
111 if (arm_arch_notm)
112 builtin_define ("__ARM_ARCH_ISA_ARM");
113 builtin_define ("__APCS_32__");
114
115 def_or_undef_macro (pfile, "__thumb__", TARGET_THUMB_P (flags));
116 def_or_undef_macro (pfile, "__thumb2__", TARGET_THUMB2_P (flags));
117 if (TARGET_BIG_END)
118 def_or_undef_macro (pfile, "__THUMBEB__", TARGET_THUMB_P (flags));
119 else
120 def_or_undef_macro (pfile, "__THUMBEL__", TARGET_THUMB_P (flags));
121
122 if (TARGET_ARM_ARCH_ISA_THUMB)
123 builtin_define_with_int_value ("__ARM_ARCH_ISA_THUMB",
124 TARGET_ARM_ARCH_ISA_THUMB);
125
126 if (TARGET_BIG_END)
127 {
128 builtin_define ("__ARMEB__");
129 builtin_define ("__ARM_BIG_ENDIAN");
130 }
131 else
132 {
133 builtin_define ("__ARMEL__");
134 }
135
136 if (TARGET_SOFT_FLOAT)
137 builtin_define ("__SOFTFP__");
138
139 if (TARGET_VFP)
140 builtin_define ("__VFP_FP__");
141
142 if (TARGET_ARM_FP)
143 builtin_define_with_int_value ("__ARM_FP", TARGET_ARM_FP);
144 if (arm_fp16_format == ARM_FP16_FORMAT_IEEE)
145 builtin_define ("__ARM_FP16_FORMAT_IEEE");
146 if (arm_fp16_format == ARM_FP16_FORMAT_ALTERNATIVE)
147 builtin_define ("__ARM_FP16_FORMAT_ALTERNATIVE");
148 if (TARGET_FMA)
149 builtin_define ("__ARM_FEATURE_FMA");
150
151 if (TARGET_NEON)
152 {
153 builtin_define ("__ARM_NEON__");
154 builtin_define ("__ARM_NEON");
155 }
156 if (TARGET_NEON_FP)
157 builtin_define_with_int_value ("__ARM_NEON_FP", TARGET_NEON_FP);
158
159 /* Add a define for interworking. Needed when building libgcc.a. */
160 if (arm_cpp_interwork)
161 builtin_define ("__THUMB_INTERWORK__");
162
163 builtin_assert ("cpu=arm");
164 builtin_assert ("machine=arm");
165
166 builtin_define (arm_arch_name);
167 if (arm_arch_xscale)
168 builtin_define ("__XSCALE__");
169 if (arm_arch_iwmmxt)
170 {
171 builtin_define ("__IWMMXT__");
172 builtin_define ("__ARM_WMMX");
173 }
174 if (arm_arch_iwmmxt2)
175 builtin_define ("__IWMMXT2__");
176 if (TARGET_AAPCS_BASED)
177 {
178 if (arm_pcs_default == ARM_PCS_AAPCS_VFP)
179 builtin_define ("__ARM_PCS_VFP");
180 else if (arm_pcs_default == ARM_PCS_AAPCS)
181 builtin_define ("__ARM_PCS");
182 builtin_define ("__ARM_EABI__");
183 }
184
185
186
187 def_or_undef_macro (pfile, "__ARM_ARCH_EXT_IDIV__", TARGET_IDIV_P (flags));
188 def_or_undef_macro (pfile, "__ARM_FEATURE_IDIV", TARGET_IDIV_P (flags));
189
190 def_or_undef_macro (pfile, "__ARM_ASM_SYNTAX_UNIFIED__", inline_asm_unified);
191 }