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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-dev/] [fsf-gcc-snapshot-1-mar-12/] [or1k-gcc/] [gcc/] [genattr-common.c] - Diff between revs 684 and 783

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 684 Rev 783
/* Generate attribute information shared between driver and core
/* Generate attribute information shared between driver and core
   compilers (insn-attr-common.h) from machine description.  Split out
   compilers (insn-attr-common.h) from machine description.  Split out
   of genattr.c.
   of genattr.c.
   Copyright (C) 1991, 1994, 1996, 1998, 1999, 2000, 2003, 2004, 2007, 2008,
   Copyright (C) 1991, 1994, 1996, 1998, 1999, 2000, 2003, 2004, 2007, 2008,
   2010, 2011  Free Software Foundation, Inc.
   2010, 2011  Free Software Foundation, Inc.
 
 
This file is part of GCC.
This file is part of GCC.
 
 
GCC is free software; you can redistribute it and/or modify it under
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
Software Foundation; either version 3, or (at your option) any later
version.
version.
 
 
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.
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 "bconfig.h"
#include "bconfig.h"
#include "system.h"
#include "system.h"
#include "coretypes.h"
#include "coretypes.h"
#include "tm.h"
#include "tm.h"
#include "rtl.h"
#include "rtl.h"
#include "errors.h"
#include "errors.h"
#include "read-md.h"
#include "read-md.h"
#include "gensupport.h"
#include "gensupport.h"
 
 
static void
static void
write_upcase (const char *str)
write_upcase (const char *str)
{
{
  for (; *str; str++)
  for (; *str; str++)
    putchar (TOUPPER(*str));
    putchar (TOUPPER(*str));
}
}
 
 
static void
static void
gen_attr (rtx attr)
gen_attr (rtx attr)
{
{
  const char *p, *tag;
  const char *p, *tag;
 
 
  p = XSTR (attr, 1);
  p = XSTR (attr, 1);
  if (*p != '\0')
  if (*p != '\0')
    {
    {
      printf ("enum attr_%s {", XSTR (attr, 0));
      printf ("enum attr_%s {", XSTR (attr, 0));
 
 
      while ((tag = scan_comma_elt (&p)) != 0)
      while ((tag = scan_comma_elt (&p)) != 0)
        {
        {
          write_upcase (XSTR (attr, 0));
          write_upcase (XSTR (attr, 0));
          putchar ('_');
          putchar ('_');
          while (tag != p)
          while (tag != p)
            putchar (TOUPPER (*tag++));
            putchar (TOUPPER (*tag++));
          if (*p == ',')
          if (*p == ',')
            fputs (", ", stdout);
            fputs (", ", stdout);
        }
        }
      fputs ("};\n", stdout);
      fputs ("};\n", stdout);
    }
    }
}
}
 
 
int
int
main (int argc, char **argv)
main (int argc, char **argv)
{
{
  rtx desc;
  rtx desc;
  bool have_delay = false;
  bool have_delay = false;
  bool have_sched = false;
  bool have_sched = false;
 
 
  progname = "genattr-common";
  progname = "genattr-common";
 
 
  if (!init_rtx_reader_args (argc, argv))
  if (!init_rtx_reader_args (argc, argv))
    return (FATAL_EXIT_CODE);
    return (FATAL_EXIT_CODE);
 
 
  puts ("/* Generated automatically by the program `genattr-common'");
  puts ("/* Generated automatically by the program `genattr-common'");
  puts ("   from the machine description file `md'.  */\n");
  puts ("   from the machine description file `md'.  */\n");
  puts ("#ifndef GCC_INSN_ATTR_COMMON_H");
  puts ("#ifndef GCC_INSN_ATTR_COMMON_H");
  puts ("#define GCC_INSN_ATTR_COMMON_H\n");
  puts ("#define GCC_INSN_ATTR_COMMON_H\n");
 
 
  /* Read the machine description.  */
  /* Read the machine description.  */
 
 
  while (1)
  while (1)
    {
    {
      int line_no, insn_code_number;
      int line_no, insn_code_number;
 
 
      desc = read_md_rtx (&line_no, &insn_code_number);
      desc = read_md_rtx (&line_no, &insn_code_number);
      if (desc == NULL)
      if (desc == NULL)
        break;
        break;
 
 
      if (GET_CODE (desc) == DEFINE_ATTR)
      if (GET_CODE (desc) == DEFINE_ATTR)
        gen_attr (desc);
        gen_attr (desc);
 
 
      if (GET_CODE (desc) == DEFINE_DELAY)
      if (GET_CODE (desc) == DEFINE_DELAY)
        {
        {
          if (!have_delay)
          if (!have_delay)
            {
            {
              printf ("#define DELAY_SLOTS\n");
              printf ("#define DELAY_SLOTS\n");
              have_delay = true;
              have_delay = true;
            }
            }
        }
        }
      else if (GET_CODE (desc) == DEFINE_INSN_RESERVATION)
      else if (GET_CODE (desc) == DEFINE_INSN_RESERVATION)
        {
        {
          if (!have_sched)
          if (!have_sched)
            {
            {
              printf ("#define INSN_SCHEDULING\n");
              printf ("#define INSN_SCHEDULING\n");
              have_sched = true;
              have_sched = true;
            }
            }
        }
        }
    }
    }
  puts ("\n#endif /* GCC_INSN_ATTR_COMMON_H */");
  puts ("\n#endif /* GCC_INSN_ATTR_COMMON_H */");
 
 
  if (ferror (stdout) || fflush (stdout) || fclose (stdout))
  if (ferror (stdout) || fflush (stdout) || fclose (stdout))
    return FATAL_EXIT_CODE;
    return FATAL_EXIT_CODE;
 
 
  return SUCCESS_EXIT_CODE;
  return SUCCESS_EXIT_CODE;
}
}
 
 

powered by: WebSVN 2.1.0

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