Statistics
| Revision:

root / spec / gcc / genoutput.i @ 53

History | View | Annotate | Download (20.9 KB)

1

    
2
extern	struct	_iobuf {
3
	int	_cnt;
4
	unsigned char *_ptr;
5
	unsigned char *_base;
6
	int	_bufsiz;
7
	short	_flag;
8
	char	_file;		 
9
} _iob[];
10

    
11
extern struct _iobuf 	*fopen();
12
extern struct _iobuf 	*fdopen();
13
extern struct _iobuf 	*freopen();
14
extern struct _iobuf 	*popen();
15
extern struct _iobuf 	*tmpfile();
16
extern long	ftell();
17
extern char	*fgets();
18
extern char	*gets();
19

    
20
extern char	*ctermid();
21
extern char	*cuserid();
22
extern char	*tempnam();
23
extern char	*tmpnam();
24

    
25
extern int target_flags;
26

    
27
enum reg_class { NO_REGS, LO_FPA_REGS, FPA_REGS, FP_REGS,
28
  FP_OR_FPA_REGS, DATA_REGS, DATA_OR_FPA_REGS, DATA_OR_FP_REGS,
29
  DATA_OR_FP_OR_FPA_REGS, ADDR_REGS, GENERAL_REGS,
30
  GENERAL_OR_FPA_REGS, GENERAL_OR_FP_REGS, ALL_REGS,
31
  LIM_REG_CLASSES };
32

    
33
extern enum reg_class regno_reg_class[];
34

    
35
enum rtx_code  {
36

    
37
  UNKNOWN , 
38

    
39
  NIL , 
40

    
41
  EXPR_LIST , 
42

    
43
  INSN_LIST , 
44

    
45
  MATCH_OPERAND , 
46

    
47
  MATCH_DUP , 
48

    
49
  MATCH_OPERATOR , 
50

    
51
  DEFINE_INSN , 
52

    
53
  DEFINE_PEEPHOLE , 
54

    
55
  DEFINE_COMBINE , 
56

    
57
  DEFINE_EXPAND , 
58

    
59
  SEQUENCE , 
60

    
61
  ADDRESS , 
62

    
63
  INSN , 
64

    
65
  JUMP_INSN , 
66

    
67
  CALL_INSN , 
68

    
69
  BARRIER , 
70

    
71
  CODE_LABEL , 
72

    
73
  NOTE , 
74

    
75
  INLINE_HEADER , 
76

    
77
  PARALLEL , 
78

    
79
  ASM_INPUT , 
80

    
81
  ASM_OPERANDS , 
82

    
83
  ADDR_VEC , 
84

    
85
  ADDR_DIFF_VEC , 
86

    
87
  SET , 
88

    
89
  USE , 
90

    
91
  CLOBBER , 
92

    
93
  CALL , 
94

    
95
  RETURN , 
96

    
97
  CONST_INT , 
98

    
99
  CONST_DOUBLE , 
100

    
101
  CONST , 
102

    
103
  PC , 
104

    
105
  REG , 
106

    
107
  SUBREG , 
108

    
109
  STRICT_LOW_PART , 
110

    
111
  MEM , 
112

    
113
  LABEL_REF , 
114

    
115
  SYMBOL_REF , 
116

    
117
  CC0 , 
118

    
119
  QUEUED , 
120

    
121
  IF_THEN_ELSE , 
122

    
123
  COMPARE , 
124

    
125
  PLUS , 
126

    
127
  MINUS , 
128

    
129
  NEG , 
130

    
131
  MULT , 
132

    
133
  DIV , 
134
  MOD , 
135

    
136
  UMULT , 
137
  UDIV , 
138
  UMOD , 
139

    
140
  AND , 
141

    
142
  IOR , 
143

    
144
  XOR , 
145

    
146
  NOT , 
147

    
148
  LSHIFT , 
149
  ASHIFT , 
150
  ROTATE , 
151

    
152
  ASHIFTRT , 
153
  LSHIFTRT , 
154
  ROTATERT , 
155

    
156
  PRE_DEC , 
157
  PRE_INC , 
158
  POST_DEC , 
159
  POST_INC , 
160

    
161
  NE , 
162
  EQ , 
163
  GE , 
164
  GT , 
165
  LE , 
166
  LT , 
167
  GEU , 
168
  GTU , 
169
  LEU , 
170
  LTU , 
171

    
172
  SIGN_EXTEND , 
173

    
174
  ZERO_EXTEND , 
175

    
176
  TRUNCATE , 
177

    
178
  FLOAT_EXTEND , 
179
  FLOAT_TRUNCATE , 
180

    
181
  FLOAT , 
182

    
183
  FIX , 
184

    
185
  UNSIGNED_FLOAT , 
186

    
187
  UNSIGNED_FIX , 
188

    
189
  ABS , 
190

    
191
  SQRT , 
192

    
193
  FFS , 
194

    
195
  SIGN_EXTRACT , 
196

    
197
  ZERO_EXTRACT , 
198

    
199
  LAST_AND_UNUSED_RTX_CODE};	 
