1 /* Subroutines for the C front end on the TMS320C[34]x
2 Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
5 Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz)
6 and Herman Ten Brugge (Haj.Ten.Brugge@net.HCC.nl).
8 This file is part of GCC.
10 GCC is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
15 GCC is distributed in the hope that it will be useful,
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.
20 You should have received a copy of the GNU General Public License
21 along with GCC; see the file COPYING. If not, write to
22 the Free Software Foundation, 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
27 #include "coretypes.h"
35 static int c4x_parse_pragma (const char *, tree
*, tree
*);
37 /* Handle machine specific pragmas for compatibility with existing
38 compilers for the C3x/C4x.
41 ----------------------------------------------------------
42 CODE_SECTION(symbol,"section") section("section")
43 DATA_SECTION(symbol,"section") section("section")
44 FUNC_CANNOT_INLINE(function)
45 FUNC_EXT_CALLED(function)
46 FUNC_IS_PURE(function) const
47 FUNC_IS_SYSTEM(function)
48 FUNC_NEVER_RETURNS(function) noreturn
49 FUNC_NO_GLOBAL_ASG(function)
50 FUNC_NO_IND_ASG(function)
51 INTERRUPT(function) interrupt
55 /* Parse a C4x pragma, of the form ( function [, "section"] ) \n.
56 FUNC is loaded with the IDENTIFIER_NODE of the function, SECT with
57 the STRING_CST node of the string. If SECT is null, then this
58 pragma doesn't take a section string. Returns 0 for a good pragma,
59 -1 for a malformed pragma. */
60 #define BAD(msgid, arg) do { warning (msgid, arg); return -1; } while (0)
63 c4x_parse_pragma (name
, func
, sect
)
70 if (c_lex (&x
) != CPP_OPEN_PAREN
)
71 BAD ("missing '(' after '#pragma %s' - ignored", name
);
73 if (c_lex (&f
) != CPP_NAME
)
74 BAD ("missing function name in '#pragma %s' - ignored", name
);
78 if (c_lex (&x
) != CPP_COMMA
)
79 BAD ("malformed '#pragma %s' - ignored", name
);
80 if (c_lex (&s
) != CPP_STRING
)
81 BAD ("missing section name in '#pragma %s' - ignored", name
);
85 if (c_lex (&x
) != CPP_CLOSE_PAREN
)
86 BAD ("missing ')' for '#pragma %s' - ignored", name
);
88 if (c_lex (&x
) != CPP_EOF
)
89 warning ("junk at end of '#pragma %s'", name
);
96 c4x_pr_CODE_SECTION (pfile
)
97 cpp_reader
*pfile ATTRIBUTE_UNUSED
;
101 if (c4x_parse_pragma ("CODE_SECTION", &func
, §
))
103 code_tree
= chainon (code_tree
,
104 build_tree_list (func
,
105 build_tree_list (NULL_TREE
, sect
)));
109 c4x_pr_DATA_SECTION (pfile
)
110 cpp_reader
*pfile ATTRIBUTE_UNUSED
;
114 if (c4x_parse_pragma ("DATA_SECTION", &func
, §
))
116 data_tree
= chainon (data_tree
,
117 build_tree_list (func
,
118 build_tree_list (NULL_TREE
, sect
)));
122 c4x_pr_FUNC_IS_PURE (pfile
)
123 cpp_reader
*pfile ATTRIBUTE_UNUSED
;
127 if (c4x_parse_pragma ("FUNC_IS_PURE", &func
, 0))
129 pure_tree
= chainon (pure_tree
, build_tree_list (func
, NULL_TREE
));
133 c4x_pr_FUNC_NEVER_RETURNS (pfile
)
134 cpp_reader
*pfile ATTRIBUTE_UNUSED
;
138 if (c4x_parse_pragma ("FUNC_NEVER_RETURNS", &func
, 0))
140 noreturn_tree
= chainon (noreturn_tree
, build_tree_list (func
, NULL_TREE
));
144 c4x_pr_INTERRUPT (pfile
)
145 cpp_reader
*pfile ATTRIBUTE_UNUSED
;
149 if (c4x_parse_pragma ("INTERRUPT", &func
, 0))
151 interrupt_tree
= chainon (interrupt_tree
, build_tree_list (func
, NULL_TREE
));
154 /* Used for FUNC_CANNOT_INLINE, FUNC_EXT_CALLED, FUNC_IS_SYSTEM,
155 FUNC_NO_GLOBAL_ASG, and FUNC_NO_IND_ASG. */
157 c4x_pr_ignored (pfile
)
158 cpp_reader
*pfile ATTRIBUTE_UNUSED
;