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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [genattr-common.c] - Blame information for rev 731

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 684 jeremybenn
/* Generate attribute information shared between driver and core
2
   compilers (insn-attr-common.h) from machine description.  Split out
3
   of genattr.c.
4
   Copyright (C) 1991, 1994, 1996, 1998, 1999, 2000, 2003, 2004, 2007, 2008,
5
   2010, 2011  Free Software Foundation, Inc.
6
 
7
This file is part of GCC.
8
 
9
GCC is free software; you can redistribute it and/or modify it under
10
the terms of the GNU General Public License as published by the Free
11
Software Foundation; either version 3, or (at your option) any later
12
version.
13
 
14
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15
WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17
for more details.
18
 
19
You should have received a copy of the GNU General Public License
20
along with GCC; see the file COPYING3.  If not see
21
<http://www.gnu.org/licenses/>.  */
22
 
23
 
24
#include "bconfig.h"
25
#include "system.h"
26
#include "coretypes.h"
27
#include "tm.h"
28
#include "rtl.h"
29
#include "errors.h"
30
#include "read-md.h"
31
#include "gensupport.h"
32
 
33
static void
34
write_upcase (const char *str)
35
{
36
  for (; *str; str++)
37
    putchar (TOUPPER(*str));
38
}
39
 
40
static void
41
gen_attr (rtx attr)
42
{
43
  const char *p, *tag;
44
 
45
  p = XSTR (attr, 1);
46
  if (*p != '\0')
47
    {
48
      printf ("enum attr_%s {", XSTR (attr, 0));
49
 
50
      while ((tag = scan_comma_elt (&p)) != 0)
51
        {
52
          write_upcase (XSTR (attr, 0));
53
          putchar ('_');
54
          while (tag != p)
55
            putchar (TOUPPER (*tag++));
56
          if (*p == ',')
57
            fputs (", ", stdout);
58
        }
59
      fputs ("};\n", stdout);
60
    }
61
}
62
 
63
int
64
main (int argc, char **argv)
65
{
66
  rtx desc;
67
  bool have_delay = false;
68
  bool have_sched = false;
69
 
70
  progname = "genattr-common";
71
 
72
  if (!init_rtx_reader_args (argc, argv))
73
    return (FATAL_EXIT_CODE);
74
 
75
  puts ("/* Generated automatically by the program `genattr-common'");
76
  puts ("   from the machine description file `md'.  */\n");
77
  puts ("#ifndef GCC_INSN_ATTR_COMMON_H");
78
  puts ("#define GCC_INSN_ATTR_COMMON_H\n");
79
 
80
  /* Read the machine description.  */
81
 
82
  while (1)
83
    {
84
      int line_no, insn_code_number;
85
 
86
      desc = read_md_rtx (&line_no, &insn_code_number);
87
      if (desc == NULL)
88
        break;
89
 
90
      if (GET_CODE (desc) == DEFINE_ATTR)
91
        gen_attr (desc);
92
 
93
      if (GET_CODE (desc) == DEFINE_DELAY)
94
        {
95
          if (!have_delay)
96
            {
97
              printf ("#define DELAY_SLOTS\n");
98
              have_delay = true;
99
            }
100
        }
101
      else if (GET_CODE (desc) == DEFINE_INSN_RESERVATION)
102
        {
103
          if (!have_sched)
104
            {
105
              printf ("#define INSN_SCHEDULING\n");
106
              have_sched = true;
107
            }
108
        }
109
    }
110
  puts ("\n#endif /* GCC_INSN_ATTR_COMMON_H */");
111
 
112
  if (ferror (stdout) || fflush (stdout) || fclose (stdout))
113
    return FATAL_EXIT_CODE;
114
 
115
  return SUCCESS_EXIT_CODE;
116
}

powered by: WebSVN 2.1.0

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