Mercurial > hg > CbC > CbC_gcc
annotate gcc/genattr.c @ 90:99e7b6776dd1
implemeted __rectype expression. add CbC-exanples/fact-rectype.s
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 25 Dec 2011 04:04:42 +0900 |
parents | f6334be47118 |
children | 04ced10e8804 |
rev | line source |
---|---|
0 | 1 /* Generate attribute information (insn-attr.h) from machine description. |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
2 Copyright (C) 1991, 1994, 1996, 1998, 1999, 2000, 2003, 2004, 2007, 2008, |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
3 2010 Free Software Foundation, Inc. |
0 | 4 Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu) |
5 | |
6 This file is part of GCC. | |
7 | |
8 GCC is free software; you can redistribute it and/or modify it under | |
9 the terms of the GNU General Public License as published by the Free | |
10 Software Foundation; either version 3, or (at your option) any later | |
11 version. | |
12 | |
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with GCC; see the file COPYING3. If not see | |
20 <http://www.gnu.org/licenses/>. */ | |
21 | |
22 | |
23 #include "bconfig.h" | |
24 #include "system.h" | |
25 #include "coretypes.h" | |
26 #include "tm.h" | |
27 #include "rtl.h" | |
28 #include "errors.h" | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
29 #include "read-md.h" |
0 | 30 #include "gensupport.h" |
31 | |
32 | |
33 static void write_upcase (const char *); | |
34 static void gen_attr (rtx); | |
35 | |
36 static void | |
37 write_upcase (const char *str) | |
38 { | |
39 for (; *str; str++) | |
40 putchar (TOUPPER(*str)); | |
41 } | |
42 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
43 static VEC (rtx, heap) *const_attrs, *reservations; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
44 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
45 |
0 | 46 static void |
47 gen_attr (rtx attr) | |
48 { | |
49 const char *p, *tag; | |
50 int is_const = GET_CODE (XEXP (attr, 2)) == CONST; | |
51 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
52 if (is_const) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
53 VEC_safe_push (rtx, heap, const_attrs, attr); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
54 |
0 | 55 printf ("#define HAVE_ATTR_%s\n", XSTR (attr, 0)); |
56 | |
57 /* If numeric attribute, don't need to write an enum. */ | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
58 if (GET_CODE (attr) == DEFINE_ENUM_ATTR) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
59 printf ("extern enum %s get_attr_%s (%s);\n\n", |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
60 XSTR (attr, 1), XSTR (attr, 0), (is_const ? "void" : "rtx")); |
0 | 61 else |
62 { | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
63 p = XSTR (attr, 1); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
64 if (*p == '\0') |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
65 printf ("extern int get_attr_%s (%s);\n", XSTR (attr, 0), |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
66 (is_const ? "void" : "rtx")); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
67 else |
0 | 68 { |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
69 printf ("enum attr_%s {", XSTR (attr, 0)); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
70 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
71 while ((tag = scan_comma_elt (&p)) != 0) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
72 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
73 write_upcase (XSTR (attr, 0)); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
74 putchar ('_'); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
75 while (tag != p) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
76 putchar (TOUPPER (*tag++)); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
77 if (*p == ',') |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
78 fputs (", ", stdout); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
79 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
80 fputs ("};\n", stdout); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
81 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
82 printf ("extern enum attr_%s get_attr_%s (%s);\n\n", |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
83 XSTR (attr, 0), XSTR (attr, 0), (is_const ? "void" : "rtx")); |
0 | 84 } |
85 } | |
86 | |
87 /* If `length' attribute, write additional function definitions and define | |
88 variables used by `insn_current_length'. */ | |
89 if (! strcmp (XSTR (attr, 0), "length")) | |
90 { | |
91 puts ("\ | |
92 extern void shorten_branches (rtx);\n\ | |
93 extern int insn_default_length (rtx);\n\ | |
94 extern int insn_min_length (rtx);\n\ | |
95 extern int insn_variable_length_p (rtx);\n\ | |
96 extern int insn_current_length (rtx);\n\n\ | |
97 #include \"insn-addr.h\"\n"); | |
98 } | |
99 } | |
100 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
101 /* Check that attribute NAME is used in define_insn_reservation condition |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
102 EXP. Return true if it is. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
103 static bool |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
104 check_tune_attr (const char *name, rtx exp) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
105 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
106 switch (GET_CODE (exp)) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
107 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
108 case AND: |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
109 if (check_tune_attr (name, XEXP (exp, 0))) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
110 return true; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
111 return check_tune_attr (name, XEXP (exp, 1)); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
112 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
113 case IOR: |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
114 return (check_tune_attr (name, XEXP (exp, 0)) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
115 && check_tune_attr (name, XEXP (exp, 1))); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
116 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
117 case EQ_ATTR: |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
118 return strcmp (XSTR (exp, 0), name) == 0; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
119 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
120 default: |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
121 return false; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
122 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
123 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
124 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
125 /* Try to find a const attribute (usually cpu or tune) that is used |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
126 in all define_insn_reservation conditions. */ |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
127 static bool |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
128 find_tune_attr (rtx exp) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
129 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
130 unsigned int i; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
131 rtx attr; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
132 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
133 switch (GET_CODE (exp)) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
134 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
135 case AND: |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
136 case IOR: |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
137 if (find_tune_attr (XEXP (exp, 0))) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
138 return true; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
139 return find_tune_attr (XEXP (exp, 1)); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
140 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
141 case EQ_ATTR: |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
142 if (strcmp (XSTR (exp, 0), "alternative") == 0) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
143 return false; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
144 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
145 FOR_EACH_VEC_ELT (rtx, const_attrs, i, attr) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
146 if (strcmp (XSTR (attr, 0), XSTR (exp, 0)) == 0) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
147 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
148 unsigned int j; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
149 rtx resv; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
150 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
151 FOR_EACH_VEC_ELT (rtx, reservations, j, resv) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
152 if (! check_tune_attr (XSTR (attr, 0), XEXP (resv, 2))) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
153 return false; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
154 return true; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
155 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
156 return false; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
157 |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
158 default: |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
159 return false; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
160 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
161 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
162 |
0 | 163 int |
164 main (int argc, char **argv) | |
165 { | |
166 rtx desc; | |
167 int have_delay = 0; | |
168 int have_annul_true = 0; | |
169 int have_annul_false = 0; | |
170 int num_insn_reservations = 0; | |
171 int i; | |
172 | |
173 progname = "genattr"; | |
174 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
175 if (!init_rtx_reader_args (argc, argv)) |
0 | 176 return (FATAL_EXIT_CODE); |
177 | |
178 puts ("/* Generated automatically by the program `genattr'"); | |
179 puts (" from the machine description file `md'. */\n"); | |
180 puts ("#ifndef GCC_INSN_ATTR_H"); | |
181 puts ("#define GCC_INSN_ATTR_H\n"); | |
182 | |
183 /* For compatibility, define the attribute `alternative', which is just | |
184 a reference to the variable `which_alternative'. */ | |
185 | |
186 puts ("#define HAVE_ATTR_alternative"); | |
187 puts ("#define get_attr_alternative(insn) which_alternative"); | |
188 | |
189 /* Read the machine description. */ | |
190 | |
191 while (1) | |
192 { | |
193 int line_no, insn_code_number; | |
194 | |
195 desc = read_md_rtx (&line_no, &insn_code_number); | |
196 if (desc == NULL) | |
197 break; | |
198 | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
199 if (GET_CODE (desc) == DEFINE_ATTR |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
200 || GET_CODE (desc) == DEFINE_ENUM_ATTR) |
0 | 201 gen_attr (desc); |
202 | |
203 else if (GET_CODE (desc) == DEFINE_DELAY) | |
204 { | |
205 if (! have_delay) | |
206 { | |
207 printf ("#define DELAY_SLOTS\n"); | |
208 printf ("extern int num_delay_slots (rtx);\n"); | |
209 printf ("extern int eligible_for_delay (rtx, int, rtx, int);\n\n"); | |
210 printf ("extern int const_num_delay_slots (rtx);\n\n"); | |
211 have_delay = 1; | |
212 } | |
213 | |
214 for (i = 0; i < XVECLEN (desc, 1); i += 3) | |
215 { | |
216 if (XVECEXP (desc, 1, i + 1) && ! have_annul_true) | |
217 { | |
218 printf ("#define ANNUL_IFTRUE_SLOTS\n"); | |
219 printf ("extern int eligible_for_annul_true (rtx, int, rtx, int);\n"); | |
220 have_annul_true = 1; | |
221 } | |
222 | |
223 if (XVECEXP (desc, 1, i + 2) && ! have_annul_false) | |
224 { | |
225 printf ("#define ANNUL_IFFALSE_SLOTS\n"); | |
226 printf ("extern int eligible_for_annul_false (rtx, int, rtx, int);\n"); | |
227 have_annul_false = 1; | |
228 } | |
229 } | |
230 } | |
231 | |
232 else if (GET_CODE (desc) == DEFINE_INSN_RESERVATION) | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
233 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
234 num_insn_reservations++; |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
235 VEC_safe_push (rtx, heap, reservations, desc); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
236 } |
0 | 237 } |
238 | |
239 if (num_insn_reservations > 0) | |
240 { | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
241 bool has_tune_attr |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
242 = find_tune_attr (XEXP (VEC_index (rtx, reservations, 0), 2)); |
0 | 243 /* Output interface for pipeline hazards recognition based on |
244 DFA (deterministic finite state automata. */ | |
245 printf ("\n#define INSN_SCHEDULING\n"); | |
246 printf ("\n/* DFA based pipeline interface. */"); | |
247 printf ("\n#ifndef AUTOMATON_ALTS\n"); | |
248 printf ("#define AUTOMATON_ALTS 0\n"); | |
249 printf ("#endif\n\n"); | |
250 printf ("\n#ifndef AUTOMATON_STATE_ALTS\n"); | |
251 printf ("#define AUTOMATON_STATE_ALTS 0\n"); | |
252 printf ("#endif\n\n"); | |
253 printf ("#ifndef CPU_UNITS_QUERY\n"); | |
254 printf ("#define CPU_UNITS_QUERY 0\n"); | |
255 printf ("#endif\n\n"); | |
256 /* Interface itself: */ | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
257 if (has_tune_attr) |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
258 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
259 printf ("/* Initialize fn pointers for internal_dfa_insn_code\n"); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
260 printf (" and insn_default_latency. */\n"); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
261 printf ("extern void init_sched_attrs (void);\n\n"); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
262 printf ("/* Internal insn code number used by automata. */\n"); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
263 printf ("extern int (*internal_dfa_insn_code) (rtx);\n\n"); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
264 printf ("/* Insn latency time defined in define_insn_reservation. */\n"); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
265 printf ("extern int (*insn_default_latency) (rtx);\n\n"); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
266 } |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
267 else |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
268 { |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
269 printf ("#define init_sched_attrs() do { } while (0)\n\n"); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
270 printf ("/* Internal insn code number used by automata. */\n"); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
271 printf ("extern int internal_dfa_insn_code (rtx);\n\n"); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
272 printf ("/* Insn latency time defined in define_insn_reservation. */\n"); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
273 printf ("extern int insn_default_latency (rtx);\n\n"); |
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
274 } |
0 | 275 printf ("/* Return nonzero if there is a bypass for given insn\n"); |
276 printf (" which is a data producer. */\n"); | |
277 printf ("extern int bypass_p (rtx);\n\n"); | |
278 printf ("/* Insn latency time on data consumed by the 2nd insn.\n"); | |
279 printf (" Use the function if bypass_p returns nonzero for\n"); | |
280 printf (" the 1st insn. */\n"); | |
281 printf ("extern int insn_latency (rtx, rtx);\n\n"); | |
282 printf ("/* Maximal insn latency time possible of all bypasses for this insn.\n"); | |
283 printf (" Use the function if bypass_p returns nonzero for\n"); | |
284 printf (" the 1st insn. */\n"); | |
285 printf ("extern int maximal_insn_latency (rtx);\n\n"); | |
286 printf ("\n#if AUTOMATON_ALTS\n"); | |
287 printf ("/* The following function returns number of alternative\n"); | |
288 printf (" reservations of given insn. It may be used for better\n"); | |
289 printf (" insns scheduling heuristics. */\n"); | |
290 printf ("extern int insn_alts (rtx);\n\n"); | |
291 printf ("#endif\n\n"); | |
292 printf ("/* Maximal possible number of insns waiting results being\n"); | |
293 printf (" produced by insns whose execution is not finished. */\n"); | |
294 printf ("extern const int max_insn_queue_index;\n\n"); | |
295 printf ("/* Pointer to data describing current state of DFA. */\n"); | |
296 printf ("typedef void *state_t;\n\n"); | |
297 printf ("/* Size of the data in bytes. */\n"); | |
298 printf ("extern int state_size (void);\n\n"); | |
299 printf ("/* Initiate given DFA state, i.e. Set up the state\n"); | |
300 printf (" as all functional units were not reserved. */\n"); | |
301 printf ("extern void state_reset (state_t);\n"); | |
302 printf ("/* The following function returns negative value if given\n"); | |
303 printf (" insn can be issued in processor state described by given\n"); | |
304 printf (" DFA state. In this case, the DFA state is changed to\n"); | |
305 printf (" reflect the current and future reservations by given\n"); | |
306 printf (" insn. Otherwise the function returns minimal time\n"); | |
307 printf (" delay to issue the insn. This delay may be zero\n"); | |
308 printf (" for superscalar or VLIW processors. If the second\n"); | |
309 printf (" parameter is NULL the function changes given DFA state\n"); | |
310 printf (" as new processor cycle started. */\n"); | |
311 printf ("extern int state_transition (state_t, rtx);\n"); | |
312 printf ("\n#if AUTOMATON_STATE_ALTS\n"); | |
313 printf ("/* The following function returns number of possible\n"); | |
314 printf (" alternative reservations of given insn in given\n"); | |
315 printf (" DFA state. It may be used for better insns scheduling\n"); | |
316 printf (" heuristics. By default the function is defined if\n"); | |
317 printf (" macro AUTOMATON_STATE_ALTS is defined because its\n"); | |
318 printf (" implementation may require much memory. */\n"); | |
319 printf ("extern int state_alts (state_t, rtx);\n"); | |
320 printf ("#endif\n\n"); | |
321 printf ("extern int min_issue_delay (state_t, rtx);\n"); | |
322 printf ("/* The following function returns nonzero if no one insn\n"); | |
323 printf (" can be issued in current DFA state. */\n"); | |
324 printf ("extern int state_dead_lock_p (state_t);\n"); | |
325 printf ("/* The function returns minimal delay of issue of the 2nd\n"); | |
326 printf (" insn after issuing the 1st insn in given DFA state.\n"); | |
327 printf (" The 1st insn should be issued in given state (i.e.\n"); | |
328 printf (" state_transition should return negative value for\n"); | |
329 printf (" the insn and the state). Data dependencies between\n"); | |
330 printf (" the insns are ignored by the function. */\n"); | |
331 printf | |
332 ("extern int min_insn_conflict_delay (state_t, rtx, rtx);\n"); | |
333 printf ("/* The following function outputs reservations for given\n"); | |
334 printf (" insn as they are described in the corresponding\n"); | |
335 printf (" define_insn_reservation. */\n"); | |
336 printf ("extern void print_reservation (FILE *, rtx);\n"); | |
337 printf ("\n#if CPU_UNITS_QUERY\n"); | |
338 printf ("/* The following function returns code of functional unit\n"); | |
339 printf (" with given name (see define_cpu_unit). */\n"); | |
340 printf ("extern int get_cpu_unit_code (const char *);\n"); | |
341 printf ("/* The following function returns nonzero if functional\n"); | |
342 printf (" unit with given code is currently reserved in given\n"); | |
343 printf (" DFA state. */\n"); | |
344 printf ("extern int cpu_unit_reservation_p (state_t, int);\n"); | |
345 printf ("#endif\n\n"); | |
346 printf ("/* The following function returns true if insn\n"); | |
347 printf (" has a dfa reservation. */\n"); | |
348 printf ("extern bool insn_has_dfa_reservation_p (rtx);\n\n"); | |
349 printf ("/* Clean insn code cache. It should be called if there\n"); | |
350 printf (" is a chance that condition value in a\n"); | |
351 printf (" define_insn_reservation will be changed after\n"); | |
352 printf (" last call of dfa_start. */\n"); | |
353 printf ("extern void dfa_clean_insn_cache (void);\n\n"); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
354 printf ("extern void dfa_clear_single_insn_cache (rtx);\n\n"); |
0 | 355 printf ("/* Initiate and finish work with DFA. They should be\n"); |
356 printf (" called as the first and the last interface\n"); | |
357 printf (" functions. */\n"); | |
358 printf ("extern void dfa_start (void);\n"); | |
359 printf ("extern void dfa_finish (void);\n"); | |
360 } | |
361 else | |
362 { | |
363 /* Otherwise we do no scheduling, but we need these typedefs | |
364 in order to avoid uglifying other code with more ifdefs. */ | |
365 printf ("typedef void *state_t;\n\n"); | |
366 } | |
367 | |
368 /* Output flag masks for use by reorg. | |
369 | |
370 Flags are used to hold branch direction and prediction information | |
371 for use by eligible_for_... */ | |
372 printf("\n#define ATTR_FLAG_forward\t0x1\n"); | |
373 printf("#define ATTR_FLAG_backward\t0x2\n"); | |
374 printf("#define ATTR_FLAG_likely\t0x4\n"); | |
375 printf("#define ATTR_FLAG_very_likely\t0x8\n"); | |
376 printf("#define ATTR_FLAG_unlikely\t0x10\n"); | |
377 printf("#define ATTR_FLAG_very_unlikely\t0x20\n"); | |
378 | |
379 puts("\n#endif /* GCC_INSN_ATTR_H */"); | |
380 | |
381 if (ferror (stdout) || fflush (stdout) || fclose (stdout)) | |
382 return FATAL_EXIT_CODE; | |
383 | |
384 return SUCCESS_EXIT_CODE; | |
385 } |