OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [config/] [v850/] [v850-c.c] - Diff between revs 38 and 154

Only display areas with differences | Details | Blame | View Log

Rev 38 Rev 154
/* v850 specific, C compiler specific functions.
/* v850 specific, C compiler specific functions.
   Copyright (C) 2000, 2007 Free Software Foundation, Inc.
   Copyright (C) 2000, 2007 Free Software Foundation, Inc.
   Contributed by Jeff Law (law@cygnus.com).
   Contributed by Jeff Law (law@cygnus.com).
 
 
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 "cpplib.h"
#include "cpplib.h"
#include "tree.h"
#include "tree.h"
#include "c-pragma.h"
#include "c-pragma.h"
#include "toplev.h"
#include "toplev.h"
#include "ggc.h"
#include "ggc.h"
#include "tm_p.h"
#include "tm_p.h"
 
 
#ifndef streq
#ifndef streq
#define streq(a,b) (strcmp (a, b) == 0)
#define streq(a,b) (strcmp (a, b) == 0)
#endif
#endif


static int  pop_data_area          (v850_data_area);
static int  pop_data_area          (v850_data_area);
static int  push_data_area         (v850_data_area);
static int  push_data_area         (v850_data_area);
static void mark_current_function_as_interrupt (void);
static void mark_current_function_as_interrupt (void);


/* Push a data area onto the stack.  */
/* Push a data area onto the stack.  */
 
 
static int
static int
push_data_area (v850_data_area data_area)
push_data_area (v850_data_area data_area)
{
{
  data_area_stack_element * elem;
  data_area_stack_element * elem;
 
 
  elem = (data_area_stack_element *) xmalloc (sizeof (* elem));
  elem = (data_area_stack_element *) xmalloc (sizeof (* elem));
 
 
  if (elem == NULL)
  if (elem == NULL)
    return 0;
    return 0;
 
 
  elem->prev      = data_area_stack;
  elem->prev      = data_area_stack;
  elem->data_area = data_area;
  elem->data_area = data_area;
 
 
  data_area_stack = elem;
  data_area_stack = elem;
 
 
  return 1;
  return 1;
}
}
 
 
/* Remove a data area from the stack.  */
/* Remove a data area from the stack.  */
 
 
static int
static int
pop_data_area (v850_data_area data_area)
pop_data_area (v850_data_area data_area)
{
{
  if (data_area_stack == NULL)
  if (data_area_stack == NULL)
    warning (OPT_Wpragmas, "#pragma GHS endXXXX found without "
    warning (OPT_Wpragmas, "#pragma GHS endXXXX found without "
             "previous startXXX");
             "previous startXXX");
  else if (data_area != data_area_stack->data_area)
  else if (data_area != data_area_stack->data_area)
    warning (OPT_Wpragmas, "#pragma GHS endXXX does not match "
    warning (OPT_Wpragmas, "#pragma GHS endXXX does not match "
             "previous startXXX");
             "previous startXXX");
  else
  else
    {
    {
      data_area_stack_element * elem;
      data_area_stack_element * elem;
 
 
      elem = data_area_stack;
      elem = data_area_stack;
      data_area_stack = data_area_stack->prev;
      data_area_stack = data_area_stack->prev;
 
 
      free (elem);
      free (elem);
 
 
      return 1;
      return 1;
    }
    }
 
 
  return 0;
  return 0;
}
}
 
 
/* Set the machine specific 'interrupt' attribute on the current function.  */
/* Set the machine specific 'interrupt' attribute on the current function.  */
 
 
static void
static void
mark_current_function_as_interrupt (void)
mark_current_function_as_interrupt (void)
{
{
  tree name;
  tree name;
 
 
  if (current_function_decl ==  NULL_TREE)
  if (current_function_decl ==  NULL_TREE)
    {
    {
      warning (0, "cannot set interrupt attribute: no current function");
      warning (0, "cannot set interrupt attribute: no current function");
      return;
      return;
    }
    }
 
 
  name = get_identifier ("interrupt");
  name = get_identifier ("interrupt");
 
 
  if (name == NULL_TREE || TREE_CODE (name) != IDENTIFIER_NODE)
  if (name == NULL_TREE || TREE_CODE (name) != IDENTIFIER_NODE)
    {
    {
      warning (0, "cannot set interrupt attribute: no such identifier");
      warning (0, "cannot set interrupt attribute: no such identifier");
      return;
      return;
    }
    }
 
 
  decl_attributes (&current_function_decl,
  decl_attributes (&current_function_decl,
                   tree_cons (name, NULL_TREE, NULL_TREE), 0);
                   tree_cons (name, NULL_TREE, NULL_TREE), 0);
}
}
 
 


