OSDN Git Service

2011-09-02 Robert Dewar <dewar@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / genattr-common.c
index bc7e1bb..d219fd1 100644 (file)
@@ -30,6 +30,36 @@ along with GCC; see the file COPYING3.  If not see
 #include "read-md.h"
 #include "gensupport.h"
 
+static void
+write_upcase (const char *str)
+{
+  for (; *str; str++)
+    putchar (TOUPPER(*str));
+}
+
+static void
+gen_attr (rtx attr)
+{
+  const char *p, *tag;
+
+  p = XSTR (attr, 1);
+  if (*p != '\0')
+    {
+      printf ("enum attr_%s {", XSTR (attr, 0));
+
+      while ((tag = scan_comma_elt (&p)) != 0)
+       {
+         write_upcase (XSTR (attr, 0));
+         putchar ('_');
+         while (tag != p)
+           putchar (TOUPPER (*tag++));
+         if (*p == ',')
+           fputs (", ", stdout);
+       }
+      fputs ("};\n", stdout);
+    }
+}
+
 int
 main (int argc, char **argv)
 {
@@ -57,6 +87,9 @@ main (int argc, char **argv)
       if (desc == NULL)
        break;
 
+      if (GET_CODE (desc) == DEFINE_ATTR)
+       gen_attr (desc);
+
       if (GET_CODE (desc) == DEFINE_DELAY)
         {
          if (!have_delay)