200

    
201
extern int rtx_length[];
202

    
203
extern char *rtx_name[];
204

    
205
extern char *rtx_format[];
206

    
207
enum machine_mode {
208

    
209
 VOIDmode, 
210

    
211
 QImode, 		 
212
 HImode, 
213

    
214
 PSImode, 
215
 SImode, 
216
 PDImode, 
217
 DImode, 
218
 TImode, 
219
 QFmode, 
220
 HFmode, 		 
221
 SFmode, 
222
 DFmode, 
223
 XFmode, 	 
224
 TFmode, 
225
 CQImode, 
226
 CHImode, 	 
227
 CSImode, 
228
 CDImode, 
229
 CTImode, 
230
 CQFmode, 
231
 CHFmode, 	 
232
 CSFmode, 
233
 CDFmode, 
234
 CXFmode, 
235
 CTFmode, 
236

    
237
 BImode, 	 
238

    
239
 BLKmode, 
240

    
241
 EPmode, 
242

    
243
MAX_MACHINE_MODE };
244

    
245
extern char *mode_name[];
246

    
247
enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT,
248
		  MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MODE_FUNCTION };
249

    
250
extern enum mode_class mode_class[];
251

    
252
extern int mode_size[];
253

    
254
extern int mode_unit_size[];
255

    
256
typedef union rtunion_def
257
{
258
  int rtint;
259
  char *rtstr;
260
  struct rtx_def *rtx;
261
  struct rtvec_def *rtvec;
262
  enum machine_mode rttype;
263
} rtunion;
264

    
265
typedef struct rtx_def
266
{
267

    
268
  enum rtx_code code : 16;
269

    
270
  enum machine_mode mode : 8;
271

    
272
  unsigned int jump : 1;
273
  unsigned int call : 1;
274

    
275
  unsigned int unchanging : 1;
276

    
277
  unsigned int volatil : 1;
278

    
279
  unsigned int in_struct : 1;
280

    
281
  unsigned int used : 1;
282

    
283
  unsigned integrated : 1;
284

    
285
  rtunion fld[1];
286
} *rtx;
287

    
288
typedef struct rtvec_def{
289
  unsigned num_elem;		 
290
  rtunion elem[1];
291
} *rtvec;
292

    
293
enum reg_note { REG_DEAD = 1, REG_INC = 2, REG_EQUIV = 3, REG_WAS_0 = 4,
294
		REG_EQUAL = 5, REG_RETVAL = 6, REG_LIBCALL = 7,
295
		REG_NONNEG = 8 };
