-
Notifications
You must be signed in to change notification settings - Fork 0
/
final.c
1608 lines (1358 loc) · 41.9 KB
/
final.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Convert RTL to assembler code and output it, for GNU compiler.
Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc.
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* This is the final pass of the compiler.
It looks at the rtl code for a function and outputs assembler code.
Call `final_start_function' to output the assembler code for function entry,
`final' to output assembler code for some RTL code,
`final_end_function' to output assembler code for function exit.
If a function is compiled in several pieces, each piece is
output separately with `final'.
Some optimizations are also done at this level.
Move instructions that were made unnecessary by good register allocation
are detected and omitted from the output. (Though most of these
are removed by the last jump pass.)
Instructions to set the condition codes are omitted when it can be
seen that the condition codes already had the desired values.
In some cases it is sufficient if the inherited condition codes
have related values, but this may require the following insn
(the one that tests the condition codes) to be modified.
The code for the function prologue and epilogue are generated
directly as assembler code by the macros FUNCTION_PROLOGUE and
FUNCTION_EPILOGUE. Those instructions never exist as rtl. */
#include <stdio.h>
#include "config.h"
#include "rtl.h"
#include "regs.h"
#include "insn-config.h"
#include "recog.h"
#include "conditions.h"
#include "gdbfiles.h"
#include "flags.h"
#include "real.h"
#include "output.h"
/* Get N_SLINE and N_SOL from stab.h if we can expect the file to exist. */
#ifdef DBX_DEBUGGING_INFO
#ifdef USG
#include "stab.h" /* If doing DBX on sysV, use our own stab.h. */
#else
#include <stab.h> /* On BSD, use the system's stab.h. */
#endif /* not USG */
#endif /* DBX_DEBUGGING_INFO */
/* .stabd code for line number. */
#ifndef N_SLINE
#define N_SLINE 0x44
#endif
/* .stabs code for included file name. */
#ifndef N_SOL
#define N_SOL 0x84
#endif
#define min(A,B) ((A) < (B) ? (A) : (B))
rtx peephole ();
void output_asm_insn ();
rtx alter_subreg ();
static int alter_cond ();
void output_asm_label ();
static void output_operand ();
void output_address ();
void output_addr_const ();
static void output_source_line ();
rtx final_scan_insn ();
/* the sdb debugger needs the line given as an offset from the beginning
of the current function -wfs*/
extern int sdb_begin_function_line;
/* Line number of last NOTE. */
static int last_linenum;
/* Number of basic blocks seen so far;
used if profile_block_flag is set. */
static int count_basic_blocks;
/* Nonzero while outputting an `asm' with operands.
This means that inconsistencies are the user's fault, so don't abort.
The precise value is the insn being output, to pass to error_for_asm. */
static rtx this_is_asm_operands;
/* Number of operands of this insn, for an `asm' with operands. */
static int insn_noperands;
/* File in which assembler code is being written. */
extern FILE *asm_out_file;
/* Compare optimization flag. */
static rtx last_ignored_compare = 0;
/* Flag indicating this insn is the start of a new basic block. */
static int new_block = 1;
/* All the symbol-blocks (levels of scoping) in the compilation
are assigned sequence numbers in order of appearance of the
beginnings of the symbol-blocks. Both final and dbxout do this,
and assume that they will both give the same number to each block.
Final uses these sequence numbers to generate assembler label names
LBBnnn and LBEnnn for the beginning and end of the symbol-block.
Dbxout uses the sequence nunbers to generate references to the same labels
from the dbx debugging information.
Sdb records this level at the beginning
of each function, so that when it recurses down the declarations, it may
find the current level, since it outputs the block beginning and endings
at the point in the asm file, where the blocks would begin and end. */
int next_block_index;
/* Chain of all `struct gdbfile's. */
struct gdbfile *gdbfiles;
/* `struct gdbfile' for the last file we wrote a line number for. */
static struct gdbfile *current_gdbfile;
/* Filenum to assign to the next distinct source file encountered. */
static int next_gdb_filenum;
/* This variable contains machine-dependent flags (defined in tm-...h)
set and examined by output routines
that describe how to interpret the condition codes properly. */
CC_STATUS cc_status;
/* During output of an insn, this contains a copy of cc_status
from before the insn. */
CC_STATUS cc_prev_status;
/* Last source file name mentioned in a NOTE insn. */
static char *lastfile;
/* Indexed by hardware reg number, is 1 if that register is ever
used in the current function.
In life_analysis, or in stupid_life_analysis, this is set
up to record the hard regs used explicitly. Reload adds
in the hard regs used for holding pseudo regs. Final uses
it to generate the code in the function prologue and epilogue
to save and restore registers as needed. */
char regs_ever_live[FIRST_PSEUDO_REGISTER];
/* Nonzero means current function must be given a frame pointer.
Set in stmt.c if anything is allocated on the stack there.
Set in reload1.c if anything is allocated on the stack there. */
int frame_pointer_needed;
/* Assign unique numbers to labels generated for profiling. */
int profile_label_no;
/* Length so far allocated in PENDING_BLOCKS. */
static int max_block_depth;
/* Stack of sequence numbers of symbol-blocks of which we have seen the
beginning but not yet the end. Sequence numbers are assigned at
the beginning; this stack allows us to find the sequence number
of a block that is ending. */
static int *pending_blocks;
/* Number of elements currently in use in PENDING_BLOCKS. */
static int block_depth;
/* Nonzero if have enabled APP processing of our assembler output. */
static int app_on;
/* If we are outputting an insn sequence, this contains the sequence rtx.
Zero otherwise. */
rtx final_sequence;
/* Initialize data in final at the beginning of a compilation. */
void
init_final (filename)
char *filename;
{
next_block_index = 2;
lastfile = filename;
app_on = 0;
max_block_depth = 20;
pending_blocks = (int *) xmalloc (20 * sizeof *pending_blocks);
gdbfiles = 0;
next_gdb_filenum = 0;
final_sequence = 0;
}
/* Called at end of source file,
to output the block-profiling table for this entire compilation. */
void
end_final (filename)
char *filename;
{
int i;
if (profile_block_flag)
{
char name[12];
data_section ();
/* Output the main header, of 6 words:
0: 1 if this file's initialized, else 0.
1: address of file name.
2: address of table of counts.
4: number of counts in the table.
5: always 0, for compatibility with Sun.
6: extra word added by GNU: address of address table
which contains addresses of basic blocks,
in parallel with the table of counts. */
ASM_OUTPUT_ALIGN (asm_out_file,
exact_log2 (min (UNITS_PER_WORD,
BIGGEST_ALIGNMENT / BITS_PER_UNIT)));
ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 0);
assemble_integer_zero ();
ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 1);
ASM_OUTPUT_INT (asm_out_file, gen_rtx (SYMBOL_REF, Pmode, name));
ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 2);
ASM_OUTPUT_INT (asm_out_file, gen_rtx (SYMBOL_REF, Pmode, name));
ASM_OUTPUT_INT (asm_out_file, gen_rtx (CONST_INT, VOIDmode,
count_basic_blocks));
assemble_integer_zero ();
ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 3);
ASM_OUTPUT_INT (asm_out_file, gen_rtx (SYMBOL_REF, Pmode, name));
/* Output the file name. */
ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 1);
assemble_string (filename, strlen (filename) + 1);
/* Realign data section. */
ASM_OUTPUT_ALIGN (asm_out_file,
exact_log2 (min (UNITS_PER_WORD,
BIGGEST_ALIGNMENT / BITS_PER_UNIT)));
/* Make space for the table of counts. */
ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 2);
ASM_OUTPUT_SKIP (asm_out_file, UNITS_PER_WORD * count_basic_blocks);
/* Output the table of addresses. */
text_section ();
ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 3);
for (i = 0; i < count_basic_blocks; i++)
{
char name[12];
ASM_GENERATE_INTERNAL_LABEL (name, "LPB", i);
ASM_OUTPUT_INT (asm_out_file, gen_rtx (SYMBOL_REF, Pmode, name));
}
/* End with the address of the table of addresses,
so we can find it easily, as the last word in the file's text. */
ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 3);
ASM_OUTPUT_INT (asm_out_file, gen_rtx (SYMBOL_REF, Pmode, name));
}
}
/* Enable APP processing of subsequent output.
Used before the output from an `asm' statement. */
void
app_enable ()
{
if (! app_on)
{
fprintf (asm_out_file, ASM_APP_ON);
app_on = 1;
}
}
/* Enable APP processing of subsequent output.
Called from varasm.c before most kinds of output. */
void
app_disable ()
{
if (app_on)
{
fprintf (asm_out_file, ASM_APP_OFF);
app_on = 0;
}
}
/* Return the number of slots filled in the current
delayed branch sequence. */
#ifdef HAVE_DELAYED_BRANCH
int
dbr_sequence_length ()
{
int i;
int slots = 0;
/* It's zero if we are not scheduling or not in a sequence.
(We never count the first insn.) */
if (flag_delayed_branch && final_sequence != 0)
{
for (i = 1; i < XVECLEN (final_sequence, 0); i++)
slots += DBR_INSN_SLOTS (XVECEXP (final_sequence, 0, i));
}
return slots;
}
#endif
/* Output assembler code for the start of a function,
and initialize some of the variables in this file
for the new function. The label for the function and associated
assembler pseudo-ops have already been output in `assemble_function'.
FIRST is the first insn of the rtl for the function being compiled.
FILE is the file to write assembler code to.
WRITE_SYMBOLS says which kind of debugging info to write (or none).
OPTIMIZE is nonzero if we should eliminate redundant
test and compare insns. */
void
final_start_function (first, file, write_symbols, optimize)
rtx first;
FILE *file;
enum debugger write_symbols;
int optimize;
{
block_depth = 0;
this_is_asm_operands = 0;
/* Record beginning of the symbol-block that's the entire function. */
if (write_symbols == GDB_DEBUG)
{
pending_blocks[block_depth++] = next_block_index;
fprintf (file, "\t.gdbbeg %d\n", next_block_index++);
}
/* Initial line number is supposed to be output
before the function's prologue and label
so that the function's address will not appear to be
in the last statement of the preceding function. */
if (NOTE_LINE_NUMBER (first) != NOTE_INSN_DELETED)
output_source_line (file, first, write_symbols);
#ifdef FUNCTION_PROLOGUE
/* First output the function prologue: code to set up the stack frame. */
FUNCTION_PROLOGUE (file, get_frame_size ());
#endif
#ifdef SDB_DEBUGGING_INFO
next_block_index = 1;
#endif
#ifdef FUNCTION_BLOCK_PROFILER
if (profile_block_flag)
{
FUNCTION_BLOCK_PROFILER (file, profile_label_no);
}
#endif /* FUNCTION_BLOCK_PROFILER */
if (profile_flag)
{
int align = min (BIGGEST_ALIGNMENT, BITS_PER_WORD);
extern int current_function_returns_struct;
extern int current_function_needs_context;
int sval = current_function_returns_struct;
int cxt = current_function_needs_context;
data_section ();
ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
ASM_OUTPUT_INTERNAL_LABEL (file, "LP", profile_label_no);
assemble_integer_zero ();
text_section ();
#ifdef STRUCT_VALUE_INCOMING_REGNUM
if (sval)
ASM_OUTPUT_REG_PUSH (file, STRUCT_VALUE_INCOMING_REGNUM);
#else
#ifdef STRUCT_VALUE_REGNUM
if (sval)
ASM_OUTPUT_REG_PUSH (file, STRUCT_VALUE_REGNUM);
#endif
#endif
#if 0
#ifdef STATIC_CHAIN_INCOMING_REGNUM
if (cxt)
ASM_OUTPUT_REG_PUSH (file, STATIC_CHAIN_INCOMING_REGNUM);
#else
#ifdef STATIC_CHAIN_REGNUM
if (cxt)
ASM_OUTPUT_REG_PUSH (file, STATIC_CHAIN_REGNUM);
#endif
#endif
#endif /* 0 */
FUNCTION_PROFILER (file, profile_label_no);
#if 0
#ifdef STATIC_CHAIN_INCOMING_REGNUM
if (cxt)
ASM_OUTPUT_REG_POP (file, STATIC_CHAIN_INCOMING_REGNUM);
#else
#ifdef STATIC_CHAIN_REGNUM
if (cxt)
ASM_OUTPUT_REG_POP (file, STATIC_CHAIN_REGNUM);
#endif
#endif
#endif /* 0 */
#ifdef STRUCT_VALUE_INCOMING_REGNUM
if (sval)
ASM_OUTPUT_REG_POP (file, STRUCT_VALUE_INCOMING_REGNUM);
#else
#ifdef STRUCT_VALUE_REGNUM
if (sval)
ASM_OUTPUT_REG_POP (file, STRUCT_VALUE_REGNUM);
#endif
#endif
}
profile_label_no++;
}
/* Output assembler code for the end of a function.
For clarity, args are same as those of `final_start_function'
even though not all of them are needed. */
void
final_end_function (first, file, write_symbols, optimize)
rtx first;
FILE *file;
enum debugger write_symbols;
int optimize;
{
if (app_on)
{
fprintf (file, ASM_APP_OFF);
app_on = 0;
}
if (write_symbols == GDB_DEBUG)
fprintf (file, "\t.gdbend %d\n", pending_blocks[0]);
#ifdef SDB_DEBUGGING_INFO
if (write_symbols == SDB_DEBUG)
sdbout_end_function (last_linenum);
#endif
#ifdef FUNCTION_EPILOGUE
/* Finally, output the function epilogue:
code to restore the stack frame and return to the caller. */
FUNCTION_EPILOGUE (file, get_frame_size ());
#endif
#ifdef SDB_DEBUGGING_INFO
if (write_symbols == SDB_DEBUG)
sdbout_end_epilogue ();
#endif
/* If FUNCTION_EPILOGUE is not defined, then the function body
itself contains return instructions wherever needed. */
}
/* Output assembler code for some insns: all or part of a function.
For description of args, see `final_start_function', above.
PRESCAN is 1 if we are not really outputting,
just scanning as if we were outputting.
Prescanning deletes and rearranges insns just like ordinary output.
PRESCAN is -2 if we are outputting after having prescanned.
In this case, don't try to delete or rearrange insns
because that has already been done.
Prescanning is done only on certain machines. */
void
final (first, file, write_symbols, optimize, prescan)
rtx first;
FILE *file;
enum debugger write_symbols;
int optimize;
int prescan;
{
register rtx insn;
last_ignored_compare = 0;
new_block = 1;
init_recog ();
CC_STATUS_INIT;
for (insn = NEXT_INSN (first); insn;)
insn = final_scan_insn (insn, file, write_symbols, optimize,
prescan, 0);
}
/* The final scan for one insn, INSN.
Args are same as in `final', except that INSN
is the insn being scanned.
Value returned is the next insn to be scanned.
NOPEEPHOLES is the flag to disallow peephole processing (currently
used for within delayed branch sequence output). */
rtx
final_scan_insn (insn, file, write_symbols, optimize, prescan, nopeepholes)
rtx insn;
FILE *file;
enum debugger write_symbols;
int optimize;
int prescan;
int nopeepholes;
{
register int i;
switch (GET_CODE (insn))
{
case NOTE:
if (prescan > 0)
break;
if (write_symbols == NO_DEBUG)
break;
if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_BEG)
{
#ifdef SDB_DEBUGGING_INFO
if (write_symbols == SDB_DEBUG)
sdbout_begin_function (last_linenum);
#endif
break;
}
if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_BEG
|| NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_END)
break;
if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED)
break; /* An insn that was "deleted" */
if (app_on)
{
fprintf (file, ASM_APP_OFF);
app_on = 0;
}
if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_BEG)
{
/* Beginning of a symbol-block. Assign it a sequence number
and push the number onto the stack PENDING_BLOCKS. */
if (block_depth == max_block_depth)
{
/* PENDING_BLOCKS is full; make it longer. */
max_block_depth *= 2;
pending_blocks
= (int *) xrealloc (pending_blocks,
max_block_depth * sizeof (int));
}
pending_blocks[block_depth++] = next_block_index;
/* Output debugging info about the symbol-block beginning. */
#ifdef SDB_DEBUGGING_INFO
if (write_symbols == SDB_DEBUG)
sdbout_begin_block (file, last_linenum, next_block_index);
#endif
#ifdef DBX_DEBUGGING_INFO
if (write_symbols == DBX_DEBUG)
ASM_OUTPUT_INTERNAL_LABEL (file, "LBB", next_block_index);
#endif
if (write_symbols == GDB_DEBUG)
fprintf (file, "\t.gdbbeg %d\n", next_block_index);
next_block_index++;
}
else if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_END)
{
/* End of a symbol-block. Pop its sequence number off
PENDING_BLOCKS and output debugging info based on that. */
--block_depth;
#ifdef DBX_DEBUGGING_INFO
if (write_symbols == DBX_DEBUG && block_depth >= 0)
ASM_OUTPUT_INTERNAL_LABEL (file, "LBE",
pending_blocks[block_depth]);
#endif
#ifdef SDB_DEBUGGING_INFO
if (write_symbols == SDB_DEBUG && block_depth >= 0)
sdbout_end_block (file, last_linenum);
#endif
if (write_symbols == GDB_DEBUG)
fprintf (file, "\t.gdbend %d\n", pending_blocks[block_depth]);
}
else if (NOTE_LINE_NUMBER (insn) > 0)
/* This note is a line-number. */
output_source_line (file, insn, write_symbols);
break;
case BARRIER:
#ifdef ASM_OUTPUT_ALIGN_CODE
ASM_OUTPUT_ALIGN_CODE (file);
#endif
break;
case CODE_LABEL:
CC_STATUS_INIT;
if (prescan > 0)
break;
new_block = 1;
if (app_on)
{
fprintf (file, ASM_APP_OFF);
app_on = 0;
}
#ifdef ASM_OUTPUT_CASE_LABEL
if (NEXT_INSN (insn) != 0
&& GET_CODE (NEXT_INSN (insn)) == JUMP_INSN)
{
rtx nextbody = PATTERN (NEXT_INSN (insn));
/* If this label is followed by a jump-table,
output the two of them together in a special way. */
if (GET_CODE (nextbody) == ADDR_VEC
|| GET_CODE (nextbody) == ADDR_DIFF_VEC)
{
ASM_OUTPUT_CASE_LABEL (file, "L", CODE_LABEL_NUMBER (insn),
NEXT_INSN (insn));
break;
}
}
#endif
ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (insn));
break;
default:
{
register rtx body = PATTERN (insn);
int insn_code_number;
char *template;
/* An INSN, JUMP_INSN or CALL_INSN.
First check for special kinds that recog doesn't recognize. */
if (GET_CODE (body) == USE /* These are just declarations */
|| GET_CODE (body) == CLOBBER)
break;
if (profile_block_flag && new_block)
{
new_block = 0;
/* Enable the table of basic-block use counts
to point at the code it applies to. */
ASM_OUTPUT_INTERNAL_LABEL (file, "LPB", count_basic_blocks);
/* Before first insn of this basic block, increment the
count of times it was entered. */
#ifdef BLOCK_PROFILER
BLOCK_PROFILER (file, count_basic_blocks);
#endif
count_basic_blocks++;
}
if (GET_CODE (body) == ASM_INPUT)
{
/* There's no telling what that did to the condition codes. */
CC_STATUS_INIT;
if (prescan > 0)
break;
if (! app_on)
{
fprintf (file, ASM_APP_ON);
app_on = 1;
}
fprintf (asm_out_file, "\t%s\n", XSTR (body, 0));
break;
}
/* Detect `asm' construct with operands. */
if (asm_noperands (body) >= 0)
{
int noperands = asm_noperands (body);
rtx *ops;
char *string;
/* There's no telling what that did to the condition codes. */
CC_STATUS_INIT;
if (prescan > 0)
break;
/* alloca won't do here, since only return from `final'
would free it. */
if (noperands > 0)
ops = (rtx *) xmalloc (noperands * sizeof (rtx));
if (! app_on)
{
fprintf (file, ASM_APP_ON);
app_on = 1;
}
/* Get out the operand values. */
string = decode_asm_operands (body, ops, 0, 0, 0);
/* Inhibit aborts on what would otherwise be compiler bugs. */
insn_noperands = noperands;
this_is_asm_operands = insn;
/* Output the insn using them. */
output_asm_insn (string, ops);
this_is_asm_operands = 0;
if (noperands > 0)
free (ops);
break;
}
if (prescan <= 0 && app_on)
{
fprintf (file, ASM_APP_OFF);
app_on = 0;
}
/* Detect insns that are really jump-tables
and output them as such. */
if (GET_CODE (body) == ADDR_VEC)
{
register int vlen, idx;
if (prescan > 0)
break;
vlen = XVECLEN (body, 0);
for (idx = 0; idx < vlen; idx++)
ASM_OUTPUT_ADDR_VEC_ELT (file,
CODE_LABEL_NUMBER (XEXP (XVECEXP (body, 0, idx), 0)));
#ifdef ASM_OUTPUT_CASE_END
ASM_OUTPUT_CASE_END (file,
CODE_LABEL_NUMBER (PREV_INSN (insn)),
insn);
#endif
break;
}
if (GET_CODE (body) == ADDR_DIFF_VEC)
{
register int vlen, idx;
if (prescan > 0)
break;
vlen = XVECLEN (body, 1);
for (idx = 0; idx < vlen; idx++)
ASM_OUTPUT_ADDR_DIFF_ELT (file,
CODE_LABEL_NUMBER (XEXP (XVECEXP (body, 1, idx), 0)),
CODE_LABEL_NUMBER (XEXP (XEXP (body, 0), 0)));
#ifdef ASM_OUTPUT_CASE_END
ASM_OUTPUT_CASE_END (file,
CODE_LABEL_NUMBER (PREV_INSN (insn)),
insn);
#endif
break;
}
if (recog_memoized (insn) == -1
&& GET_CODE (body) == SEQUENCE) /* A delayed-branch sequence */
{
register int i;
if (prescan > 0)
break;
final_sequence = body;
for (i = 0; i < XVECLEN (body, 0); i++)
final_scan_insn (XVECEXP (body, 0, i), file, write_symbols,
optimize, prescan, 1);
final_sequence = 0;
#ifdef DBR_OUTPUT_SEQEND
DBR_OUTPUT_SEQEND (file);
#endif
break;
}
/* We have a real machine instruction as rtl. */
body = PATTERN (insn);
/* Check for redundant test and compare instructions
(when the condition codes are already set up as desired).
This is done only when optimizing; if not optimizing,
it should be possible for the user to alter a variable
with the debugger in between statements
and the next statement should reexamine the variable
to compute the condition codes. */
if (optimize
&& GET_CODE (body) == SET
&& GET_CODE (SET_DEST (body)) == CC0
&& insn != last_ignored_compare)
{
if (GET_CODE (SET_SRC (body)) == SUBREG)
SET_SRC (body) = alter_subreg (SET_SRC (body));
if ((cc_status.value1 != 0
&& rtx_equal_p (SET_SRC (body), cc_status.value1))
|| (cc_status.value2 != 0
&& rtx_equal_p (SET_SRC (body), cc_status.value2)))
{
/* Don't delete insn if has an addressing side-effect */
if (! find_reg_note (insn, REG_INC, 0)
/* or if anything in it is volatile. */
&& ! volatile_refs_p (PATTERN (insn)))
{
/* We don't really delete the insn; just ignore it. */
last_ignored_compare = insn;
break;
}
}
}
/* Following a conditional branch, we have a new basic block. */
if (GET_CODE (insn) == JUMP_INSN && GET_CODE (body) == SET
&& GET_CODE (SET_SRC (body)) != LABEL_REF)
new_block = 1;
/* If this is a conditional branch, maybe modify it
if the cc's are in a nonstandard state
so that it accomplishes the same thing that it would
do straightforwardly if the cc's were set up normally. */
if (cc_status.flags != 0
&& GET_CODE (insn) == JUMP_INSN
&& GET_CODE (body) == SET
&& SET_DEST (body) == pc_rtx
&& GET_CODE (SET_SRC (body)) == IF_THEN_ELSE
/* This is done during prescan; it is not done again
in final scan when prescan has been done. */
&& prescan >= 0)
{
/* This function may alter the contents of its argument
and clear some of the cc_status.flags bits.
It may also return 1 meaning condition now always true
or -1 meaning condition now always false
or 2 meaning condition nontrivial but altered. */
register int result = alter_cond (XEXP (SET_SRC (body), 0));
/* If condition now has fixed value, replace the IF_THEN_ELSE
with its then-operand or its else-operand. */
if (result == 1)
SET_SRC (body) = XEXP (SET_SRC (body), 1);
if (result == -1)
SET_SRC (body) = XEXP (SET_SRC (body), 2);
/* The jump is now either unconditional or a no-op.
If it has become a no-op, don't try to output it.
(It would not be recognized.) */
if (SET_SRC (body) == pc_rtx)
{
PUT_CODE (insn, NOTE);
NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
NOTE_SOURCE_FILE (insn) = 0;
break;
}
/* Rerecognize the instruction if it has changed. */
if (result != 0)
INSN_CODE (insn) = -1;
}
#ifdef STORE_FLAG_VALUE
/* Make same adjustments to instructions that examine the
condition codes without jumping (if this machine has them). */
if (cc_status.flags != 0
&& GET_CODE (body) == SET)
switch (GET_CODE (SET_SRC (body)))
{
case GTU:
case GT:
case LTU:
case LT:
case GEU:
case GE:
case LEU:
case LE:
case EQ:
case NE:
{
register int result;
if (GET_CODE (XEXP (SET_SRC (body), 0)) != CC0)
break;
result = alter_cond (SET_SRC (body));
if (result == 1)
SET_SRC (body) = gen_rtx (CONST_INT, VOIDmode,
STORE_FLAG_VALUE);
if (result == -1)
SET_SRC (body) = const0_rtx;
if (result != 0)
INSN_CODE (insn) = -1;
}
}
#endif /* STORE_FLAG_VALUE */
/* Do machine-specific peephole optimizations if desired. */
if (optimize && !flag_no_peephole && !nopeepholes)
{
rtx next = peephole (insn);
/* When peepholing, if there were notes within the peephole,
emit them before the peephole. */
if (next != 0 && next != NEXT_INSN (insn))
{
rtx note = NEXT_INSN (insn);
rtx prev = PREV_INSN (insn);
while (note != next)
{
final_scan_insn (note, file, write_symbols, optimize,
prescan, nopeepholes);
note = NEXT_INSN (note);
}
/* In case this is prescan, put the notes
in proper position for later rescan. */
note = NEXT_INSN (insn);
PREV_INSN (note) = prev;
NEXT_INSN (prev) = note;
NEXT_INSN (PREV_INSN (next)) = insn;
PREV_INSN (insn) = PREV_INSN (next);
NEXT_INSN (insn) = next;
PREV_INSN (next) = insn;
}
/* PEEPHOLE might have changed this. */
body = PATTERN (insn);
}
/* Try to recognize the instruction.
If successful, verify that the operands satisfy the
constraints for the instruction. Crash if they don't,
since `reload' should have changed them so that they do. */
insn_code_number = recog_memoized (insn);
insn_extract (insn);
for (i = 0; i < insn_n_operands[insn_code_number]; i++)
{
if (GET_CODE (recog_operand[i]) == SUBREG)
recog_operand[i] = alter_subreg (recog_operand[i]);
}
#ifdef REGISTER_CONSTRAINTS
if (! constrain_operands (insn_code_number))
abort ();
#endif
/* Some target machines need to prescan each insn before
it is output. */
#ifdef FINAL_PRESCAN_INSN
FINAL_PRESCAN_INSN (insn, recog_operand,
insn_n_operands[insn_code_number]);
#endif
cc_prev_status = cc_status;
/* Update `cc_status' for this instruction.
The instruction's output routine may change it further.
If the output routine for a jump insn needs to depend
on the cc status, it should look at cc_prev_status. */
NOTICE_UPDATE_CC (body, insn);
/* If the proper template needs to be chosen by some C code,
run that code and get the real template. */
template = insn_template[insn_code_number];
if (template == 0)