]>
Commit | Line | Data |
---|---|---|
51fabca5 | 1 | /* Subroutines for the C front end on the TMS320C[34]x |
2f83c7d6 NC |
2 | Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, |
3 | 2007 Free Software Foundation, Inc. | |
51fabca5 NB |
4 | |
5 | Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz) | |
6 | and Herman Ten Brugge (Haj.Ten.Brugge@net.HCC.nl). | |
7 | ||
4db9c756 | 8 | This file is part of GCC. |
51fabca5 | 9 | |
4db9c756 | 10 | GCC is free software; you can redistribute it and/or modify |
51fabca5 | 11 | it under the terms of the GNU General Public License as published by |
2f83c7d6 | 12 | the Free Software Foundation; either version 3, or (at your option) |
51fabca5 NB |
13 | any later version. |
14 | ||
4db9c756 | 15 | GCC is distributed in the hope that it will be useful, |
51fabca5 NB |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | GNU General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU General Public License | |
2f83c7d6 NC |
21 | along with GCC; see the file COPYING3. If not see |
22 | <http://www.gnu.org/licenses/>. */ | |
51fabca5 NB |
23 | |
24 | #include "config.h" | |
25 | #include "system.h" | |
4977bab6 ZW |
26 | #include "coretypes.h" |
27 | #include "tm.h" | |
51fabca5 NB |
28 | #include "tree.h" |
29 | #include "toplev.h" | |
30 | #include "cpplib.h" | |
31 | #include "c-pragma.h" | |
245ff137 | 32 | #include "tm_p.h" |
51fabca5 | 33 | |
f12b3fc8 | 34 | static int c4x_parse_pragma (const char *, tree *, tree *); |
51fabca5 NB |
35 | |
36 | /* Handle machine specific pragmas for compatibility with existing | |
37 | compilers for the C3x/C4x. | |
38 | ||
39 | pragma attribute | |
40 | ---------------------------------------------------------- | |
41 | CODE_SECTION(symbol,"section") section("section") | |
42 | DATA_SECTION(symbol,"section") section("section") | |
43 | FUNC_CANNOT_INLINE(function) | |
44 | FUNC_EXT_CALLED(function) | |
45 | FUNC_IS_PURE(function) const | |
46 | FUNC_IS_SYSTEM(function) | |
47 | FUNC_NEVER_RETURNS(function) noreturn | |
48 | FUNC_NO_GLOBAL_ASG(function) | |
49 | FUNC_NO_IND_ASG(function) | |
50 | INTERRUPT(function) interrupt | |
51 | ||
52 | */ | |
53 | ||
54 | /* Parse a C4x pragma, of the form ( function [, "section"] ) \n. | |
55 | FUNC is loaded with the IDENTIFIER_NODE of the function, SECT with | |
56 | the STRING_CST node of the string. If SECT is null, then this | |
57 | pragma doesn't take a section string. Returns 0 for a good pragma, | |
58 | -1 for a malformed pragma. */ | |
b9b8dde3 DD |
59 | #define BAD(gmsgid, arg) \ |
60 | do { warning (OPT_Wpragmas, gmsgid, arg); return -1; } while (0) | |
51fabca5 NB |
61 | |
62 | static int | |
586de218 | 63 | c4x_parse_pragma (const char *name, tree *func, tree *sect) |
51fabca5 NB |
64 | { |
65 | tree f, s, x; | |
66 | ||
75ce3d48 | 67 | if (pragma_lex (&x) != CPP_OPEN_PAREN) |
51fabca5 NB |
68 | BAD ("missing '(' after '#pragma %s' - ignored", name); |
69 | ||
75ce3d48 | 70 | if (pragma_lex (&f) != CPP_NAME) |
51fabca5 NB |
71 | BAD ("missing function name in '#pragma %s' - ignored", name); |
72 | ||
73 | if (sect) | |
74 | { | |
75ce3d48 | 75 | if (pragma_lex (&x) != CPP_COMMA) |
51fabca5 | 76 | BAD ("malformed '#pragma %s' - ignored", name); |
75ce3d48 | 77 | if (pragma_lex (&s) != CPP_STRING) |
51fabca5 NB |
78 | BAD ("missing section name in '#pragma %s' - ignored", name); |
79 | *sect = s; | |
80 | } | |
81 | ||
75ce3d48 | 82 | if (pragma_lex (&x) != CPP_CLOSE_PAREN) |
51fabca5 NB |
83 | BAD ("missing ')' for '#pragma %s' - ignored", name); |
84 | ||
75ce3d48 | 85 | if (pragma_lex (&x) != CPP_EOF) |
b9b8dde3 | 86 | warning (OPT_Wpragmas, "junk at end of '#pragma %s'", name); |
51fabca5 NB |
87 | |
88 | *func = f; | |
89 | return 0; | |
90 | } | |
91 | ||
92 | void | |
586de218 | 93 | c4x_pr_CODE_SECTION (cpp_reader *pfile ATTRIBUTE_UNUSED) |
51fabca5 NB |
94 | { |
95 | tree func, sect; | |
96 | ||
97 | if (c4x_parse_pragma ("CODE_SECTION", &func, §)) | |
98 | return; | |
99 | code_tree = chainon (code_tree, | |
100 | build_tree_list (func, | |
101 | build_tree_list (NULL_TREE, sect))); | |
102 | } | |
103 | ||
104 | void | |
586de218 | 105 | c4x_pr_DATA_SECTION (cpp_reader *pfile ATTRIBUTE_UNUSED) |
51fabca5 NB |
106 | { |
107 | tree func, sect; | |
108 | ||
109 | if (c4x_parse_pragma ("DATA_SECTION", &func, §)) | |
110 | return; | |
111 | data_tree = chainon (data_tree, | |
112 | build_tree_list (func, | |
113 | build_tree_list (NULL_TREE, sect))); | |
114 | } | |
115 | ||
116 | void | |
586de218 | 117 | c4x_pr_FUNC_IS_PURE (cpp_reader *pfile ATTRIBUTE_UNUSED) |
51fabca5 NB |
118 | { |
119 | tree func; | |
120 | ||
121 | if (c4x_parse_pragma ("FUNC_IS_PURE", &func, 0)) | |
122 | return; | |
123 | pure_tree = chainon (pure_tree, build_tree_list (func, NULL_TREE)); | |
124 | } | |
125 | ||
126 | void | |
586de218 | 127 | c4x_pr_FUNC_NEVER_RETURNS (cpp_reader *pfile ATTRIBUTE_UNUSED) |
51fabca5 NB |
128 | { |
129 | tree func; | |
130 | ||
131 | if (c4x_parse_pragma ("FUNC_NEVER_RETURNS", &func, 0)) | |
132 | return; | |
133 | noreturn_tree = chainon (noreturn_tree, build_tree_list (func, NULL_TREE)); | |
134 | } | |
135 | ||
136 | void | |
586de218 | 137 | c4x_pr_INTERRUPT (cpp_reader *pfile ATTRIBUTE_UNUSED) |
51fabca5 NB |
138 | { |
139 | tree func; | |
140 | ||
141 | if (c4x_parse_pragma ("INTERRUPT", &func, 0)) | |
142 | return; | |
143 | interrupt_tree = chainon (interrupt_tree, build_tree_list (func, NULL_TREE)); | |
144 | } | |
145 | ||
146 | /* Used for FUNC_CANNOT_INLINE, FUNC_EXT_CALLED, FUNC_IS_SYSTEM, | |
147 | FUNC_NO_GLOBAL_ASG, and FUNC_NO_IND_ASG. */ | |
148 | void | |
586de218 | 149 | c4x_pr_ignored (cpp_reader *pfile ATTRIBUTE_UNUSED) |
51fabca5 NB |
150 | { |
151 | } |