296

    
297
extern char *reg_note_name[];
298

    
299
extern char *note_insn_name[];
300

    
301
extern rtx rtx_alloc ();
302
extern rtvec rtvec_alloc ();
303
extern rtx find_reg_note ();
304
extern rtx gen_rtx ();
305
extern rtx copy_rtx ();
306
extern rtvec gen_rtvec ();
307
extern rtvec gen_rtvec_v ();
308
extern rtx gen_reg_rtx ();
309
extern rtx gen_label_rtx ();
310
extern rtx gen_inline_header_rtx ();
311
extern rtx gen_lowpart ();
312
extern rtx gen_highpart ();
313
extern int subreg_lowpart_p ();
314
extern rtx make_safe_from ();
315
extern rtx memory_address ();
316
extern rtx get_insns ();
317
extern rtx get_last_insn ();
318
extern rtx start_sequence ();
319
extern rtx gen_sequence ();
320
extern rtx expand_expr ();
321
extern rtx output_constant_def ();
322
extern rtx immed_real_const ();
323
extern rtx immed_real_const_1 ();
324
extern rtx immed_double_const ();
325
extern rtx force_const_double_mem ();
326
extern rtx force_const_mem ();
327
extern rtx get_parm_real_loc ();
328
extern rtx assign_stack_local ();
329
extern rtx protect_from_queue ();
330
extern void emit_queue ();
331
extern rtx emit_move_insn ();
332
extern rtx emit_insn ();
333
extern rtx emit_jump_insn ();
334
extern rtx emit_call_insn ();
335
extern rtx emit_call_insn_before ();
336
extern rtx emit_insn_before ();
337
extern rtx emit_insn_after ();
338
extern rtx emit_label ();
339
extern rtx emit_barrier ();
340
extern rtx emit_note ();
341
extern rtx emit_line_note ();
342
extern rtx emit_line_note_force ();
343
extern rtx prev_real_insn ();
344
extern rtx next_real_insn ();
345
extern rtx next_nondeleted_insn ();
346
extern rtx plus_constant ();
347
extern rtx find_equiv_reg ();
348
extern rtx delete_insn ();
349
extern rtx adj_offsetable_operand ();
350

    
351
extern int max_parallel;
352

    
353
extern int asm_noperands ();
354
extern char *decode_asm_operands ();
355

    
356
extern enum reg_class reg_preferred_class ();
357

    
358
extern rtx get_first_nonparm_insn ();
359

    
360
extern rtx pc_rtx;
361
extern rtx cc0_rtx;
362
extern rtx const0_rtx;
363
extern rtx const1_rtx;
364
extern rtx fconst0_rtx;
365
extern rtx dconst0_rtx;
366

    
367
extern rtx stack_pointer_rtx;
368
extern rtx frame_pointer_rtx;
369
extern rtx arg_pointer_rtx;
370
extern rtx struct_value_rtx;
371
extern rtx struct_value_incoming_rtx;
372
extern rtx static_chain_rtx;
373
extern rtx static_chain_incoming_rtx;
374

    
375
struct _obstack_chunk		 
376
{
377
  char  *limit;			 
378
  struct _obstack_chunk *prev;	 
379
  char	contents[4];		 
380
};
381

    
382
struct obstack		 
383
{
384
  long	chunk_size;		 
385
  struct _obstack_chunk* chunk;	 
386
  char	*object_base;		 
387
  char	*next_free;		 
388
  char	*chunk_limit;		 
389
  int	temp;			 
390
  int   alignment_mask;		 
391
  struct _obstack_chunk *(*chunkfun) ();  
392
  void (*freefun) ();		 
393
};
394

    
395
void obstack_init (struct obstack *obstack);
396

    
397
void * obstack_alloc (struct obstack *obstack, int size);
398

    
399
void * obstack_copy (struct obstack *obstack, void *address, int size);
400
void * obstack_copy0 (struct obstack *obstack, void *address, int size);
401

    
402
void obstack_free (struct obstack *obstack, void *block);
403

    
404
void obstack_blank (struct obstack *obstack, int size);
405

    
406
void obstack_grow (struct obstack *obstack, void *data, int size);
407
void obstack_grow0 (struct obstack *obstack, void *data, int size);
408

    
409
void obstack_1grow (struct obstack *obstack, int data_char);
410

    
411
void * obstack_finish (struct obstack *obstack);
412

    
413
int obstack_object_size (struct obstack *obstack);
414

    
415
int obstack_room (struct obstack *obstack);
416
void obstack_1grow_fast (struct obstack *obstack, int data_char);
417
void obstack_blank_fast (struct obstack *obstack, int size);
418

    
419
void * obstack_base (struct obstack *obstack);
420
void * obstack_next_free (struct obstack *obstack);
421
int obstack_alignment_mask (struct obstack *obstack);
422
int obstack_chunk_size (struct obstack *obstack);
423

    
424
struct obstack obstack;
425
struct obstack *rtl_obstack = &obstack;
426

    
427
extern int xmalloc ();
428
extern void free ();
429

    
430
void fatal ();
431
void error ();
432
void mybcopy ();
433
void mybzero ();
434

    
435
int next_code_number;
436

    
437
struct data
438
{
439
  int code_number;
440
  char *name;
441
  char *template;		 
442
  int n_operands;		 
443
  int n_dups;			 
444
  int n_alternatives;		 
445
  struct data *next;
446
  char *constraints[40 ];
447
  int op_n_alternatives[40 ];
448
  char *predicates[40 ];
449
  char address_p[40 ];
450
  enum machine_mode modes[40 ];
451
  char strict_low[40 ];
452
  char outfun;			 
453
  char *machine_info;		 
454
};
455

    
456
struct data *insn_data;
457

    
458
struct data *end_of_insn_data;
459

    
460
int have_constraints;
461
void
462
output_prologue ()
463
{
464

    
465
  printf ("/* Generated automatically by the program `genoutput'\nfrom the machine description file `md'.  */\n\n");
466

    
467
  printf ("#include \"config.h\"\n");
468
  printf ("#include \"rtl.h\"\n");
469
  printf ("#include \"regs.h\"\n");
470
  printf ("#include \"hard-reg-set.h\"\n");
471
  printf ("#include \"real.h\"\n");
472
  printf ("#include \"conditions.h\"\n");
473
  printf ("#include \"insn-flags.h\"\n");
474
  printf ("#include \"insn-config.h\"\n\n");
475

    
476
  printf ("#ifndef __STDC__\n");
477
  printf ("#define const\n");
478
  printf ("#endif\n\n");
479

    
480
  printf ("#include \"output.h\"\n");
481
  printf ("#include \"aux-output.c\"\n\n");
482

    
483
  printf ("#ifndef INSN_MACHINE_INFO\n");
484
  printf ("#define INSN_MACHINE_INFO struct dummy1 {int i;}\n");
485
  printf ("#endif\n\n");
486
}
487

    
488
void
489
output_epilogue ()
490
{
491
  register struct data *d;
492

    
493
  printf ("\nchar * const insn_template[] =\n  {\n");
494
  for (d = insn_data; d; d = d->next)
495
    {
496
      if (d->template)
497
	printf ("    \"%s\",\n", d->template);
498
      else
499
	printf ("    0,\n");
500
    }
501
  printf ("  };\n");
502

    
503
  printf ("\nchar *(*const insn_outfun[])() =\n  {\n");
504
  for (d = insn_data; d; d = d->next)
505
    {
506
      if (d->outfun)
507
	printf ("    output_%d,\n", d->code_number);
508
      else
509
	printf ("    0,\n");
510
    }
511
  printf ("  };\n");
512

    
513
  printf ("\nrtx (*const insn_gen_function[]) () =\n  {\n");
514
  for (d = insn_data; d; d = d->next)
515
    {
516
      if (d->name)
517
	printf ("    gen_%s,\n", d->name);
518
      else
519
	printf ("    0,\n");
520
    }
521
  printf ("  };\n");
522

    
523
  printf ("\nconst int insn_n_operands[] =\n  {\n");
524
  for (d = insn_data; d; d = d->next)
525
    {
526
      printf ("    %d,\n", d->n_operands);
527
    }
528
  printf ("  };\n");
529

    
530
  printf ("\nconst int insn_n_dups[] =\n  {\n");
531
  for (d = insn_data; d; d = d->next)
532
    {
533
      printf ("    %d,\n", d->n_dups);
534
    }
535
  printf ("  };\n");
536

    
537
  if (have_constraints)
538
    {
539
      printf ("\nchar *const insn_operand_constraint[][MAX_RECOG_OPERANDS] =\n  {\n");
540
      for (d = insn_data; d; d = d->next)
541
	{
542
	  register int i, n = 0, start;
543
	  printf ("    {");
544

    
545
	  for (start = 0; start < d->n_operands; start++)
546
	    if (d->op_n_alternatives[start] > 0)
547
	      {
548
		if (n == 0)
549
		  n = d->op_n_alternatives[start];
550
		else if (n != d->op_n_alternatives[start])
551
		  error ("wrong number of alternatives in operand %d of insn number %d",
552
			 start, d->code_number);
553
	      }
554
	  d->n_alternatives = n;
555

    
556
	  for (i = 0; i < d->n_operands; i++)
557
	    {
558
	      if (d->constraints[i] == 0)
559
		printf (" \"\",");
560
	      else
561
		printf (" \"%s\",", d->constraints[i]);
562
	    }
563
	  if (d->n_operands == 0)
564
	    printf (" 0");
565
	  printf (" },\n");
566
	}
567
      printf ("  };\n");
568
    }
569
  else
570
    {
571
      printf ("\nconst char insn_operand_address_p[][MAX_RECOG_OPERANDS] =\n  {\n");
572
      for (d = insn_data; d; d = d->next)
573
	{
574
	  register int i;
575
	  printf ("    {");
576
	  for (i = 0; i < d->n_operands; i++)
577
	    printf (" %d,", d->address_p[i]);
578
	  if (d->n_operands == 0)
579
	    printf (" 0");
580
	  printf (" },\n");
581
	}
582
      printf ("  };\n");
583
    }
584

    
585
  printf ("\nconst enum machine_mode insn_operand_mode[][MAX_RECOG_OPERANDS] =\n  {\n");
586
  for (d = insn_data; d; d = d->next)
587
    {
588
      register int i;
589
      printf ("    {");
590
      for (i = 0; i < d->n_operands; i++)
591
	printf (" %smode,", 	(mode_name[(int)(d->modes[i])]) );
592
      if (d->n_operands == 0)
593
	printf (" VOIDmode");
594
      printf (" },\n");
595
    }
596
  printf ("  };\n");
597

    
598
  printf ("\nconst char insn_operand_strict_low[][MAX_RECOG_OPERANDS] =\n  {\n");
599
  for (d = insn_data; d; d = d->next)
600
    {
601
      register int i;
602
      printf ("    {");
603
      for (i = 0; i < d->n_operands; i++)
604
	printf (" %d,", d->strict_low[i]);
605
      if (d->n_operands == 0)
606
	printf (" 0");
607
      printf (" },\n");
608
    }
609
  printf ("  };\n");
610

    
611
  printf ("\nint (*const insn_operand_predicate[][MAX_RECOG_OPERANDS])() =\n  {\n");
612
  for (d = insn_data; d; d = d->next)
613
    {
614
      register int i;
615
      printf ("    {");
616
      for (i = 0; i < d->n_operands; i++)
617
	printf (" %s,", ((d->predicates[i] && d->predicates[i][0])
618
			 ? d->predicates[i] : "0"));
619
      if (d->n_operands == 0)
620
	printf (" 0");
621
      printf (" },\n");
622
    }
623
  printf ("  };\n");
624

    
625
  printf ("\nconst INSN_MACHINE_INFO insn_machine_info[] =\n  {\n");
626
  for (d = insn_data; d; d = d->next)
627
    {
628
      if (d->machine_info)
629
	printf ("    {%s},\n", d->machine_info);
630
      else
631
	printf("     {0},\n");
632
    }
633
  printf("  };\n");
634

    
635
  printf ("\nconst int insn_n_alternatives[] =\n  {\n");
636
  for (d = insn_data; d; d = d->next)
637
    {
638
      if (d->n_alternatives)
639
	printf ("    %d,\n", d->n_alternatives);
640
      else
641
	printf("     0,\n");
642
    }
643
  printf("  };\n");
644
}
645

    
646
int max_opno;
647
int num_dups;
648
char *constraints[40 ];
649
int op_n_alternatives[40 ];
650
char *predicates[40 ];
651
char address_p[40 ];
652
enum machine_mode modes[40 ];
653
char strict_low[40 ];
654

    
655
void
656
scan_operands (part, this_address_p, this_strict_low)
657
     rtx part;