/* Support for GHS pragmata.  */
/* Support for GHS pragmata.  */
 
 
void
void
ghs_pragma_section (cpp_reader * pfile ATTRIBUTE_UNUSED)
ghs_pragma_section (cpp_reader * pfile ATTRIBUTE_UNUSED)
{
{
  int repeat;
  int repeat;
 
 
  /* #pragma ghs section [name = alias [, name = alias [, ...]]] */
  /* #pragma ghs section [name = alias [, name = alias [, ...]]] */
  do
  do
    {
    {
      tree x;
      tree x;
      enum cpp_ttype type;
      enum cpp_ttype type;
      const char *sect, *alias;
      const char *sect, *alias;
      enum GHS_section_kind kind;
      enum GHS_section_kind kind;
 
 
      type = pragma_lex (&x);
      type = pragma_lex (&x);
 
 
      if (type == CPP_EOF && !repeat)
      if (type == CPP_EOF && !repeat)
        goto reset;
        goto reset;
      else if (type == CPP_NAME)
      else if (type == CPP_NAME)
        sect = IDENTIFIER_POINTER (x);
        sect = IDENTIFIER_POINTER (x);
      else
      else
        goto bad;
        goto bad;
      repeat = 0;
      repeat = 0;
 
 
      if (pragma_lex (&x) != CPP_EQ)
      if (pragma_lex (&x) != CPP_EQ)
        goto bad;
        goto bad;
      if (pragma_lex (&x) != CPP_NAME)
      if (pragma_lex (&x) != CPP_NAME)
        goto bad;
        goto bad;
 
 
      alias = IDENTIFIER_POINTER (x);
      alias = IDENTIFIER_POINTER (x);
 
 
      type = pragma_lex (&x);
      type = pragma_lex (&x);
      if (type == CPP_COMMA)
      if (type == CPP_COMMA)
        repeat = 1;
        repeat = 1;
      else if (type != CPP_EOF)
      else if (type != CPP_EOF)
        warning (OPT_Wpragmas, "junk at end of #pragma ghs section");
        warning (OPT_Wpragmas, "junk at end of #pragma ghs section");
 
 
      if      (streq (sect, "data"))    kind = GHS_SECTION_KIND_DATA;
      if      (streq (sect, "data"))    kind = GHS_SECTION_KIND_DATA;
      else if (streq (sect, "text"))    kind = GHS_SECTION_KIND_TEXT;
      else if (streq (sect, "text"))    kind = GHS_SECTION_KIND_TEXT;
      else if (streq (sect, "rodata"))  kind = GHS_SECTION_KIND_RODATA;
      else if (streq (sect, "rodata"))  kind = GHS_SECTION_KIND_RODATA;
      else if (streq (sect, "const"))   kind = GHS_SECTION_KIND_RODATA;
      else if (streq (sect, "const"))   kind = GHS_SECTION_KIND_RODATA;
      else if (streq (sect, "rosdata")) kind = GHS_SECTION_KIND_ROSDATA;
      else if (streq (sect, "rosdata")) kind = GHS_SECTION_KIND_ROSDATA;
      else if (streq (sect, "rozdata")) kind = GHS_SECTION_KIND_ROZDATA;
      else if (streq (sect, "rozdata")) kind = GHS_SECTION_KIND_ROZDATA;
      else if (streq (sect, "sdata"))   kind = GHS_SECTION_KIND_SDATA;
      else if (streq (sect, "sdata"))   kind = GHS_SECTION_KIND_SDATA;
      else if (streq (sect, "tdata"))   kind = GHS_SECTION_KIND_TDATA;
      else if (streq (sect, "tdata"))   kind = GHS_SECTION_KIND_TDATA;
      else if (streq (sect, "zdata"))   kind = GHS_SECTION_KIND_ZDATA;
      else if (streq (sect, "zdata"))   kind = GHS_SECTION_KIND_ZDATA;
      /* According to GHS beta documentation, the following should not be
      /* According to GHS beta documentation, the following should not be
         allowed!  */
         allowed!  */
      else if (streq (sect, "bss"))     kind = GHS_SECTION_KIND_BSS;
      else if (streq (sect, "bss"))     kind = GHS_SECTION_KIND_BSS;
      else if (streq (sect, "zbss"))    kind = GHS_SECTION_KIND_ZDATA;
      else if (streq (sect, "zbss"))    kind = GHS_SECTION_KIND_ZDATA;
      else
      else
        {
        {
          warning (0, "unrecognized section name \"%s\"", sect);
          warning (0, "unrecognized section name \"%s\"", sect);
          return;
          return;
        }
        }
 
 
      if (streq (alias, "default"))
      if (streq (alias, "default"))
        GHS_current_section_names [kind] = NULL;
        GHS_current_section_names [kind] = NULL;
      else
      else
        GHS_current_section_names [kind] =
        GHS_current_section_names [kind] =
          build_string (strlen (alias) + 1, alias);
          build_string (strlen (alias) + 1, alias);
    }
    }
  while (repeat);
  while (repeat);
 
 
  return;
  return;
 
 
 bad:
 bad:
  warning (OPT_Wpragmas, "malformed #pragma ghs section");
  warning (OPT_Wpragmas, "malformed #pragma ghs section");
  return;
  return;
 
 
 reset:
 reset:
  /* #pragma ghs section \n: Reset all section names back to their defaults.  */
  /* #pragma ghs section \n: Reset all section names back to their defaults.  */
  {
  {
    int i;
    int i;
 
 
    for (i = COUNT_OF_GHS_SECTION_KINDS; i--;)
    for (i = COUNT_OF_GHS_SECTION_KINDS; i--;)
      GHS_current_section_names [i] = NULL;
      GHS_current_section_names [i] = NULL;
  }
  }
}
}
 
 
void
void
ghs_pragma_interrupt (cpp_reader * pfile ATTRIBUTE_UNUSED)
ghs_pragma_interrupt (cpp_reader * pfile ATTRIBUTE_UNUSED)
{
{
  tree x;
  tree x;
 
 
  if (pragma_lex (&x) != CPP_EOF)
  if (pragma_lex (&x) != CPP_EOF)
    warning (OPT_Wpragmas, "junk at end of #pragma ghs interrupt");
    warning (OPT_Wpragmas, "junk at end of #pragma ghs interrupt");
 
 
  mark_current_function_as_interrupt ();
  mark_current_function_as_interrupt ();
}
}
 
 
void
void
ghs_pragma_starttda (cpp_reader * pfile ATTRIBUTE_UNUSED)
ghs_pragma_starttda (cpp_reader * pfile ATTRIBUTE_UNUSED)
{
{
  tree x;
  tree x;
 
 
  if (pragma_lex (&x) != CPP_EOF)
  if (pragma_lex (&x) != CPP_EOF)
    warning (OPT_Wpragmas, "junk at end of #pragma ghs starttda");
    warning (OPT_Wpragmas, "junk at end of #pragma ghs starttda");
 
 
  push_data_area (DATA_AREA_TDA);
  push_data_area (DATA_AREA_TDA);
}
}
 
 
void
void
ghs_pragma_startsda (cpp_reader * pfile ATTRIBUTE_UNUSED)
ghs_pragma_startsda (cpp_reader * pfile ATTRIBUTE_UNUSED)
{
{
  tree x;
  tree x;
 
 
  if (pragma_lex (&x) != CPP_EOF)
  if (pragma_lex (&x) != CPP_EOF)
    warning (OPT_Wpragmas, "junk at end of #pragma ghs startsda");
    warning (OPT_Wpragmas, "junk at end of #pragma ghs startsda");
 
 
  push_data_area (DATA_AREA_SDA);
  push_data_area (DATA_AREA_SDA);
}
}
 
 
void
void
ghs_pragma_startzda (cpp_reader * pfile ATTRIBUTE_UNUSED)
ghs_pragma_startzda (cpp_reader * pfile ATTRIBUTE_UNUSED)
{
{
  tree x;
  tree x;
 
 
  if (pragma_lex (&x) != CPP_EOF)
  if (pragma_lex (&x) != CPP_EOF)
    warning (OPT_Wpragmas, "junk at end of #pragma ghs startzda");
    warning (OPT_Wpragmas, "junk at end of #pragma ghs startzda");
 
 
  push_data_area (DATA_AREA_ZDA);
  push_data_area (DATA_AREA_ZDA);
}
}
 
 
void
void
ghs_pragma_endtda (cpp_reader * pfile ATTRIBUTE_UNUSED)
ghs_pragma_endtda (cpp_reader * pfile ATTRIBUTE_UNUSED)
{
{
  tree x;
  tree x;
 
 
  if (pragma_lex (&x) != CPP_EOF)
  if (pragma_lex (&x) != CPP_EOF)
    warning (OPT_Wpragmas, "junk at end of #pragma ghs endtda");
    warning (OPT_Wpragmas, "junk at end of #pragma ghs endtda");
 
 
  pop_data_area (DATA_AREA_TDA);
  pop_data_area (DATA_AREA_TDA);
}
}
 
 
void
void
ghs_pragma_endsda (cpp_reader * pfile ATTRIBUTE_UNUSED)
ghs_pragma_endsda (cpp_reader * pfile ATTRIBUTE_UNUSED)
{
{
  tree x;
  tree x;
 
 
  if (pragma_lex (&x) != CPP_EOF)
  if (pragma_lex (&x) != CPP_EOF)
    warning (OPT_Wpragmas, "junk at end of #pragma ghs endsda");
    warning (OPT_Wpragmas, "junk at end of #pragma ghs endsda");
 
 
  pop_data_area (DATA_AREA_SDA);
  pop_data_area (DATA_AREA_SDA);
}
}
 
 
void
void
ghs_pragma_endzda (cpp_reader * pfile ATTRIBUTE_UNUSED)
ghs_pragma_endzda (cpp_reader * pfile ATTRIBUTE_UNUSED)
{
{
  tree x;
  tree x;
 
 
  if (pragma_lex (&x) != CPP_EOF)
  if (pragma_lex (&x) != CPP_EOF)
    warning (OPT_Wpragmas, "junk at end of #pragma ghs endzda");
    warning (OPT_Wpragmas, "junk at end of #pragma ghs endzda");
 
 
  pop_data_area (DATA_AREA_ZDA);
  pop_data_area (DATA_AREA_ZDA);
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.