]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/arc/arc-c.c
[ARC] New CPU C-define handler.
[thirdparty/gcc.git] / gcc / config / arc / arc-c.c
1 /* Copyright (C) 2016 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
6 under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
9
10 GCC is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
13 License 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
20 #include "config.h"
21 #include "system.h"
22 #include "coretypes.h"
23 #include "tm.h"
24 #include "tree.h"
25 #include "tm_p.h"
26 #include "cpplib.h"
27 #include "c-family/c-common.h"
28 #include "target.h"
29
30 #define builtin_define(TXT) cpp_define (pfile, TXT)
31 #define builtin_assert(TXT) cpp_assert (pfile, TXT)
32
33 /* Define or undefine macros based on the current target. */
34
35 static void
36 def_or_undef_macro (cpp_reader* pfile, const char *name, bool def_p)
37 {
38 if (def_p)
39 cpp_define (pfile, name);
40 else
41 cpp_undef (pfile, name);
42 }
43
44 /* Helper for TARGET_CPU_CPP_BUILTINS hook. */
45
46 void
47 arc_cpu_cpp_builtins (cpp_reader * pfile)
48 {
49 builtin_assert ("cpu=arc");
50 builtin_assert ("machine=arc");
51
52 builtin_define ("__arc__");
53
54 #undef ARC_C_DEF
55 #define ARC_C_DEF(NAME, CONDITION) \
56 def_or_undef_macro (pfile, NAME, CONDITION);
57
58 #include "arc-c.def"
59 #undef ARC_C_DEF
60
61 builtin_define_with_int_value ("__ARC_TLS_REGNO__",
62 arc_tp_regno);
63
64 builtin_define (TARGET_BIG_ENDIAN
65 ? "__BIG_ENDIAN__" : "__LITTLE_ENDIAN__");
66 if (TARGET_BIG_ENDIAN)
67 builtin_define ("__big_endian__");
68
69 }