658
     int this_address_p;
659
     int this_strict_low;
660
{
661
  register int i, j;
662
  register enum rtx_code  code;
663
  register char *format_ptr;
664

    
665
  if (part == 0)
666
    return;
667

    
668
  code = 	((part)->code) ;
669

    
670
  if (code == MATCH_OPERAND)
671
    {
672
      int opno = ((part)->fld[ 0].rtint) ;
673
      if (opno > max_opno)
674
	max_opno = opno;
675
      if (max_opno >= 40 )
676
	error ("Too many operands (%d) in one instruction pattern.\n",
677
	       max_opno + 1);
678
      modes[opno] = 	((part)->mode) ;
679
      strict_low[opno] = this_strict_low;
680
      predicates[opno] = ((part)->fld[ 1].rtstr) ;
681
      constraints[opno] = ((part)->fld[ 2].rtstr) ;
682
      if (((part)->fld[ 2].rtstr)  != 0 && *((part)->fld[ 2].rtstr)  != 0)
683
	{
684
	  op_n_alternatives[opno] = n_occurrences (',', ((part)->fld[ 2].rtstr) ) + 1;
685
	  have_constraints = 1;
686
	}
687
      address_p[opno] = this_address_p;
688
      return;
689
    }
690

    
691
  if (code == MATCH_OPERATOR)
692
    {
693
      int opno = ((part)->fld[ 0].rtint) ;
694
      if (opno > max_opno)
695
	max_opno = opno;
696
      if (max_opno >= 40 )
697
	error ("Too many operands (%d) in one instruction pattern.\n",
698
	       max_opno + 1);
699
      modes[opno] = 	((part)->mode) ;
700
      strict_low[opno] = 0;
701
      predicates[opno] = ((part)->fld[ 1].rtstr) ;
702
      constraints[opno] = 0;
703
      address_p[opno] = 0;
704
      for (i = 0; i < ((part)->fld[ 2].rtvec->num_elem) ; i++)
705
	scan_operands (((part)->fld[ 2].rtvec->elem[ i].rtx) , 0, 0);
706
      return;
707
    }
708

    
709
  if (code == MATCH_DUP)
710
    {
711
      ++num_dups;
712
      return;
713
    }
714

    
715
  if (code == ADDRESS)
716
    {
717
      scan_operands (((part)->fld[ 0].rtx) , 1, 0);
718
      return;
719
    }
720

    
721
  if (code == STRICT_LOW_PART)
722
    {
723
      scan_operands (((part)->fld[ 0].rtx) , 0, 1);
724
      return;
725
    }
726

    
727
  format_ptr = 	(rtx_format[(int)(	((part)->code) )]) ;
728

    
729
  for (i = 0; i < 	(rtx_length[(int)(	((part)->code) )]) ; i++)
730
    switch (*format_ptr++)
731
      {
732
      case 'e':
733
	scan_operands (((part)->fld[ i].rtx) , 0, 0);
734
	break;
735
      case 'E':
736
	if (((part)->fld[ i].rtvec)  != 0 )
737
	  for (j = 0; j < ((part)->fld[ i].rtvec->num_elem) ; j++)
738
	    scan_operands (((part)->fld[ i].rtvec->elem[ j].rtx) , 0, 0);
739
	break;
740
      }
741
}
742

    
743
void
744
gen_insn (insn)
745
     rtx insn;
