]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/sh/sh-c.c
2015-07-07 Andrew MacLeod <amacleod@redhat.com>
[thirdparty/gcc.git] / gcc / config / sh / sh-c.c
CommitLineData
57d5535b 1/* Pragma handling for GCC for Renesas / SuperH SH.
d353bf18 2 Copyright (C) 1993-2015 Free Software Foundation, Inc.
57d5535b 3 Contributed by Joern Rennecke <joern.rennecke@st.com>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
038d1e19 9the Free Software Foundation; either version 3, or (at your option)
57d5535b 10any later version.
11
12GCC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
038d1e19 18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
57d5535b 20
21#include "config.h"
22#include "system.h"
23#include "coretypes.h"
24#include "tm.h"
b20a8bb4 25#include "alias.h"
57d5535b 26#include "tree.h"
9ed99284 27#include "stringpool.h"
f616b318 28#include "attribs.h"
57d5535b 29#include "tm_p.h"
cfaba078 30#include "cpplib.h"
31#include "c-family/c-common.h"
32#include "target.h"
57d5535b 33
34/* Handle machine specific pragmas to be semi-compatible with Renesas
35 compiler. */
36
37/* Add ATTR to the attributes of the current function. If there is no
38 such function, save it to be added to the attributes of the next
39 function. */
40static void
41sh_add_function_attribute (const char *attr)
42{
43 tree id = get_identifier (attr);
44
45 if (current_function_decl)
46 decl_attributes (&current_function_decl,
47 tree_cons (id, NULL_TREE, NULL_TREE), 0);
48 else
49 {
50 *sh_deferred_function_attributes_tail
51 = tree_cons (id, NULL_TREE, *sh_deferred_function_attributes_tail);
52 sh_deferred_function_attributes_tail
53 = &TREE_CHAIN (*sh_deferred_function_attributes_tail);
54 }
55}
56
57void
58sh_pr_interrupt (struct cpp_reader *pfile ATTRIBUTE_UNUSED)
59{
60 sh_add_function_attribute ("interrupt_handler");
61}
62
63void
64sh_pr_trapa (struct cpp_reader *pfile ATTRIBUTE_UNUSED)
65{
66 sh_add_function_attribute ("trapa_handler");
67}
68
69void
70sh_pr_nosave_low_regs (struct cpp_reader *pfile ATTRIBUTE_UNUSED)
71{
72 sh_add_function_attribute ("nosave_low_regs");
73}
cfaba078 74
75#define builtin_define(TXT) cpp_define (pfile, TXT)
76#define builtin_assert(TXT) cpp_assert (pfile, TXT)
77
78/* Implement the TARGET_CPU_CPP_BUILTINS macro */
79void
80sh_cpu_cpp_builtins (cpp_reader* pfile)
81{
82 builtin_define ("__sh__");
83 builtin_assert ("cpu=sh");
84 builtin_assert ("machine=sh");
85 switch ((int) sh_cpu)
86 {
87 case PROCESSOR_SH1:
88 builtin_define ("__sh1__");
89 builtin_define ("__SH1__");
90 break;
91 case PROCESSOR_SH2:
92 builtin_define ("__sh2__");
93 builtin_define ("__SH2__");
94 break;
95 case PROCESSOR_SH2E:
96 builtin_define ("__SH2E__");
97 break;
98 case PROCESSOR_SH2A:
99 builtin_define ("__SH2A__");
100 if (TARGET_SH2A_DOUBLE)
101 builtin_define (TARGET_FPU_SINGLE
102 ? "__SH2A_SINGLE__" : "__SH2A_DOUBLE__");
103 else
104 builtin_define (TARGET_FPU_ANY
105 ? "__SH2A_SINGLE_ONLY__" : "__SH2A_NOFPU__");
106 break;
107 case PROCESSOR_SH3:
108 builtin_define ("__sh3__");
109 builtin_define ("__SH3__");
110 if (TARGET_HARD_SH4)
111 builtin_define ("__SH4_NOFPU__");
112 break;
113 case PROCESSOR_SH3E:
114 builtin_define (TARGET_HARD_SH4 ? "__SH4_SINGLE_ONLY__" : "__SH3E__");
115 break;
116 case PROCESSOR_SH4:
117 builtin_define (TARGET_FPU_SINGLE ? "__SH4_SINGLE__" : "__SH4__");
118 break;
119 case PROCESSOR_SH4A: \
120 builtin_define ("__SH4A__");
121 builtin_define (TARGET_SH4
122 ? (TARGET_FPU_SINGLE ? "__SH4_SINGLE__" : "__SH4__")
123 : TARGET_FPU_ANY ? "__SH4_SINGLE_ONLY__"
124 : "__SH4_NOFPU__");
125 break;
126 case PROCESSOR_SH5:
127 {
128 builtin_define_with_value ("__SH5__",
129 TARGET_SHMEDIA64 ? "64" : "32", 0);
130 builtin_define_with_value ("__SHMEDIA__",
131 TARGET_SHMEDIA ? "1" : "0", 0);
132 if (! TARGET_FPU_DOUBLE)
133 builtin_define ("__SH4_NOFPU__");
134 }
135 }
136 if (TARGET_FPU_ANY)
137 builtin_define ("__SH_FPU_ANY__");
138 if (TARGET_FPU_DOUBLE)
139 builtin_define ("__SH_FPU_DOUBLE__");
140 if (TARGET_HITACHI)
141 builtin_define ("__HITACHI__");
142 if (TARGET_FMOVD)
143 builtin_define ("__FMOVD_ENABLED__");
144 builtin_define (TARGET_LITTLE_ENDIAN
145 ? "__LITTLE_ENDIAN__" : "__BIG_ENDIAN__");
146
147 cpp_define_formatted (pfile, "__SH_ATOMIC_MODEL_%s__",
148 selected_atomic_model ().cdef_name);
149}