-
Notifications
You must be signed in to change notification settings - Fork 0
/
gcc.info-8
executable file
·1122 lines (901 loc) · 48.2 KB
/
gcc.info-8
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
Info file gcc.info, produced by Makeinfo, -*- Text -*- from input
file gcc.texinfo.
This file documents the use and the internals of the GNU compiler.
Copyright (C) 1988, 1989 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided also
that the section entitled ``GNU General Public License'' is included
exactly as in the original, and provided that the entire resulting
derived work is distributed under the terms of a permission notice
identical to this one.
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that the section entitled ``GNU General Public
License'' and this permission notice may be included in translations
approved by the Free Software Foundation instead of in the original
English.
File: gcc.info, Node: Peephole Definitions, Next: Expander Definitions, Prev: Jump Patterns, Up: Machine Desc
Defining Machine-Specific Peephole Optimizers
=============================================
In addition to instruction patterns the `md' file may contain
definitions of machine-specific peephole optimizations.
The combiner does not notice certain peephole optimizations when the
data flow in the program does not suggest that it should try them.
For example, sometimes two consecutive insns related in purpose can
be combined even though the second one does not appear to use a
register computed in the first one. A machine-specific peephole
optimizer can detect such opportunities.
A definition looks like this:
(define_peephole
[INSN-PATTERN-1
INSN-PATTERN-2
...]
"CONDITION"
"TEMPLATE"
"MACHINE-SPECIFIC INFO")
The last string operand may be omitted if you are not using any
machine-specific information in this machine description. If
present, it must obey the same rules as in a `define_insn'.
In this skeleton, INSN-PATTERN-1 and so on are patterns to match
consecutive insns. The optimization applies to a sequence of insns
when INSN-PATTERN-1 matches the first one, INSN-PATTERN-2 matches the
next, and so on.
Each of the insns matched by a peephole must also match a
`define_insn'. Peepholes are checked only at the last stage just
before code generation, and only optionally. Therefore, any insn
which would match a peephole but no `define_insn' will cause a crash
in code generation in an unoptimized compilation, or at various
optimization stages.
The operands of the insns are matched with `match_operands' and
`match_dup', as usual. What is not usual is that the operand numbers
apply to all the insn patterns in the definition. So, you can check
for identical operands in two insns by using `match_operand' in one
insn and `match_dup' in the other.
The operand constraints used in `match_operand' patterns do not have
any direct effect on the applicability of the peephole, but they will
be validated afterward, so make sure your constraints are general
enough to apply whenever the peephole matches. If the peephole
matches but the constraints are not satisfied, the compiler will crash.
It is safe to omit constraints in all the operands of the peephole;
or you can write constraints which serve as a double-check on the
criteria previously tested.
Once a sequence of insns matches the patterns, the CONDITION is
checked. This is a C expression which makes the final decision
whether to perform the optimization (we do so if the expression is
nonzero). If CONDITION is omitted (in other words, the string is
empty) then the optimization is applied to every sequence of insns
that matches the patterns.
The defined peephole optimizations are applied after register
allocation is complete. Therefore, the peephole definition can check
which operands have ended up in which kinds of registers, just by
looking at the operands.
The way to refer to the operands in CONDITION is to write
`operands[I]' for operand number I (as matched by `(match_operand I
...)'). Use the variable `insn' to refer to the last of the insns
being matched; use `PREV_INSN' to find the preceding insns (but be
careful to skip over any `note' insns that intervene).
When optimizing computations with intermediate results, you can use
CONDITION to match only when the intermediate results are not used
elsewhere. Use the C expression `dead_or_set_p (INSN, OP)', where
INSN is the insn in which you expect the value to be used for the
last time (from the value of `insn', together with use of
`PREV_INSN'), and OP is the intermediate value (from `operands[I]').
Applying the optimization means replacing the sequence of insns with
one new insn. The TEMPLATE controls ultimate output of assembler
code for this combined insn. It works exactly like the template of a
`define_insn'. Operand numbers in this template are the same ones
used in matching the original sequence of insns.
The result of a defined peephole optimizer does not need to match any
of the insn patterns in the machine description; it does not even
have an opportunity to match them. The peephole optimizer definition
itself serves as the insn pattern to control how the insn is output.
Defined peephole optimizers are run as assembler code is being
output, so the insns they produce are never combined or rearranged in
any way.
Here is an example, taken from the 68000 machine description:
(define_peephole
[(set (reg:SI 15) (plus:SI (reg:SI 15) (const_int 4)))
(set (match_operand:DF 0 "register_operand" "f")
(match_operand:DF 1 "register_operand" "ad"))]
"FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
"*
{
rtx xoperands[2];
xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
#ifdef MOTOROLA
output_asm_insn (\"move.l %1,(sp)\", xoperands);
output_asm_insn (\"move.l %1,-(sp)\", operands);
return \"fmove.d (sp)+,%0\";
#else
output_asm_insn (\"movel %1,sp@\", xoperands);
output_asm_insn (\"movel %1,sp@-\", operands);
return \"fmoved sp@+,%0\";
#endif
}
")
The effect of this optimization is to change
jbsr _foobar
addql #4,sp
movel d1,sp@-
movel d0,sp@-
fmoved sp@+,fp0
into
jbsr _foobar
movel d1,sp@
movel d0,sp@-
fmoved sp@+,fp0
INSN-PATTERN-1 and so on look *almost* like the second operand of
`define_insn'. There is one important difference: the second operand
of `define_insn' consists of one or more RTX's enclosed in square
brackets. Usually, there is only one: then the same action can be
written as an element of a `define_peephole'. But when there are
multiple actions in a `define_insn', they are implicitly enclosed in
a `parallel'. Then you must explicitly write the `parallel', and the
square brackets within it, in the `define_peephole'. Thus, if an
insn pattern looks like this,
(define_insn "divmodsi4"
[(set (match_operand:SI 0 "general_operand" "=d")
(div:SI (match_operand:SI 1 "general_operand" "0")
(match_operand:SI 2 "general_operand" "dmsK")))
(set (match_operand:SI 3 "general_operand" "=d")
(mod:SI (match_dup 1) (match_dup 2)))]
"TARGET_68020"
"divsl%.l %2,%3:%0")
then the way to mention this insn in a peephole is as follows:
(define_peephole
[...
(parallel
[(set (match_operand:SI 0 "general_operand" "=d")
(div:SI (match_operand:SI 1 "general_operand" "0")
(match_operand:SI 2 "general_operand" "dmsK")))
(set (match_operand:SI 3 "general_operand" "=d")
(mod:SI (match_dup 1) (match_dup 2)))])
...]
...)
File: gcc.info, Node: Expander Definitions, Prev: Peephole Definitions, Up: Machine Desc
Defining RTL Sequences for Code Generation
==========================================
On some target machines, some standard pattern names for RTL
generation cannot be handled with single insn, but a sequence of RTL
insns can represent them. For these target machines, you can write a
`define_expand' to specify how to generate the sequence of RTL.
A `define_expand' is an RTL expression that looks almost like a
`define_insn'; but, unlike the latter, a `define_expand' is used only
for RTL generation and it can produce more than one RTL insn.
A `define_expand' RTX has four operands:
* The name. Each `define_expand' must have a name, since the only
use for it is to refer to it by name.
* The RTL template. This is just like the RTL template for a
`define_peephole' in that it is a vector of RTL expressions each
being one insn.
* The condition, a string containing a C expression. This
expression is used to express how the availability of this
pattern depends on subclasses of target machine, selected by
command-line options when GNU CC is run. This is just like the
condition of a `define_insn' that has a standard name.
* The preparation statements, a string containing zero or more C
statements which are to be executed before RTL code is generated
from the RTL template.
Usually these statements prepare temporary registers for use as
internal operands in the RTL template, but they can also
generate RTL insns directly by calling routines such as
`emit_insn', etc. Any such insns precede the ones that come
from the RTL template.
Every RTL insn emitted by a `define_expand' must match some
`define_insn' in the machine description. Otherwise, the compiler
will crash when trying to generate code for the insn or trying to
optimize it.
The RTL template, in addition to controlling generation of RTL insns,
also describes the operands that need to be specified when this
pattern is used. In particular, it gives a predicate for each operand.
A true operand, which need to be specified in order to generate RTL
from the pattern, should be described with a `match_operand' in its
first occurrence in the RTL template. This enters information on the
operand's predicate into the tables that record such things. GNU CC
uses the information to preload the operand into a register if that
is required for valid RTL code. If the operand is referred to more
than once, subsequent references should use `match_dup'.
The RTL template may also refer to internal ``operands'' which are
temporary registers or labels used only within the sequence made by
the `define_expand'. Internal operands are substituted into the RTL
template with `match_dup', never with `match_operand'. The values of
the internal operands are not passed in as arguments by the compiler
when it requests use of this pattern. Instead, they are computed
within the pattern, in the preparation statements. These statements
compute the values and store them into the appropriate elements of
`operands' so that `match_dup' can find them.
There are two special macros defined for use in the preparation
statements: `DONE' and `FAIL'. Use them with a following semicolon,
as a statement.
`DONE'
Use the `DONE' macro to end RTL generation for the pattern. The
only RTL insns resulting from the pattern on this occasion will
be those already emitted by explicit calls to `emit_insn' within
the preparation statements; the RTL template will not be
generated.
`FAIL'
Make the pattern fail on this occasion. When a pattern fails,
it means that the pattern was not truly available. The calling
routines in the compiler will try other strategies for code
generation using other patterns.
Failure is currently supported only for binary operations
(addition, multiplication, shifting, etc.).
Do not emit any insns explicitly with `emit_insn' before failing.
Here is an example, the definition of left-shift for the SPUR chip:
(define_expand "ashlsi3"
[(set (match_operand:SI 0 "register_operand" "")
(ashift:SI
(match_operand:SI 1 "register_operand" "")
(match_operand:SI 2 "nonmemory_operand" "")))]
""
"
{
if (GET_CODE (operands[2]) != CONST_INT
|| (unsigned) INTVAL (operands[2]) > 3)
FAIL;
}")
This example uses `define_expand' so that it can generate an RTL insn
for shifting when the shift-count is in the supported range of 0 to 3
but fail in other cases where machine insns aren't available. When
it fails, the compiler tries another strategy using different
patterns (such as, a library call).
If the compiler were able to handle nontrivial condition-strings in
patterns with names, then it would be possible to use a `define_insn'
in that case. Here is another case (zero-extension on the 68000)
which makes more use of the power of `define_expand':
(define_expand "zero_extendhisi2"
[(set (match_operand:SI 0 "general_operand" "")
(const_int 0))
(set (strict_low_part
(subreg:HI
(match_dup 0)
0))
(match_operand:HI 1 "general_operand" ""))]
""
"operands[1] = make_safe_from (operands[1], operands[0]);")
Here two RTL insns are generated, one to clear the entire output
operand and the other to copy the input operand into its low half.
This sequence is incorrect if the input operand refers to [the old
value of] the output operand, so the preparation statement makes sure
this isn't so. The function `make_safe_from' copies the
`operands[1]' into a temporary register if it refers to
`operands[0]'. It does this by emitting another RTL insn.
Finally, a third example shows the use of an internal operand.
Zero-extension on the SPUR chip is done by `and'-ing the result
against a halfword mask. But this mask cannot be represented by a
`const_int' because the constant value is too large to be legitimate
on this machine. So it must be copied into a register with
`force_reg' and then the register used in the `and'.
(define_expand "zero_extendhisi2"
[(set (match_operand:SI 0 "register_operand" "")
(and:SI (subreg:SI
(match_operand:HI 1 "register_operand" "")
0)
(match_dup 2)))]
""
"operands[2]
= force_reg (SImode, gen_rtx (CONST_INT,
VOIDmode, 65535)); ")
*Note:* If the `define_expand' is used to serve a standard binary or
unary arithmetic operation, then the last insn it generates must not
be a `code_label', `barrier' or `note'. It must be an `insn',
`jump_insn' or `call_insn'.
File: gcc.info, Node: Machine Macros, Next: Config, Prev: Machine Desc, Up: Top
Machine Description Macros
**************************
The other half of the machine description is a C header file
conventionally given the name `tm-MACHINE.h'. The file `tm.h' should
be a link to it. The header file `config.h' includes `tm.h' and most
compiler source files include `config.h'.
* Menu:
* Run-time Target:: Defining -m options like -m68000 and -m68020.
* Storage Layout:: Defining sizes and alignments of data types.
* Registers:: Naming and describing the hardware registers.
* Register Classes:: Defining the classes of hardware registers.
* Stack Layout:: Defining which way the stack grows and by how much.
* Library Names:: Specifying names of subroutines to call automatically.
* Addressing Modes:: Defining addressing modes valid for memory operands.
* Delayed Branch:: Do branches execute the following instruction?
* Condition Code:: Defining how insns update the condition code.
* Assembler Format:: Defining how to write insns and pseudo-ops to output.
* Cross-compilation:: Handling floating point for cross-compilers.
* Misc:: Everything else.
File: gcc.info, Node: Run-time Target, Next: Storage Layout, Prev: Machine Macros, Up: Machine Macros
Run-time Target Specification
=============================
`CPP_PREDEFINES'
Define this to be a string constant containing `-D' options to
define the predefined macros that identify this machine and
system. These macros will be predefined unless the `-ansi'
option is specified.
In addition, a parallel set of macros are predefined, whose
names are made by appending `__' at the beginning and at the
end. These `__' macros are permitted by the ANSI standard, so
they are predefined regardless of whether `-ansi' is specified.
For example, on the Sun, one can use the following value:
"-Dmc68000 -Dsun -Dunix"
The result is to define the macros `__mc68000__', `__sun__' and
`__unix__' unconditionally, and the macros `mc68000', `sun' and
`unix' provided `-ansi' is not specified.
`CPP_SPEC'
A C string constant that tells the GNU CC driver program options
to pass to CPP. It can also specify how to translate options
you give to GNU CC into options for GNU CC to pass to the CPP.
Do not define this macro if it does not need to do anything.
`CC1_SPEC'
A C string constant that tells the GNU CC driver program options
to pass to CC1. It can also specify how to translate options
you give to GNU CC into options for GNU CC to pass to the CC1.
Do not define this macro if it does not need to do anything.
`extern int target_flags;'
This declaration should be present.
`TARGET_...'
This series of macros is to allow compiler command arguments to
enable or disable the use of optional features of the target
machine. For example, one machine description serves both the
68000 and the 68020; a command argument tells the compiler
whether it should use 68020-only instructions or not. This
command argument works by means of a macro `TARGET_68020' that
tests a bit in `target_flags'.
Define a macro `TARGET_FEATURENAME' for each such option. Its
definition should test a bit in `target_flags'; for example:
#define TARGET_68020 (target_flags & 1)
One place where these macros are used is in the
condition-expressions of instruction patterns. Note how
`TARGET_68020' appears frequently in the 68000 machine
description file, `m68k.md'. Another place they are used is in
the definitions of the other macros in the `tm-MACHINE.h' file.
`TARGET_SWITCHES'
This macro defines names of command options to set and clear
bits in `target_flags'. Its definition is an initializer with a
subgrouping for each command option.
Each subgrouping contains a string constant, that defines the
option name, and a number, which contains the bits to set in
`target_flags'. A negative number says to clear bits instead;
the negative of the number is which bits to clear. The actual
option name is made by appending `-m' to the specified name.
One of the subgroupings should have a null string. The number
in this grouping is the default value for `target_flags'. Any
target options act starting with that value.
Here is an example which defines `-m68000' and `-m68020' with
opposite meanings, and picks the latter as the default:
#define TARGET_SWITCHES \
{ { "68020", 1}, \
{ "68000", -1}, \
{ "", 1}}
`OVERRIDE_OPTIONS'
Sometimes certain combinations of command options do not make
sense on a particular target machine. You can define a macro
`OVERRIDE_OPTIONS' to take account of this. This macro, if
defined, is executed once just after all the command options
have been parsed.
File: gcc.info, Node: Storage Layout, Next: Registers, Prev: Run-time Target, Up: Machine Macros
Storage Layout
==============
Note that the definitions of the macros in this table which are sizes
or alignments measured in bits do not need to be constant. They can
be C expressions that refer to static variables, such as the
`target_flags'. *Note Run-time Target::.
`BITS_BIG_ENDIAN'
Define this macro if the most significant bit in a byte has the
lowest number. This means that bit-field instructions count
from the most significant bit. If the machine has no bit-field
instructions, this macro is irrelevant.
This macro does not affect the way structure fields are packed
into bytes or words; that is controlled by `BYTES_BIG_ENDIAN'.
`BYTES_BIG_ENDIAN'
Define this macro if the most significant byte in a word has the
lowest number.
`WORDS_BIG_ENDIAN'
Define this macro if, in a multiword object, the most
significant word has the lowest number.
`BITS_PER_UNIT'
Number of bits in an addressable storage unit (byte); normally 8.
`BITS_PER_WORD'
Number of bits in a word; normally 32.
`UNITS_PER_WORD'
Number of storage units in a word; normally 4.
`POINTER_SIZE'
Width of a pointer, in bits.
`POINTER_BOUNDARY'
Alignment required for pointers stored in memory, in bits.
`PARM_BOUNDARY'
Normal alignment required for function parameters on the stack,
in bits. All stack parameters receive least this much alignment
regardless of data type. On most machines, this is the same as
the size of an integer.
`MAX_PARM_BOUNDARY'
Largest alignment required for any stack parameters, in bits.
If the data type of the parameter calls for more alignment than
`PARM_BOUNDARY', then it is given extra padding up to this limit.
Don't define this macro if it would be equal to `PARM_BOUNDARY';
in other words, if the alignment of a stack parameter should not
depend on its data type (as is the case on most machines).
`STACK_BOUNDARY'
Define this macro if you wish to preserve a certain alignment
for the stack pointer at all times. The definition is a C
expression for the desired alignment (measured in bits).
`FUNCTION_BOUNDARY'
Alignment required for a function entry point, in bits.
`BIGGEST_ALIGNMENT'
Biggest alignment that any data type can require on this
machine, in bits.
`CONSTANT_ALIGNMENT (CODE, TYPEALIGN)'
A C expression to compute the alignment for a constant. The
argument TYPEALIGN is the alignment required for the constant's
data type. CODE is the tree code of the constant itself.
If this macro is not defined, the default is to use TYPEALIGN.
If you do define this macro, the value must be a multiple of
TYPEALIGN.
The purpose of defining this macro is usually to cause string
constants to be word aligned so that `dhrystone' can be made to
run faster.
`EMPTY_FIELD_BOUNDARY'
Alignment in bits to be given to a structure bit field that
follows an empty field such as `int : 0;'.
`STRUCTURE_SIZE_BOUNDARY'
Number of bits which any structure or union's size must be a
multiple of. Each structure or union's size is rounded up to a
multiple of this.
If you do not define this macro, the default is the same as
`BITS_PER_UNIT'.
`STRICT_ALIGNMENT'
Define this if instructions will fail to work if given data not
on the nominal alignment. If instructions will merely go slower
in that case, do not define this macro.
`PCC_BITFIELD_TYPE_MATTERS'
Define this if you wish to imitate a certain bizarre behavior
pattern of some instances of PCC: a bit field whose declared
type is `int' has the same effect on the size and alignment of a
structure as an actual `int' would have.
Just what effect that is in GNU CC depends on other parameters,
but on most machines it would force the structure's alignment
and size to a multiple of 32 or `BIGGEST_ALIGNMENT' bits.
`MAX_FIXED_MODE_SIZE'
An integer expression for the largest integer machine mode that
should actually be used. All integer machine modes of this size
or smaller can be used for structures and unions with the
appropriate sizes.
`CHECK_FLOAT_VALUE (MODE, VALUE)'
A C statement to validate the value VALUE (or type `double') for
mode MODE. This means that you check whether VALUE fits within
the possible range of values for mode MODE on this target
machine. The mode MODE is always `SFmode' or `DFmode'.
If VALUE is not valid, you should call `error' to print an error
message and then assign some valid value to VALUE. Allowing an
invalid value to go through the compiler can produce incorrect
assembler code which may even cause Unix assemblers to crash.
This macro need not be defined if there is no work for it to do.
File: gcc.info, Node: Registers, Next: Register Classes, Prev: Storage Layout, Up: Machine Macros
Register Usage
==============
`FIRST_PSEUDO_REGISTER'
Number of hardware registers known to the compiler. They
receive numbers 0 through `FIRST_PSEUDO_REGISTER-1'; thus, the
first pseudo register's number really is assigned the number
`FIRST_PSEUDO_REGISTER'.
`FIXED_REGISTERS'
An initializer that says which registers are used for fixed
purposes all throughout the compiled code and are therefore not
available for general allocation. These would include the stack
pointer, the frame pointer (except on machines where that can be
used as a general register when no frame pointer is needed), the
program counter on machines where that is considered one of the
addressable registers, and any other numbered register with a
standard use.
This information is expressed as a sequence of numbers,
separated by commas and surrounded by braces. The Nth number is
1 if register N is fixed, 0 otherwise.
The table initialized from this macro, and the table initialized
by the following one, may be overridden at run time either
automatically, by the actions of the macro
`CONDITIONAL_REGISTER_USAGE', or by the user with the command
options `-ffixed-REG', `-fcall-used-REG' and `-fcall-saved-REG'.
`CALL_USED_REGISTERS'
Like `FIXED_REGISTERS' but has 1 for each register that is
clobbered (in general) by function calls as well as for fixed
registers. This macro therefore identifies the registers that
are not available for general allocation of values that must
live across function calls.
If a register has 0 in `CALL_USED_REGISTERS', the compiler
automatically saves it on function entry and restores it on
function exit, if the register is used within the function.
`DEFAULT_CALLER_SAVES'
Define this macro if function calls on the target machine do not
preserve any registers; in other words, if `CALL_USED_REGISTERS'
has 1 for all registers. This macro enables `-fcaller-saves' by
default. Eventually that option will be enabled by default on
all machines and both the option and this macro will be
eliminated.
`CONDITIONAL_REGISTER_USAGE'
Zero or more C statements that may conditionally modify two
variables `fixed_regs' and `call_used_regs' (both of type `char
[]') after they have been initialized from the two preceding
macros.
This is necessary in case the fixed or call-clobbered registers
depend on target flags.
You need not define this macro if it has no work to do.
If the usage of an entire class of registers depends on the
target flags, you may indicate this to GCC by using this macro
to modify `fixed_regs' and `call_used_regs' to 1 for each of the
registers in the classes which should not be used by GCC. Also
define the macro `REG_CLASS_FROM_LETTER' to return `NO_REGS' if
it is called with a letter for a class that shouldn't be used.
(However, if this class is not included in `GENERAL_REGS' and
all of the insn patterns whose constraints permit this class are
controlled by target switches, then GCC will automatically avoid
using these registers when the target switches are opposed to
them.)
`OVERLAPPING_REGNO_P (REGNO)'
If defined, this is a C expression whose value is nonzero if
hard register number REGNO is an overlapping register. This
means a hard register which overlaps a hard register with a
different number. (Such overlap is undesirable, but
occasionally it allows a machine to be supported which otherwise
could not be.) This macro must return nonzero for *all* the
registers which overlap each other. GNU CC can use an
overlapping register only in certain limited ways. It can be
used for allocation within a basic block, and may be spilled for
reloading; that is all.
If this macro is not defined, it means that none of the hard
registers overlap each other. This is the usual situation.
`INSN_CLOBBERS_REGNO_P (INSN, REGNO)'
If defined, this is a C expression whose value should be nonzero
if the insn INSN has the effect of mysteriously clobbering the
contents of hard register number REGNO. By ``mysterious'' we
mean that the insn's RTL expression doesn't describe such an
effect.
If this macro is not defined, it means that no insn clobbers
registers mysteriously. This is the usual situation; all else
being equal, it is best for the RTL expression to show all the
activity.
`PRESERVE_DEATH_INFO_REGNO_P (REGNO)'
If defined, this is a C expression whose value is nonzero if
accurate `REG_DEAD' notes are needed for hard register number
REGNO at the time of outputting the assembler code. When this
is so, a few optimizations that take place after register
allocation and could invalidate the death notes are not done
when this register is involved.
You would arrange to preserve death info for a register when
some of the code in the machine description which is executed to
write the assembler code looks at the death notes. This is
necessary only when the actual hardware feature which GNU CC
thinks of as a register is not actually a register of the usual
sort. (It might, for example, be a hardware stack.)
If this macro is not defined, it means that no death notes need
to be preserved. This is the usual situation.
`HARD_REGNO_REGS (REGNO, MODE)'
A C expression for the number of consecutive hard registers,
starting at register number REGNO, required to hold a value of
mode MODE.
On a machine where all registers are exactly one word, a
suitable definition of this macro is
#define HARD_REGNO_NREGS(REGNO, MODE) \
((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
/ UNITS_PER_WORD))
`HARD_REGNO_MODE_OK (REGNO, MODE)'
A C expression that is nonzero if it is permissible to store a
value of mode MODE in hard register number REGNO (or in several
registers starting with that one). For a machine where all
registers are equivalent, a suitable definition is
#define HARD_REGNO_MODE_OK(REGNO, MODE) 1
It is not necessary for this macro to check for the numbers of
fixed registers, because the allocation mechanism considers them
to be always occupied.
On some machines, double-precision values must be kept in
even/odd register pairs. The way to implement that is to define
this macro to reject odd register numbers for such modes.
GNU CC assumes that it can always move values between registers
and (suitably addressed) memory locations. If it is impossible
to move a value of a certain mode between memory and certain
registers, then `HARD_REGNO_MODE_OK' must not allow this mode in
those registers.
Many machines have special registers for floating point
arithmetic. Often people assume that floating point machine
modes are allowed only in floating point registers. This is not
true. Any registers that can hold integers can safely *hold* a
floating point machine mode, whether or not floating arithmetic
can be done on it in those registers.
The true significance of special floating registers is rather
that non-floating-point machine modes *may not* go in those
registers. This is true if the floating registers normalize any
value stored in them, because storing a non-floating value there
would garble it. If the floating registers do not automatically
normalize, if you can store any bit pattern in one and retrieve
it unchanged without a trap, then any machine mode may go in a
floating register and this macro should say so.
Sometimes there are floating registers that are especially slow
to access, so that it is better to store a value in a stack
frame than in such a register if floating point arithmetic is
not being done. As long as the floating registers are not in
class `GENERAL_REGS', they will not be used unless some insn's
constraint asks for one.
It is obligatory to support floating point `move' instructions
into and out of any registers that can hold fixed point values,
because unions and structures (which have modes `SImode' or
`DImode') can be in those registers and they may have floating
point members.
There may also be a need to support fixed point `move'
instructions in and out of floating point registers.
Unfortunately, I have forgotten why this was so, and I don't
know whether it is still true. If `HARD_REGNO_MODE_OK' rejects
fixed point values in floating point registers, then the
constraints of the fixed point `move' instructions must be
designed to avoid ever trying to reload into a floating point
register.
`MODES_TIEABLE_P (MODE1, MODE2)'
A C expression that is nonzero if it is desirable to choose
register allocation so as to avoid move instructions between a
value of mode MODE1 and a value of mode MODE2.
If `HARD_REGNO_MODE_OK (R, MODE1)' and `HARD_REGNO_MODE_OK (R,
MODE2)' are ever different for any R, then `MODES_TIEABLE_P
(MODE1, MODE2)' must be zero.
`PC_REGNUM'
If the program counter has a register number, define this as
that register number. Otherwise, do not define it.
`STACK_POINTER_REGNUM'
The register number of the stack pointer register, which must
also be a fixed register according to `FIXED_REGISTERS'. On
many machines, the hardware determines which register this is.
`FRAME_POINTER_REGNUM'
The register number of the frame pointer register, which is used
to access automatic variables in the stack frame. On some
machines, the hardware determines which register this is. On
other machines, you can choose any register you wish for this
purpose.
`FRAME_POINTER_REQUIRED'
A C expression which is nonzero if a function must have and use
a frame pointer. This expression is evaluated in the reload
pass, in the function `reload', and it can in principle examine
the current function and decide according to the facts, but on
most machines the constant 0 or the constant 1 suffices. Use 0
when the machine allows code to be generated with no frame
pointer, and doing so saves some time or space. Use 1 when
there is no possible advantage to avoiding a frame pointer.
In certain cases, the compiler does not know how to produce
valid code without a frame pointer. The compiler recognizes
those cases and automatically gives the function a frame pointer
regardless of what `FRAME_POINTER_REQUIRED' says. You don't
need to worry about them.
In a function that does not require a frame pointer, the frame
pointer register can be allocated for ordinary usage, unless you
mark it as a fixed register. See `FIXED_REGISTERS' for more
information.
`ARG_POINTER_REGNUM'
The register number of the arg pointer register, which is used
to access the function's argument list. On some machines, this
is the same as the frame pointer register. On some machines,
the hardware determines which register this is. On other
machines, you can choose any register you wish for this purpose.
If this is not the same register as the frame pointer register,
then you must mark it as a fixed register according to
`FIXED_REGISTERS'.
`STATIC_CHAIN_REGNUM'
The register number used for passing a function's static chain
pointer. This is needed for languages such as Pascal and Algol
where functions defined within other functions can access the
local variables of the outer functions; it is not currently used
because C does not provide this feature, but you must define the
macro.
The static chain register need not be a fixed register.
`STRUCT_VALUE_REGNUM'
When a function's value's mode is `BLKmode', the value is not
returned according to `FUNCTION_VALUE'. Instead, the caller
passes the address of a block of memory in which the value
should be stored.
If this value is passed in a register, then
`STRUCT_VALUE_REGNUM' should be the number of that register.
`STRUCT_VALUE'
If the structure value address is not passed in a register,
define `STRUCT_VALUE' as an expression returning an RTX for the
place where the address is passed. If it returns a `mem' RTX,
the address is passed as an ``invisible'' first argument.
`STRUCT_VALUE_INCOMING_REGNUM'
On some architectures the place where the structure value
address is found by the called function is not the same place
that the caller put it. This can be due to register windows, or
it could be because the function prologue moves it to a
different place.
If the incoming location of the structure value address is in a
register, define this macro as the register number.
`STRUCT_VALUE_INCOMING'
If the incoming location is not a register, define
`STRUCT_VALUE_INCOMING' as an expression for an RTX for where
the called function should find the value. If it should find
the value on the stack, define this to create a `mem' which
refers to the frame pointer. If the value is a `mem', the
compiler assumes it is for an invisible first argument, and
leaves space for it when finding the first real argument.
`REG_ALLOC_ORDER'
If defined, an initializer for a vector of integers, containing
the numbers of hard registers in the order in which the GNU CC
should prefer to use them (from most preferred to least).
If this macro is not defined, registers are used lowest numbered
first (all else being equal).
One use of this macro is on the 360, where the highest numbered
registers must always be saved and the save-multiple-registers
instruction supports only sequences of consecutive registers.
This macro is defined to cause the highest numbered allocatable
registers to be used first.
File: gcc.info, Node: Register Classes, Next: Stack Layout, Prev: Registers, Up: Machine Macros
Register Classes
================
On many machines, the numbered registers are not all equivalent. For
example, certain registers may not be allowed for indexed addressing;
certain registers may not be allowed in some instructions. These
machine restrictions are described to the compiler using "register
classes".
You define a number of register classes, giving each one a name and
saying which of the registers belong to it. Then you can specify
register classes that are allowed as operands to particular
instruction patterns.
In general, each register will belong to several classes. In fact,
one class must be named `ALL_REGS' and contain all the registers.
Another class must be named `NO_REGS' and contain no registers.
Often the union of two classes will be another class; however, this
is not required.
One of the classes must be named `GENERAL_REGS'. There is nothing
terribly special about the name, but the operand constraint letters
`r' and `g' specify this class. If `GENERAL_REGS' is the same as
`ALL_REGS', just define it as a macro which expands to `ALL_REGS'.
The way classes other than `GENERAL_REGS' are specified in operand
constraints is through machine-dependent operand constraint letters.
You can define such letters to correspond to various classes, then
use them in operand constraints.
You should define a class for the union of two classes whenever some
instruction allows both classes. For example, if an instruction
allows either a floating-point (coprocessor) register or a general
register for a certain operand, you should define a class
`FLOAT_OR_GENERAL_REGS' which includes both of them. Otherwise you
will get suboptimal code.
You must also specify certain redundant information about the
register classes: for each class, which classes contain it and which
ones are contained in it; for each pair of classes, the largest class
contained in their union.
When a value occupying several consecutive registers is expected in a
certain class, all the registers used must belong to that class.
Therefore, register classes cannot be used to enforce a requirement
for a register pair to start with an even-numbered register. The way
to specify this requirement is with `HARD_REGNO_MODE_OK'.
Register classes used for input-operands of bitwise-and or shift
instructions have a special requirement: each such class must have,
for each fixed-point machine mode, a subclass whose registers can
transfer that mode to or from memory. For example, on some machines,
the operations for single-byte values (`QImode') are limited to
certain registers. When this is so, each register class that is used
in a bitwise-and or shift instruction must have a subclass consisting
of registers from which single-byte values can be loaded or stored.
This is so that `PREFERRED_RELOAD_CLASS' can always have a possible
value to return.
`enum reg_class'
An enumeral type that must be defined with all the register
class names as enumeral values. `NO_REGS' must be first.
`ALL_REGS' must be the last register class, followed by one more
enumeral value, `LIM_REG_CLASSES', which is not a register class
but rather tells how many classes there are.
Each register class has a number, which is the value of casting
the class name to type `int'. The number serves as an index in
many of the tables described below.
`N_REG_CLASSES'
The number of distinct register classes, defined as follows:
#define N_REG_CLASSES (int) LIM_REG_CLASSES
`REG_CLASS_NAMES'
An initializer containing the names of the register classes as C
string constants. These names are used in writing some of the
debugging dumps.
`REG_CLASS_CONTENTS'
An initializer containing the contents of the register classes,
as integers which are bit masks. The Nth integer specifies the
contents of class N. The way the integer MASK is interpreted is
that register R is in the class if `MASK & (1 << R)' is 1.
When the machine has more than 32 registers, an integer does not