746
{
747
  register struct data *d = (struct data *) xmalloc (sizeof (struct data));
748
  register int i;
749

    
750
  d->code_number = next_code_number++;
751
  if (((insn)->fld[ 0].rtstr) [0])
752
    d->name = ((insn)->fld[ 0].rtstr) ;
753
  else
754
    d->name = 0;
755

    
756
  d->next = 0;
757
  if (end_of_insn_data)
758
    end_of_insn_data->next = d;
759
  else
760
    insn_data = d;
761

    
762
  end_of_insn_data = d;
763

    
764
  max_opno = -1;
765
  num_dups = 0;
766

    
767
  mybzero (constraints, sizeof constraints);
768
  mybzero (op_n_alternatives, sizeof op_n_alternatives);
769
  mybzero (predicates, sizeof predicates);
770
  mybzero (address_p, sizeof address_p);
771
  mybzero (modes, sizeof modes);
772
  mybzero (strict_low, sizeof strict_low);
773
  for (i = 0; i < ((insn)->fld[ 1].rtvec->num_elem) ; i++)
774
    scan_operands (((insn)->fld[ 1].rtvec->elem[ i].rtx) , 0, 0);
775
  d->n_operands = max_opno + 1;
776
  d->n_dups = num_dups;
777
  mybcopy (constraints, d->constraints, sizeof constraints);
778
  mybcopy (op_n_alternatives, d->op_n_alternatives, sizeof op_n_alternatives);
779
  mybcopy (predicates, d->predicates, sizeof predicates);
780
  mybcopy (address_p, d->address_p, sizeof address_p);
781
  mybcopy (modes, d->modes, sizeof modes);
782
  mybcopy (strict_low, d->strict_low, sizeof strict_low);
783
  d->machine_info = ((insn)->fld[ 4].rtstr) ;
784

    
785
  if (((insn)->fld[ 3].rtstr) [0] != '*')
786
    {
787
      d->template = ((insn)->fld[ 3].rtstr) ;
788
      d->outfun = 0;
789
      return;
790
    }
791

    
792
  d->template = 0;
793
  d->outfun = 1;
794

    
795
  printf ("\nchar *\n");
796
  printf ("output_%d (operands, insn)\n", d->code_number);
797
  printf ("     rtx *operands;\n");
798
  printf ("     rtx insn;\n");
799
  printf ("{\n");
800

    
801
  {
802
    register char *cp = &(((insn)->fld[ 3].rtstr) [1]);
803
    while (*cp) (--((&_iob[1]) )->_cnt >= 0 ?	(int)(*((&_iob[1]) )->_ptr++ = (unsigned char)((*cp++))) :	((((&_iob[1]) )->_flag & 0200 ) && -((&_iob[1]) )->_cnt < ((&_iob[1]) )->_bufsiz ?	((*((&_iob[1]) )->_ptr = (unsigned char)((*cp++))) != '\n' ?	(int)(*((&_iob[1]) )->_ptr++) :	_flsbuf(*(unsigned char *)((&_iob[1]) )->_ptr, (&_iob[1]) )) :	_flsbuf((unsigned char)((*cp++)), (&_iob[1]) )))  ;
804
    (--((&_iob[1]) )->_cnt >= 0 ?	(int)(*((&_iob[1]) )->_ptr++ = (unsigned char)(('\n'))) :	((((&_iob[1]) )->_flag & 0200 ) && -((&_iob[1]) )->_cnt < ((&_iob[1]) )->_bufsiz ?	((*((&_iob[1]) )->_ptr = (unsigned char)(('\n'))) != '\n' ?	(int)(*((&_iob[1]) )->_ptr++) :	_flsbuf(*(unsigned char *)((&_iob[1]) )->_ptr, (&_iob[1]) )) :	_flsbuf((unsigned char)(('\n')), (&_iob[1]) )))  ;
805
  }
806
  printf ("}\n");
807
}
808

    
809
void
810
gen_peephole (peep)
811
     rtx peep;
