1 /* Pragma handling for GCC for Renesas / SuperH SH.
2 Copyright (C) 1993-2015 Free Software Foundation, Inc.
3 Contributed by Joern Rennecke <joern.rennecke@st.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
25 #include "c-family/c-common.h"
27 #include "stringpool.h"
30 /* Handle machine specific pragmas to be semi-compatible with Renesas
33 /* Add ATTR to the attributes of the current function. If there is no
34 such function, save it to be added to the attributes of the next
37 sh_add_function_attribute (const char *attr
)
39 tree id
= get_identifier (attr
);
41 if (current_function_decl
)
42 decl_attributes (¤t_function_decl
,
43 tree_cons (id
, NULL_TREE
, NULL_TREE
), 0);
46 *sh_deferred_function_attributes_tail
47 = tree_cons (id
, NULL_TREE
, *sh_deferred_function_attributes_tail
);
48 sh_deferred_function_attributes_tail
49 = &TREE_CHAIN (*sh_deferred_function_attributes_tail
);
54 sh_pr_interrupt (struct cpp_reader
*pfile ATTRIBUTE_UNUSED
)
56 sh_add_function_attribute ("interrupt_handler");
60 sh_pr_trapa (struct cpp_reader
*pfile ATTRIBUTE_UNUSED
)
62 sh_add_function_attribute ("trapa_handler");
66 sh_pr_nosave_low_regs (struct cpp_reader
*pfile ATTRIBUTE_UNUSED
)
68 sh_add_function_attribute ("nosave_low_regs");
71 #define builtin_define(TXT) cpp_define (pfile, TXT)
72 #define builtin_assert(TXT) cpp_assert (pfile, TXT)
74 /* Implement the TARGET_CPU_CPP_BUILTINS macro */
76 sh_cpu_cpp_builtins (cpp_reader
* pfile
)
78 builtin_define ("__sh__");
79 builtin_assert ("cpu=sh");
80 builtin_assert ("machine=sh");
84 builtin_define ("__sh1__");
85 builtin_define ("__SH1__");
88 builtin_define ("__sh2__");
89 builtin_define ("__SH2__");
92 builtin_define ("__SH2E__");
95 builtin_define ("__SH2A__");
96 if (TARGET_SH2A_DOUBLE
)
97 builtin_define (TARGET_FPU_SINGLE
98 ? "__SH2A_SINGLE__" : "__SH2A_DOUBLE__");
100 builtin_define (TARGET_FPU_ANY
101 ? "__SH2A_SINGLE_ONLY__" : "__SH2A_NOFPU__");
104 builtin_define ("__sh3__");
105 builtin_define ("__SH3__");
107 builtin_define ("__SH4_NOFPU__");
110 builtin_define (TARGET_HARD_SH4
? "__SH4_SINGLE_ONLY__" : "__SH3E__");
113 builtin_define (TARGET_FPU_SINGLE
? "__SH4_SINGLE__" : "__SH4__");
115 case PROCESSOR_SH4A
: \
116 builtin_define ("__SH4A__");
117 builtin_define (TARGET_SH4
118 ? (TARGET_FPU_SINGLE
? "__SH4_SINGLE__" : "__SH4__")
119 : TARGET_FPU_ANY
? "__SH4_SINGLE_ONLY__"
124 builtin_define_with_value ("__SH5__",
125 TARGET_SHMEDIA64
? "64" : "32", 0);
126 builtin_define_with_value ("__SHMEDIA__",
127 TARGET_SHMEDIA
? "1" : "0", 0);
128 if (! TARGET_FPU_DOUBLE
)
129 builtin_define ("__SH4_NOFPU__");
133 builtin_define ("__SH_FPU_ANY__");
134 if (TARGET_FPU_DOUBLE
)
135 builtin_define ("__SH_FPU_DOUBLE__");
137 builtin_define ("__HITACHI__");
139 builtin_define ("__FMOVD_ENABLED__");
140 builtin_define (TARGET_LITTLE_ENDIAN
141 ? "__LITTLE_ENDIAN__" : "__BIG_ENDIAN__");
143 cpp_define_formatted (pfile
, "__SH_ATOMIC_MODEL_%s__",
144 selected_atomic_model ().cdef_name
);