genattr.c revision 132718
1214501Srpaulo/* Generate attribute information (insn-attr.h) from machine description.
2214501Srpaulo   Copyright (C) 1991, 1994, 1996, 1998, 1999, 2000, 2003
3252726Srpaulo   Free Software Foundation, Inc.
4214501Srpaulo   Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
5252726Srpaulo
6252726SrpauloThis file is part of GCC.
7214501Srpaulo
8214501SrpauloGCC is free software; you can redistribute it and/or modify it under
9214501Srpaulothe terms of the GNU General Public License as published by the Free
10214501SrpauloSoftware Foundation; either version 2, or (at your option) any later
11214501Srpauloversion.
12214501Srpaulo
13214501SrpauloGCC is distributed in the hope that it will be useful, but WITHOUT ANY
14214501SrpauloWARRANTY; without even the implied warranty of MERCHANTABILITY or
15214501SrpauloFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16214501Srpaulofor more details.
17214501Srpaulo
18214501SrpauloYou should have received a copy of the GNU General Public License
19214501Srpauloalong with GCC; see the file COPYING.  If not, write to the Free
20214501SrpauloSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA
21214501Srpaulo02111-1307, USA.  */
22252726Srpaulo
23214501Srpaulo
24214501Srpaulo#include "bconfig.h"
25214501Srpaulo#include "system.h"
26214501Srpaulo#include "coretypes.h"
27214501Srpaulo#include "tm.h"
28214501Srpaulo#include "rtl.h"
29214501Srpaulo#include "errors.h"
30214501Srpaulo#include "gensupport.h"
31214501Srpaulo
32214501Srpaulo
33214501Srpaulo/* A range of values.  */
34214501Srpaulo
35252726Srpaulostruct range
36252726Srpaulo{
37252726Srpaulo  int min;
38214501Srpaulo  int max;
39214501Srpaulo};
40214501Srpaulo
41214501Srpaulo/* Record information about each function unit mentioned in a
42214501Srpaulo   DEFINE_FUNCTION_UNIT.  */
43214501Srpaulo
44214501Srpaulostruct function_unit
45214501Srpaulo{
46214501Srpaulo  char *name;			/* Function unit name.  */
47214501Srpaulo  struct function_unit *next;	/* Next function unit.  */
48214501Srpaulo  int multiplicity;		/* Number of units of this type.  */
49214501Srpaulo  int simultaneity;		/* Maximum number of simultaneous insns
50214501Srpaulo				   on this function unit or 0 if unlimited.  */
51252726Srpaulo  struct range ready_cost;	/* Range of ready cost values.  */
52252726Srpaulo  struct range issue_delay;	/* Range of issue delay values.  */
53252726Srpaulo};
54252726Srpaulo
55214501Srpaulostatic void extend_range (struct range *, int, int);
56214501Srpaulostatic void init_range (struct range *);
57214501Srpaulostatic void write_upcase (const char *);
58214501Srpaulostatic void gen_attr (rtx);
59214501Srpaulostatic void write_units (int, struct range *, struct range *,
60214501Srpaulo			 struct range *, struct range *,
61214501Srpaulo			 struct range *);
62214501Srpaulostatic void
63214501Srpauloextend_range (struct range *range, int min, int max)
64214501Srpaulo{
65214501Srpaulo  if (range->min > min) range->min = min;
66214501Srpaulo  if (range->max < max) range->max = max;
67214501Srpaulo}
68214501Srpaulo
69214501Srpaulostatic void
70214501Srpauloinit_range (struct range *range)
71214501Srpaulo{
72252726Srpaulo  range->min = 100000;
73252726Srpaulo  range->max = -1;
74252726Srpaulo}
75252726Srpaulo
76252726Srpaulostatic void
77252726Srpaulowrite_upcase (const char *str)
78252726Srpaulo{
79252726Srpaulo  for (; *str; str++)
80252726Srpaulo    putchar (TOUPPER(*str));
81252726Srpaulo}
82214501Srpaulo
83214501Srpaulostatic void
84214501Srpaulogen_attr (rtx attr)
85214501Srpaulo{
86214501Srpaulo  const char *p, *tag;
87214501Srpaulo  int is_const = GET_CODE (XEXP (attr, 2)) == CONST;
88214501Srpaulo
89214501Srpaulo  printf ("#define HAVE_ATTR_%s\n", XSTR (attr, 0));
90214501Srpaulo
91214501Srpaulo  /* If numeric attribute, don't need to write an enum.  */
92214501Srpaulo  p = XSTR (attr, 1);
93214501Srpaulo  if (*p == '\0')
94214501Srpaulo    printf ("extern int get_attr_%s (%s);\n", XSTR (attr, 0),
95252726Srpaulo	    (is_const ? "void" : "rtx"));
96252726Srpaulo  else
97252726Srpaulo    {
98252726Srpaulo      printf ("enum attr_%s {", XSTR (attr, 0));
99214501Srpaulo
100214501Srpaulo      while ((tag = scan_comma_elt (&p)) != 0)
101214501Srpaulo	{
102214501Srpaulo	  write_upcase (XSTR (attr, 0));
103214501Srpaulo	  putchar ('_');
104214501Srpaulo	  while (tag != p)
105214501Srpaulo	    putchar (TOUPPER (*tag++));
106214501Srpaulo	  if (*p == ',')
107214501Srpaulo	    fputs (", ", stdout);
108214501Srpaulo	}
109214501Srpaulo
110214501Srpaulo      fputs ("};\n", stdout);
111214501Srpaulo      printf ("extern enum attr_%s get_attr_%s (%s);\n\n",
112214501Srpaulo	      XSTR (attr, 0), XSTR (attr, 0), (is_const ? "void" : "rtx"));
113214501Srpaulo    }
114214501Srpaulo
115214501Srpaulo  /* If `length' attribute, write additional function definitions and define
116214501Srpaulo     variables used by `insn_current_length'.  */
117252726Srpaulo  if (! strcmp (XSTR (attr, 0), "length"))
118252726Srpaulo    {
119252726Srpaulo      puts ("\
120252726Srpauloextern void shorten_branches (rtx);\n\
121252726Srpauloextern int insn_default_length (rtx);\n\
122252726Srpauloextern int insn_variable_length_p (rtx);\n\
123252726Srpauloextern int insn_current_length (rtx);\n\n\
124252726Srpaulo#include \"insn-addr.h\"\n");
125252726Srpaulo    }
126252726Srpaulo}
127252726Srpaulo
128252726Srpaulostatic void
129214501Srpaulowrite_units (int num_units, struct range *multiplicity, struct range *simultaneity,
130214501Srpaulo	     struct range *ready_cost, struct range *issue_delay,
131214501Srpaulo	     struct range *blockage)
132214501Srpaulo{
133214501Srpaulo  int i, q_size;
134214501Srpaulo
135214501Srpaulo  printf ("#define INSN_SCHEDULING\n\n");
136214501Srpaulo  printf ("extern int result_ready_cost (rtx);\n");
137214501Srpaulo  printf ("extern int function_units_used (rtx);\n\n");
138214501Srpaulo  printf ("extern const struct function_unit_desc\n");
139214501Srpaulo  printf ("{\n");
140214501Srpaulo  printf ("  const char *const name;\n");
141214501Srpaulo  printf ("  const int bitmask;\n");
142214501Srpaulo  printf ("  const int multiplicity;\n");
143214501Srpaulo  printf ("  const int simultaneity;\n");
144214501Srpaulo  printf ("  const int default_cost;\n");
145214501Srpaulo  printf ("  const int max_issue_delay;\n");
146214501Srpaulo  printf ("  int (*const ready_cost_function) (rtx);\n");
147214501Srpaulo  printf ("  int (*const conflict_cost_function) (rtx, rtx);\n");
148214501Srpaulo  printf ("  const int max_blockage;\n");
149214501Srpaulo  printf ("  unsigned int (*const blockage_range_function) (rtx);\n");
150214501Srpaulo  printf ("  int (*const blockage_function) (rtx, rtx);\n");
151214501Srpaulo  printf ("} function_units[];\n\n");
152214501Srpaulo  printf ("#define FUNCTION_UNITS_SIZE %d\n", num_units);
153214501Srpaulo  printf ("#define MIN_MULTIPLICITY %d\n", multiplicity->min);
154214501Srpaulo  printf ("#define MAX_MULTIPLICITY %d\n", multiplicity->max);
155214501Srpaulo  printf ("#define MIN_SIMULTANEITY %d\n", simultaneity->min);
156214501Srpaulo  printf ("#define MAX_SIMULTANEITY %d\n", simultaneity->max);
157214501Srpaulo  printf ("#define MIN_READY_COST %d\n", ready_cost->min);
158214501Srpaulo  printf ("#define MAX_READY_COST %d\n", ready_cost->max);
159214501Srpaulo  printf ("#define MIN_ISSUE_DELAY %d\n", issue_delay->min);
160214501Srpaulo  printf ("#define MAX_ISSUE_DELAY %d\n", issue_delay->max);
161214501Srpaulo  printf ("#define MIN_BLOCKAGE %d\n", blockage->min);
162214501Srpaulo  printf ("#define MAX_BLOCKAGE %d\n", blockage->max);
163214501Srpaulo  for (i = 0; (1 << i) < blockage->max; i++)
164214501Srpaulo    ;
165214501Srpaulo  printf ("#define BLOCKAGE_BITS %d\n", i + 1);
166214501Srpaulo
167214501Srpaulo  /* INSN_QUEUE_SIZE is a power of two larger than MAX_BLOCKAGE and
168214501Srpaulo     MAX_READY_COST.  This is the longest time an insn may be queued.  */
169214501Srpaulo  i = MAX (blockage->max, ready_cost->max);
170214501Srpaulo  for (q_size = 1; q_size <= i; q_size <<= 1)
171214501Srpaulo    ;
172214501Srpaulo  printf ("#define INSN_QUEUE_SIZE %d\n", q_size);
173214501Srpaulo}
174214501Srpaulo
175214501Srpauloint
176214501Srpaulomain (int argc, char **argv)
177214501Srpaulo{
178214501Srpaulo  rtx desc;
179214501Srpaulo  int have_delay = 0;
180214501Srpaulo  int have_annul_true = 0;
181214501Srpaulo  int have_annul_false = 0;
182214501Srpaulo  int num_insn_reservations = 0;
183214501Srpaulo  int num_units = 0;
184214501Srpaulo  struct range all_simultaneity, all_multiplicity;
185214501Srpaulo  struct range all_ready_cost, all_issue_delay, all_blockage;
186214501Srpaulo  struct function_unit *units = 0, *unit;
187214501Srpaulo  int i;
188214501Srpaulo
189214501Srpaulo  init_range (&all_multiplicity);
190214501Srpaulo  init_range (&all_simultaneity);
191214501Srpaulo  init_range (&all_ready_cost);
192214501Srpaulo  init_range (&all_issue_delay);
193214501Srpaulo  init_range (&all_blockage);
194214501Srpaulo
195214501Srpaulo  progname = "genattr";
196214501Srpaulo
197214501Srpaulo  if (argc <= 1)
198214501Srpaulo    fatal ("no input file name");
199214501Srpaulo
200214501Srpaulo  if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
201214501Srpaulo    return (FATAL_EXIT_CODE);
202214501Srpaulo
203214501Srpaulo  puts ("/* Generated automatically by the program `genattr'");
204214501Srpaulo  puts ("   from the machine description file `md'.  */\n");
205214501Srpaulo  puts ("#ifndef GCC_INSN_ATTR_H");
206214501Srpaulo  puts ("#define GCC_INSN_ATTR_H\n");
207252726Srpaulo
208214501Srpaulo  /* For compatibility, define the attribute `alternative', which is just
209214501Srpaulo     a reference to the variable `which_alternative'.  */
210214501Srpaulo
211214501Srpaulo  puts ("#define HAVE_ATTR_alternative");
212214501Srpaulo  puts ("#define get_attr_alternative(insn) which_alternative");
213252726Srpaulo
214252726Srpaulo  /* Read the machine description.  */
215252726Srpaulo
216214501Srpaulo  while (1)
217214501Srpaulo    {
218214501Srpaulo      int line_no, insn_code_number;
219214501Srpaulo
220214501Srpaulo      desc = read_md_rtx (&line_no, &insn_code_number);
221214501Srpaulo      if (desc == NULL)
222214501Srpaulo	break;
223214501Srpaulo
224214501Srpaulo      if (GET_CODE (desc) == DEFINE_ATTR)
225214501Srpaulo	gen_attr (desc);
226214501Srpaulo
227214501Srpaulo      else if (GET_CODE (desc) == DEFINE_DELAY)
228214501Srpaulo        {
229214501Srpaulo	  if (! have_delay)
230214501Srpaulo	    {
231214501Srpaulo	      printf ("#define DELAY_SLOTS\n");
232214501Srpaulo	      printf ("extern int num_delay_slots (rtx);\n");
233214501Srpaulo	      printf ("extern int eligible_for_delay (rtx, int, rtx, int);\n\n");
234214501Srpaulo	      printf ("extern int const_num_delay_slots (rtx);\n\n");
235214501Srpaulo	      have_delay = 1;
236214501Srpaulo	    }
237214501Srpaulo
238214501Srpaulo	  for (i = 0; i < XVECLEN (desc, 1); i += 3)
239214501Srpaulo	    {
240214501Srpaulo	      if (XVECEXP (desc, 1, i + 1) && ! have_annul_true)
241214501Srpaulo		{
242214501Srpaulo		  printf ("#define ANNUL_IFTRUE_SLOTS\n");
243214501Srpaulo		  printf ("extern int eligible_for_annul_true (rtx, int, rtx, int);\n");
244214501Srpaulo		  have_annul_true = 1;
245214501Srpaulo		}
246214501Srpaulo
247214501Srpaulo	      if (XVECEXP (desc, 1, i + 2) && ! have_annul_false)
248214501Srpaulo		{
249214501Srpaulo		  printf ("#define ANNUL_IFFALSE_SLOTS\n");
250214501Srpaulo		  printf ("extern int eligible_for_annul_false (rtx, int, rtx, int);\n");
251214501Srpaulo		  have_annul_false = 1;
252214501Srpaulo		}
253214501Srpaulo	    }
254214501Srpaulo        }
255214501Srpaulo
256214501Srpaulo      else if (GET_CODE (desc) == DEFINE_FUNCTION_UNIT)
257214501Srpaulo	{
258214501Srpaulo	  const char *name = XSTR (desc, 0);
259214501Srpaulo	  int multiplicity = XINT (desc, 1);
260214501Srpaulo	  int simultaneity = XINT (desc, 2);
261214501Srpaulo	  int ready_cost = MAX (XINT (desc, 4), 1);
262214501Srpaulo	  int issue_delay = MAX (XINT (desc, 5), 1);
263214501Srpaulo	  int issueexp_p = (XVEC (desc, 6) != 0);
264214501Srpaulo
265214501Srpaulo	  for (unit = units; unit; unit = unit->next)
266214501Srpaulo	    if (strcmp (unit->name, name) == 0)
267214501Srpaulo	      break;
268214501Srpaulo
269214501Srpaulo	  if (unit == 0)
270214501Srpaulo	    {
271214501Srpaulo	      unit = xmalloc (sizeof (struct function_unit));
272214501Srpaulo	      unit->name = xstrdup (name);
273214501Srpaulo	      unit->multiplicity = multiplicity;
274214501Srpaulo	      unit->simultaneity = simultaneity;
275214501Srpaulo	      unit->ready_cost.min = unit->ready_cost.max = ready_cost;
276214501Srpaulo	      unit->issue_delay.min = unit->issue_delay.max = issue_delay;
277214501Srpaulo	      unit->next = units;
278214501Srpaulo	      units = unit;
279214501Srpaulo	      num_units++;
280214501Srpaulo
281214501Srpaulo	      extend_range (&all_multiplicity, multiplicity, multiplicity);
282214501Srpaulo	      extend_range (&all_simultaneity, simultaneity, simultaneity);
283214501Srpaulo	    }
284214501Srpaulo	  else if (unit->multiplicity != multiplicity
285252726Srpaulo		   || unit->simultaneity != simultaneity)
286214501Srpaulo	    fatal ("Differing specifications given for `%s' function unit",
287214501Srpaulo		   unit->name);
288214501Srpaulo
289214501Srpaulo	  extend_range (&unit->ready_cost, ready_cost, ready_cost);
290214501Srpaulo	  extend_range (&unit->issue_delay,
291214501Srpaulo			issueexp_p ? 1 : issue_delay, issue_delay);
292214501Srpaulo	  extend_range (&all_ready_cost,
293214501Srpaulo			unit->ready_cost.min, unit->ready_cost.max);
294214501Srpaulo	  extend_range (&all_issue_delay,
295214501Srpaulo			unit->issue_delay.min, unit->issue_delay.max);
296214501Srpaulo	}
297214501Srpaulo      else if (GET_CODE (desc) == DEFINE_INSN_RESERVATION)
298214501Srpaulo	num_insn_reservations++;
299214501Srpaulo    }
300214501Srpaulo
301214501Srpaulo  if (num_units > 0 || num_insn_reservations > 0)
302214501Srpaulo    {
303214501Srpaulo      if (num_units > 0)
304214501Srpaulo	printf ("#define TRADITIONAL_PIPELINE_INTERFACE 1\n");
305214501Srpaulo
306214501Srpaulo      if (num_insn_reservations > 0)
307214501Srpaulo	printf ("#define DFA_PIPELINE_INTERFACE 1\n");
308214501Srpaulo
309214501Srpaulo      /* Compute the range of blockage cost values.  See genattrtab.c
310214501Srpaulo	 for the derivation.  BLOCKAGE (E,C) when SIMULTANEITY is zero is
311214501Srpaulo
312214501Srpaulo	     MAX (ISSUE-DELAY (E,C),
313214501Srpaulo		  READY-COST (E) - (READY-COST (C) - 1))
314214501Srpaulo
315214501Srpaulo	 and otherwise
316214501Srpaulo
317214501Srpaulo	     MAX (ISSUE-DELAY (E,C),
318252726Srpaulo		  READY-COST (E) - (READY-COST (C) - 1),
319252726Srpaulo		  READY-COST (E) - FILL-TIME)  */
320252726Srpaulo
321252726Srpaulo      for (unit = units; unit; unit = unit->next)
322252726Srpaulo	{
323252726Srpaulo	  struct range blockage;
324252726Srpaulo
325252726Srpaulo	  blockage = unit->issue_delay;
326252726Srpaulo	  blockage.max = MAX (unit->ready_cost.max
327252726Srpaulo			      - (unit->ready_cost.min - 1),
328252726Srpaulo			      blockage.max);
329252726Srpaulo	  blockage.min = MAX (1, blockage.min);
330252726Srpaulo
331252726Srpaulo	  if (unit->simultaneity != 0)
332252726Srpaulo	    {
333252726Srpaulo	      int fill_time = ((unit->simultaneity - 1)
334252726Srpaulo			       * unit->issue_delay.min);
335252726Srpaulo	      blockage.min = MAX (unit->ready_cost.min - fill_time,
336252726Srpaulo				  blockage.min);
337252726Srpaulo	      blockage.max = MAX (unit->ready_cost.max - fill_time,
338252726Srpaulo				  blockage.max);
339252726Srpaulo	    }
340252726Srpaulo	  extend_range (&all_blockage, blockage.min, blockage.max);
341252726Srpaulo	}
342252726Srpaulo
343252726Srpaulo      write_units (num_units, &all_multiplicity, &all_simultaneity,
344252726Srpaulo		   &all_ready_cost, &all_issue_delay, &all_blockage);
345252726Srpaulo
346252726Srpaulo      /* Output interface for pipeline hazards recognition based on
347252726Srpaulo	 DFA (deterministic finite state automata.  */
348252726Srpaulo      printf ("\n/* DFA based pipeline interface.  */");
349252726Srpaulo      printf ("\n#ifndef AUTOMATON_ALTS\n");
350252726Srpaulo      printf ("#define AUTOMATON_ALTS 0\n");
351252726Srpaulo      printf ("#endif\n\n");
352252726Srpaulo      printf ("\n#ifndef AUTOMATON_STATE_ALTS\n");
353252726Srpaulo      printf ("#define AUTOMATON_STATE_ALTS 0\n");
354252726Srpaulo      printf ("#endif\n\n");
355252726Srpaulo      printf ("#ifndef CPU_UNITS_QUERY\n");
356252726Srpaulo      printf ("#define CPU_UNITS_QUERY 0\n");
357252726Srpaulo      printf ("#endif\n\n");
358252726Srpaulo      /* Interface itself: */
359252726Srpaulo      printf ("extern int max_dfa_issue_rate;\n\n");
360252726Srpaulo      printf ("/* The following macro value is calculated from the\n");
361252726Srpaulo      printf ("   automaton based pipeline description and is equal to\n");
362252726Srpaulo      printf ("   maximal number of all insns described in constructions\n");
363252726Srpaulo      printf ("   `define_insn_reservation' which can be issued on the\n");
364252726Srpaulo      printf ("   same processor cycle. */\n");
365252726Srpaulo      printf ("#define MAX_DFA_ISSUE_RATE max_dfa_issue_rate\n\n");
366252726Srpaulo      printf ("/* Insn latency time defined in define_insn_reservation. */\n");
367252726Srpaulo      printf ("extern int insn_default_latency (rtx);\n\n");
368252726Srpaulo      printf ("/* Return nonzero if there is a bypass for given insn\n");
369252726Srpaulo      printf ("   which is a data producer.  */\n");
370252726Srpaulo      printf ("extern int bypass_p (rtx);\n\n");
371252726Srpaulo      printf ("/* Insn latency time on data consumed by the 2nd insn.\n");
372252726Srpaulo      printf ("   Use the function if bypass_p returns nonzero for\n");
373252726Srpaulo      printf ("   the 1st insn. */\n");
374252726Srpaulo      printf ("extern int insn_latency (rtx, rtx);\n\n");
375252726Srpaulo      printf ("\n#if AUTOMATON_ALTS\n");
376252726Srpaulo      printf ("/* The following function returns number of alternative\n");
377252726Srpaulo      printf ("   reservations of given insn.  It may be used for better\n");
378252726Srpaulo      printf ("   insns scheduling heuristics. */\n");
379252726Srpaulo      printf ("extern int insn_alts (rtx);\n\n");
380252726Srpaulo      printf ("#endif\n\n");
381252726Srpaulo      printf ("/* Maximal possible number of insns waiting results being\n");
382252726Srpaulo      printf ("   produced by insns whose execution is not finished. */\n");
383252726Srpaulo      printf ("extern int max_insn_queue_index;\n\n");
384252726Srpaulo      printf ("/* Pointer to data describing current state of DFA.  */\n");
385252726Srpaulo      printf ("typedef void *state_t;\n\n");
386252726Srpaulo      printf ("/* Size of the data in bytes.  */\n");
387252726Srpaulo      printf ("extern int state_size (void);\n\n");
388252726Srpaulo      printf ("/* Initiate given DFA state, i.e. Set up the state\n");
389252726Srpaulo      printf ("   as all functional units were not reserved.  */\n");
390252726Srpaulo      printf ("extern void state_reset (state_t);\n");
391252726Srpaulo      printf ("/* The following function returns negative value if given\n");
392252726Srpaulo      printf ("   insn can be issued in processor state described by given\n");
393252726Srpaulo      printf ("   DFA state.  In this case, the DFA state is changed to\n");
394252726Srpaulo      printf ("   reflect the current and future reservations by given\n");
395252726Srpaulo      printf ("   insn.  Otherwise the function returns minimal time\n");
396252726Srpaulo      printf ("   delay to issue the insn.  This delay may be zero\n");
397252726Srpaulo      printf ("   for superscalar or VLIW processors.  If the second\n");
398252726Srpaulo      printf ("   parameter is NULL the function changes given DFA state\n");
399252726Srpaulo      printf ("   as new processor cycle started.  */\n");
400252726Srpaulo      printf ("extern int state_transition (state_t, rtx);\n");
401252726Srpaulo      printf ("\n#if AUTOMATON_STATE_ALTS\n");
402252726Srpaulo      printf ("/* The following function returns number of possible\n");
403252726Srpaulo      printf ("   alternative reservations of given insn in given\n");
404252726Srpaulo      printf ("   DFA state.  It may be used for better insns scheduling\n");
405252726Srpaulo      printf ("   heuristics.  By default the function is defined if\n");
406252726Srpaulo      printf ("   macro AUTOMATON_STATE_ALTS is defined because its\n");
407252726Srpaulo      printf ("   implementation may require much memory.  */\n");
408252726Srpaulo      printf ("extern int state_alts (state_t, rtx);\n");
409252726Srpaulo      printf ("#endif\n\n");
410252726Srpaulo      printf ("extern int min_issue_delay (state_t, rtx);\n");
411252726Srpaulo      printf ("/* The following function returns nonzero if no one insn\n");
412252726Srpaulo      printf ("   can be issued in current DFA state. */\n");
413252726Srpaulo      printf ("extern int state_dead_lock_p (state_t);\n");
414252726Srpaulo      printf ("/* The function returns minimal delay of issue of the 2nd\n");
415252726Srpaulo      printf ("   insn after issuing the 1st insn in given DFA state.\n");
416252726Srpaulo      printf ("   The 1st insn should be issued in given state (i.e.\n");
417252726Srpaulo      printf ("    state_transition should return negative value for\n");
418252726Srpaulo      printf ("    the insn and the state).  Data dependencies between\n");
419252726Srpaulo      printf ("    the insns are ignored by the function.  */\n");
420252726Srpaulo      printf
421252726Srpaulo	("extern int min_insn_conflict_delay (state_t, rtx, rtx);\n");
422252726Srpaulo      printf ("/* The following function outputs reservations for given\n");
423252726Srpaulo      printf ("   insn as they are described in the corresponding\n");
424252726Srpaulo      printf ("   define_insn_reservation.  */\n");
425252726Srpaulo      printf ("extern void print_reservation (FILE *, rtx);\n");
426252726Srpaulo      printf ("\n#if CPU_UNITS_QUERY\n");
427252726Srpaulo      printf ("/* The following function returns code of functional unit\n");
428252726Srpaulo      printf ("   with given name (see define_cpu_unit). */\n");
429252726Srpaulo      printf ("extern int get_cpu_unit_code (const char *);\n");
430252726Srpaulo      printf ("/* The following function returns nonzero if functional\n");
431252726Srpaulo      printf ("   unit with given code is currently reserved in given\n");
432252726Srpaulo      printf ("   DFA state.  */\n");
433252726Srpaulo      printf ("extern int cpu_unit_reservation_p (state_t, int);\n");
434252726Srpaulo      printf ("#endif\n\n");
435252726Srpaulo      printf ("/* Clean insn code cache.  It should be called if there\n");
436252726Srpaulo      printf ("   is a chance that condition value in a\n");
437252726Srpaulo      printf ("   define_insn_reservation will be changed after\n");
438252726Srpaulo      printf ("   last call of dfa_start.  */\n");
439252726Srpaulo      printf ("extern void dfa_clean_insn_cache (void);\n\n");
440252726Srpaulo      printf ("/* Initiate and finish work with DFA.  They should be\n");
441252726Srpaulo      printf ("   called as the first and the last interface\n");
442252726Srpaulo      printf ("   functions.  */\n");
443252726Srpaulo      printf ("extern void dfa_start (void);\n");
444252726Srpaulo      printf ("extern void dfa_finish (void);\n");
445252726Srpaulo    }
446252726Srpaulo  else
447252726Srpaulo    {
448252726Srpaulo      /* Otherwise we do no scheduling, but we need these typedefs
449252726Srpaulo	 in order to avoid uglifying other code with more ifdefs.  */
450252726Srpaulo      printf ("typedef void *state_t;\n\n");
451252726Srpaulo    }
452252726Srpaulo
453252726Srpaulo  /* Output flag masks for use by reorg.
454214501Srpaulo
455214501Srpaulo     Flags are used to hold branch direction and prediction information
456214501Srpaulo     for use by eligible_for_...  */
457214501Srpaulo  printf("\n#define ATTR_FLAG_forward\t0x1\n");
458214501Srpaulo  printf("#define ATTR_FLAG_backward\t0x2\n");
459214501Srpaulo  printf("#define ATTR_FLAG_likely\t0x4\n");
460214501Srpaulo  printf("#define ATTR_FLAG_very_likely\t0x8\n");
461214501Srpaulo  printf("#define ATTR_FLAG_unlikely\t0x10\n");
462214501Srpaulo  printf("#define ATTR_FLAG_very_unlikely\t0x20\n");
463214501Srpaulo
464214501Srpaulo  puts("\n#endif /* GCC_INSN_ATTR_H */");
465252726Srpaulo
466214501Srpaulo  if (ferror (stdout) || fflush (stdout) || fclose (stdout))
467214501Srpaulo    return FATAL_EXIT_CODE;
468252726Srpaulo
469252726Srpaulo  return SUCCESS_EXIT_CODE;
470214501Srpaulo}
471214501Srpaulo
472214501Srpaulo/* Define this so we can link with print-rtl.o to get debug_rtx function.  */
473214501Srpauloconst char *
474214501Srpauloget_insn_name (int code ATTRIBUTE_UNUSED)
475214501Srpaulo{
476214501Srpaulo  return NULL;
477214501Srpaulo}
478214501Srpaulo