812
{
813
  register struct data *d = (struct data *) xmalloc (sizeof (struct data));
814
  register int i;
815

    
816
  d->code_number = next_code_number++;
817
  d->name = 0;
818

    
819
  d->next = 0;
820
  if (end_of_insn_data)
821
    end_of_insn_data->next = d;
822
  else
823
    insn_data = d;
824

    
825
  end_of_insn_data = d;
826

    
827
  max_opno = -1;
828
  mybzero (constraints, sizeof constraints);
829
  mybzero (op_n_alternatives, sizeof op_n_alternatives);
830

    
831
  for (i = 0; i < ((peep)->fld[ 0].rtvec->num_elem) ; i++)
832
    scan_operands (((peep)->fld[ 0].rtvec->elem[ i].rtx) , 0, 0);
833

    
834
  d->n_operands = max_opno + 1;
835
  d->n_dups = 0;
836
  mybcopy (constraints, d->constraints, sizeof constraints);
837
  mybcopy (op_n_alternatives, d->op_n_alternatives, sizeof op_n_alternatives);
838
  mybzero (d->predicates, sizeof predicates);
839
  mybzero (d->address_p, sizeof address_p);
840
  mybzero (d->modes, sizeof modes);
841
  mybzero (d->strict_low, sizeof strict_low);
842
  d->machine_info = ((peep)->fld[ 3].rtstr) ;
843

    
844
  if (((peep)->fld[ 2].rtstr) [0] != '*')
845
    {
846
      d->template = ((peep)->fld[ 2].rtstr) ;
847
      d->outfun = 0;
848
      return;
849
    }
850

    
851
  d->template = 0;
852
  d->outfun = 1;
853

    
854
  printf ("\nchar *\n");
855
  printf ("output_%d (operands, insn)\n", d->code_number);
856
  printf ("     rtx *operands;\n");
857
  printf ("     rtx insn;\n");
858
  printf ("{\n");
859
  printf ("%s\n", &(((peep)->fld[ 2].rtstr) [1]));
860
  printf ("}\n");
861
}
862

    
863
void
864
gen_expand (insn)
865
     rtx insn;
