/* Subroutines for the C front end on the TMS320C[34]x
|
/* Subroutines for the C front end on the TMS320C[34]x
|
Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
|
Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
|
2007 Free Software Foundation, Inc.
|
2007 Free Software Foundation, Inc.
|
|
|
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz)
|
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz)
|
and Herman Ten Brugge (Haj.Ten.Brugge@net.HCC.nl).
|
and Herman Ten Brugge (Haj.Ten.Brugge@net.HCC.nl).
|
|
|
This file is part of GCC.
|
This file is part of GCC.
|
|
|
GCC is free software; you can redistribute it and/or modify
|
GCC is free software; you can redistribute it and/or modify
|
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
the Free Software Foundation; either version 3, or (at your option)
|
the Free Software Foundation; either version 3, or (at your option)
|
any later version.
|
any later version.
|
|
|
GCC is distributed in the hope that it will be useful,
|
GCC is distributed in the hope that it will be useful,
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
GNU General Public License for more details.
|
GNU General Public License for more details.
|
|
|
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
along with GCC; see the file COPYING3. If not see
|
along with GCC; see the file COPYING3. If not see
|
<http://www.gnu.org/licenses/>. */
|
<http://www.gnu.org/licenses/>. */
|
|
|
#include "config.h"
|
#include "config.h"
|
#include "system.h"
|
#include "system.h"
|
#include "coretypes.h"
|
#include "coretypes.h"
|
#include "tm.h"
|
#include "tm.h"
|
#include "tree.h"
|
#include "tree.h"
|
#include "toplev.h"
|
#include "toplev.h"
|
#include "cpplib.h"
|
#include "cpplib.h"
|
#include "c-pragma.h"
|
#include "c-pragma.h"
|
#include "tm_p.h"
|
#include "tm_p.h"
|
|
|
static int c4x_parse_pragma (const char *, tree *, tree *);
|
static int c4x_parse_pragma (const char *, tree *, tree *);
|
|
|
/* Handle machine specific pragmas for compatibility with existing
|
/* Handle machine specific pragmas for compatibility with existing
|
compilers for the C3x/C4x.
|
compilers for the C3x/C4x.
|
|
|
pragma attribute
|
pragma attribute
|
----------------------------------------------------------
|
----------------------------------------------------------
|
CODE_SECTION(symbol,"section") section("section")
|
CODE_SECTION(symbol,"section") section("section")
|
DATA_SECTION(symbol,"section") section("section")
|
DATA_SECTION(symbol,"section") section("section")
|
FUNC_CANNOT_INLINE(function)
|
FUNC_CANNOT_INLINE(function)
|
FUNC_EXT_CALLED(function)
|
FUNC_EXT_CALLED(function)
|
FUNC_IS_PURE(function) const
|
FUNC_IS_PURE(function) const
|
FUNC_IS_SYSTEM(function)
|
FUNC_IS_SYSTEM(function)
|
FUNC_NEVER_RETURNS(function) noreturn
|
FUNC_NEVER_RETURNS(function) noreturn
|
FUNC_NO_GLOBAL_ASG(function)
|
FUNC_NO_GLOBAL_ASG(function)
|
FUNC_NO_IND_ASG(function)
|
FUNC_NO_IND_ASG(function)
|
INTERRUPT(function) interrupt
|
INTERRUPT(function) interrupt
|
|
|
*/
|
*/
|
|
|
/* Parse a C4x pragma, of the form ( function [, "section"] ) \n.
|
/* Parse a C4x pragma, of the form ( function [, "section"] ) \n.
|
FUNC is loaded with the IDENTIFIER_NODE of the function, SECT with
|
FUNC is loaded with the IDENTIFIER_NODE of the function, SECT with
|
the STRING_CST node of the string. If SECT is null, then this
|
the STRING_CST node of the string. If SECT is null, then this
|
pragma doesn't take a section string. Returns 0 for a good pragma,
|
pragma doesn't take a section string. Returns 0 for a good pragma,
|
-1 for a malformed pragma. */
|
-1 for a malformed pragma. */
|
#define BAD(gmsgid, arg) \
|
#define BAD(gmsgid, arg) \
|
do { warning (OPT_Wpragmas, gmsgid, arg); return -1; } while (0)
|
do { warning (OPT_Wpragmas, gmsgid, arg); return -1; } while (0)
|
|
|
static int
|
static int
|
c4x_parse_pragma (name, func, sect)
|
c4x_parse_pragma (name, func, sect)
|
const char *name;
|
const char *name;
|
tree *func;
|
tree *func;
|
tree *sect;
|
tree *sect;
|
{
|
{
|
tree f, s, x;
|
tree f, s, x;
|
|
|
if (pragma_lex (&x) != CPP_OPEN_PAREN)
|
if (pragma_lex (&x) != CPP_OPEN_PAREN)
|
BAD ("missing '(' after '#pragma %s' - ignored", name);
|
BAD ("missing '(' after '#pragma %s' - ignored", name);
|
|
|
if (pragma_lex (&f) != CPP_NAME)
|
if (pragma_lex (&f) != CPP_NAME)
|
BAD ("missing function name in '#pragma %s' - ignored", name);
|
BAD ("missing function name in '#pragma %s' - ignored", name);
|
|
|
if (sect)
|
if (sect)
|
{
|
{
|
if (pragma_lex (&x) != CPP_COMMA)
|
if (pragma_lex (&x) != CPP_COMMA)
|
BAD ("malformed '#pragma %s' - ignored", name);
|
BAD ("malformed '#pragma %s' - ignored", name);
|
if (pragma_lex (&s) != CPP_STRING)
|
if (pragma_lex (&s) != CPP_STRING)
|
BAD ("missing section name in '#pragma %s' - ignored", name);
|
BAD ("missing section name in '#pragma %s' - ignored", name);
|
*sect = s;
|
*sect = s;
|
}
|
}
|
|
|
if (pragma_lex (&x) != CPP_CLOSE_PAREN)
|
if (pragma_lex (&x) != CPP_CLOSE_PAREN)
|
BAD ("missing ')' for '#pragma %s' - ignored", name);
|
BAD ("missing ')' for '#pragma %s' - ignored", name);
|
|
|
if (pragma_lex (&x) != CPP_EOF)
|
if (pragma_lex (&x) != CPP_EOF)
|
warning (OPT_Wpragmas, "junk at end of '#pragma %s'", name);
|
warning (OPT_Wpragmas, "junk at end of '#pragma %s'", name);
|
|
|
*func = f;
|
*func = f;
|
return 0;
|
return 0;
|
}
|
}
|
|
|
void
|
void
|
c4x_pr_CODE_SECTION (pfile)
|
c4x_pr_CODE_SECTION (pfile)
|
cpp_reader *pfile ATTRIBUTE_UNUSED;
|
cpp_reader *pfile ATTRIBUTE_UNUSED;
|
{
|
{
|
tree func, sect;
|
tree func, sect;
|
|
|
if (c4x_parse_pragma ("CODE_SECTION", &func, §))
|
if (c4x_parse_pragma ("CODE_SECTION", &func, §))
|
return;
|
return;
|
code_tree = chainon (code_tree,
|
code_tree = chainon (code_tree,
|
build_tree_list (func,
|
build_tree_list (func,
|
build_tree_list (NULL_TREE, sect)));
|
build_tree_list (NULL_TREE, sect)));
|
}
|
}
|
|
|
void
|
void
|
c4x_pr_DATA_SECTION (pfile)
|
c4x_pr_DATA_SECTION (pfile)
|
cpp_reader *pfile ATTRIBUTE_UNUSED;
|
cpp_reader *pfile ATTRIBUTE_UNUSED;
|
{
|
{
|
tree func, sect;
|
tree func, sect;
|
|
|
if (c4x_parse_pragma ("DATA_SECTION", &func, §))
|
if (c4x_parse_pragma ("DATA_SECTION", &func, §))
|
return;
|
return;
|
data_tree = chainon (data_tree,
|
data_tree = chainon (data_tree,
|
build_tree_list (func,
|
build_tree_list (func,
|
build_tree_list (NULL_TREE, sect)));
|
build_tree_list (NULL_TREE, sect)));
|
}
|
}
|
|
|
void
|
void
|
c4x_pr_FUNC_IS_PURE (pfile)
|
c4x_pr_FUNC_IS_PURE (pfile)
|
cpp_reader *pfile ATTRIBUTE_UNUSED;
|
cpp_reader *pfile ATTRIBUTE_UNUSED;
|
{
|
{
|
tree func;
|
tree func;
|
|
|
if (c4x_parse_pragma ("FUNC_IS_PURE", &func, 0))
|
if (c4x_parse_pragma ("FUNC_IS_PURE", &func, 0))
|
return;
|
return;
|
pure_tree = chainon (pure_tree, build_tree_list (func, NULL_TREE));
|
pure_tree = chainon (pure_tree, build_tree_list (func, NULL_TREE));
|
}
|
}
|
|
|
void
|
void
|
c4x_pr_FUNC_NEVER_RETURNS (pfile)
|
c4x_pr_FUNC_NEVER_RETURNS (pfile)
|
cpp_reader *pfile ATTRIBUTE_UNUSED;
|
cpp_reader *pfile ATTRIBUTE_UNUSED;
|
{
|
{
|
tree func;
|
tree func;
|
|
|
if (c4x_parse_pragma ("FUNC_NEVER_RETURNS", &func, 0))
|
if (c4x_parse_pragma ("FUNC_NEVER_RETURNS", &func, 0))
|
return;
|
return;
|
noreturn_tree = chainon (noreturn_tree, build_tree_list (func, NULL_TREE));
|
noreturn_tree = chainon (noreturn_tree, build_tree_list (func, NULL_TREE));
|
}
|
}
|
|
|
void
|
void
|
c4x_pr_INTERRUPT (pfile)
|
c4x_pr_INTERRUPT (pfile)
|
cpp_reader *pfile ATTRIBUTE_UNUSED;
|
cpp_reader *pfile ATTRIBUTE_UNUSED;
|
{
|
{
|
tree func;
|
tree func;
|
|
|
if (c4x_parse_pragma ("INTERRUPT", &func, 0))
|
if (c4x_parse_pragma ("INTERRUPT", &func, 0))
|
return;
|
return;
|
interrupt_tree = chainon (interrupt_tree, build_tree_list (func, NULL_TREE));
|
interrupt_tree = chainon (interrupt_tree, build_tree_list (func, NULL_TREE));
|
}
|
}
|
|
|
/* Used for FUNC_CANNOT_INLINE, FUNC_EXT_CALLED, FUNC_IS_SYSTEM,
|
/* Used for FUNC_CANNOT_INLINE, FUNC_EXT_CALLED, FUNC_IS_SYSTEM,
|
FUNC_NO_GLOBAL_ASG, and FUNC_NO_IND_ASG. */
|
FUNC_NO_GLOBAL_ASG, and FUNC_NO_IND_ASG. */
|
void
|
void
|
c4x_pr_ignored (pfile)
|
c4x_pr_ignored (pfile)
|
cpp_reader *pfile ATTRIBUTE_UNUSED;
|
cpp_reader *pfile ATTRIBUTE_UNUSED;
|
{
|
{
|
}
|
}
|
|
|