866
{
867
  register struct data *d = (struct data *) xmalloc (sizeof (struct data));
868
  register int i;
869

    
870
  d->code_number = next_code_number++;
871
  if (((insn)->fld[ 0].rtstr) [0])
872
    d->name = ((insn)->fld[ 0].rtstr) ;
873
  else
874
    d->name = 0;
875

    
876
  d->next = 0;
877
  if (end_of_insn_data)
878
    end_of_insn_data->next = d;
879
  else
880
    insn_data = d;
881

    
882
  end_of_insn_data = d;
883

    
884
  max_opno = -1;
885
  num_dups = 0;
886

    
887
  mybzero (predicates, sizeof predicates);
888
  mybzero (modes, sizeof modes);
889
  if (((insn)->fld[ 1].rtvec) )
890
    for (i = 0; i < ((insn)->fld[ 1].rtvec->num_elem) ; i++)
891
      scan_operands (((insn)->fld[ 1].rtvec->elem[ i].rtx) , 0, 0);
892
  d->n_operands = max_opno + 1;
893
  mybcopy (predicates, d->predicates, sizeof predicates);
894
  mybcopy (modes, d->modes, sizeof modes);
895

    
896
  mybzero (d->constraints, sizeof constraints);
897
  mybzero (d->op_n_alternatives, sizeof op_n_alternatives);
898
  mybzero (d->address_p, sizeof address_p);
899
  mybzero (d->strict_low, sizeof strict_low);
900

    
901
  d->n_dups = 0;
902
  d->template = 0;
903
  d->outfun = 0;
904
  d->machine_info = 0;
905
}
906
int
907
xmalloc (size)
908
{
909
  register int val = malloc (size);
910

    
911
  if (val == 0)
912
    fatal ("virtual memory exhausted");
913
  return val;
914
}
915

    
916
int
917
xrealloc (ptr, size)
918
     char *ptr;
919
     int size;
920
{
921
  int result = realloc (ptr, size);
922
  if (!result)
923
    fatal ("virtual memory exhausted");
924
  return result;
925
}
926

    
927
void
928
mybzero (b, length)
929
     register char *b;
930
     register int length;
931
{
932
  while (length-- > 0)
933
    *b++ = 0;
934
}
935

    
936
void
937
mybcopy (b1, b2, length)
938
     register char *b1;
939
     register char *b2;
940
     register int length;
941
{
942
  while (length-- > 0)
943
    *b2++ = *b1++;
944
}
945

    
946
void
947
fatal (s, a1, a2)
948
{
949
  fprintf ((&_iob[2]) , "genoutput: ");
950
  fprintf ((&_iob[2]) , s, a1, a2);
951
  fprintf ((&_iob[2]) , "\n");
952
  exit (33 );
953
}
954

    
955
void
956
error (s, a1, a2)
957
{
958
  fprintf ((&_iob[2]) , "genoutput: ");
959
  fprintf ((&_iob[2]) , s, a1, a2);
960
  fprintf ((&_iob[2]) , "\n");
961
}
962
int
963
main (argc, argv)
964
     int argc;
965
     char **argv;
966
{
967
  rtx desc;
968
  struct _iobuf  *infile;
969
  extern rtx read_rtx ();
970
  register int c;
971

    
972
  _obstack_begin ((rtl_obstack), 0, 0, xmalloc , free ) ;
973

    
974
  if (argc <= 1)
975
    fatal ("No input file name.");
976

    
977
  infile = fopen (argv[1], "r");
978
  if (infile == 0)
979
    {
980
      perror (argv[1]);
981
      exit (33 );
982
    }
983

    
984
  init_rtl ();
985

    
986
  output_prologue ();
987
  next_code_number = 0;
988
  have_constraints = 0;
989

    
990
  while (1)
991
    {
992
      c = read_skip_spaces (infile);
993
      if (c == (-1) )
994
	break;
995
      ungetc (c, infile);
996

    
997
      desc = read_rtx (infile);
998
      if (	((desc)->code)  == DEFINE_INSN)
999
	gen_insn (desc);
1000
      if (	((desc)->code)  == DEFINE_PEEPHOLE)
1001
	gen_peephole (desc);
1002
      if (	((desc)->code)  == DEFINE_EXPAND)
1003
	gen_expand (desc);
1004
    }
1005

    
1006
  output_epilogue ();
1007

    
1008
  fflush ((&_iob[1]) );
1009
  exit (((((&_iob[1]) )->_flag&040 )!=0)  != 0 ? 33  : 0 );
1010
}
1011

    
1012
int
1013
n_occurrences (c, s)
1014
     char c;
1015
     char *s;
1016
{
1017
  int n = 0;
1018
  while (*s)
1019
    n += (*s++ == c);
1020
  return n;
1021
}
1022