--- gcc/internals.texinfo 2018/04/24 16:42:03 1.1.1.6 +++ gcc/internals.texinfo 2018/04/24 16:44:48 1.1.1.9 @@ -39,9 +39,9 @@ Free Software Foundation instead of in t @sp 2 @center Richard M. Stallman @sp 3 -@center last updated 26 June 1988 +@center last updated 12 September 1988 @sp 1 -@center for version 1.23 +@center for version 1.28 @page @vskip 0pt plus 1filll Copyright @copyright{} 1988 Free Software Foundation, Inc. @@ -58,9 +58,9 @@ distributed under the terms of a permiss 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 CC General Public License'' may be -included in a translation approved by the author instead of in the original -English. +except that the section entitled ``GNU CC General Public License'' and +this permission notice may be included in translations approved by the +Free Software Foundation instead of in the original English. @end titlepage @page @@ -275,10 +275,17 @@ Charles LaBrec contributed the support f 68020 system. @item -Michael Tiemann of MCC wrote the description of the National -Semiconductor 32000 series cpu, with some contributions from Jan Stein -of the Chalmers Computer Club. Tiemann also wrote the code for inline -function integration and for the SPARC cpu and Motorola 88000 cpu. +Michael Tiemann of MCC wrote most of the description of the National +Semiconductor 32000 series cpu. He also wrote the code for inline +function integration and for the SPARC cpu and Motorola 88000 cpu +and part of the Sun FPA support. + +@item +Jan Stein of the Chalmers Computer Society provided support for +Genix, as well as part of the 32000 machine description. + +@item +Randy Smith finished the Sun FPA support. @item Robert Brown implemented the support for Encore 32000 systems. @@ -423,14 +430,25 @@ to @code{unsigned int}. Out-of-range floating point literals are not an error. @item -In the preprocessor, comments convert to nothing at all, rather than to -a space. This allows traditional token concatenation. +In the preprocessor, comments convert to nothing at all, rather than +to a space. This allows traditional token concatenation. @item -In the preprocessor, single and double quote characters are ignored -when scanning macro definitions, so that macro arguments can be replaced -even within a string or character constant. Quote characters are also -ignored when skipping text inside a failing conditional directive. +In the preprocessor, macro arguments are recognized within string +constants in a macro definition (and their values are stringified, +though without additional quote marks, when they appear in such a +context). The preprocessor always considers a string constant to end +at a newline. + +@item +The predefined macro @code{__STDC__} is not defined when you use +@samp{-traditional}, but @code{__GNUC__} is (since the GNU extensions +which @code{__GNUC__} indicates are not affected by +@samp{-traditional}). If you need to write header files that work +differently depending on whether @samp{-traditional} is in use, by +testing both of these predefined macros you can distinguish four +situations: GNU C, traditional GNU C, other ANSI C compilers, and +other old C compilers. @end itemize @item -O @@ -580,6 +598,15 @@ Warn whenever a comment-start sequence @ @item -Wall All of the above @samp{-W} options combined. +@item -Wwrite-strings +Give string constants the type @code{const char[@var{length}]} so that +copying the address of one into a non-@code{const} @code{char *} +pointer will get a warning. These warnings will help you find at +compile time code that can try to write into a string constant, but +only if you have been very careful about using @code{const} in +declarations and prototypes. Otherwise, it will just be a nuisance; +this is why we did not make @samp{-Wall} request these warnings. + @item -p Generate extra code to write profile information suitable for the analysis program @code{prof}. @@ -626,16 +653,21 @@ description: @table @samp @item -m68020 +@itemx -mc68020 Generate output for a 68020 (rather than a 68000). This is the default if you use the unmodified sources. @item -m68000 +@item -mc68000 Generate output for a 68000 (rather than a 68020). @item -m68881 Generate output containing 68881 instructions for floating point. This is the default if you use the unmodified sources. +@item -mfpa +Generate output containing Sun FPA instructions for floating point. + @item -msoft-float Generate output containing library calls for floating point. @@ -971,11 +1003,23 @@ config file for the machine you are usin file is responsible for defining information about the host machine. It includes @file{tm.h}. -The file's name should be @file{config-@var{machine}.h}. On VMS, use -@file{config-vms.h} rather than @file{config-vax.h}. On the HP 9000 -series 300, use @file{config-hp9k3.h} rather than -@file{config-m68k.h}. On Suns (model 3 or 4) running system version -4, use @file{config-sun4.h}.@refill +The file's name should be @file{config-@var{machine}.h}, with these +exceptions: + +@table @file +@item config-vms.h +for vaxen running VMS. +@item config-vaxv.h +for vaxen running system V. +@item config-i386v.h +for Intel 80386's running system V. +@item config-sun4.h +for Suns (model 2, 3 or 4) running @emph{operating system} version 4. +@item config-hp9k3.h +for the HP 9000 series 300. +@item config-gnx.h +for the ns32000 running Genix +@end table If your system does not support symbolic links, you might want to set up @file{config.h} to contain a @samp{#include} command which @@ -986,49 +1030,53 @@ Make a symbolic link named @file{tm.h} t macro file for your machine (its name should be @file{tm-@var{machine}.h}). -For the 68000/68020, do not use @file{tm-m68k.h} directly; -instead use one of the files @file{tm-sun3.h}, @file{tm-sun2.h}, -@file{tm-isi68.h}, @file{tm-news800.h} or @file{tm-3b1.h}. Each -of those files includes @file{tm-m68k.h} but sets up a few things -differently as appropriate to the specific model of -machine.@refill - -There are two files you can use for a 680x0 running HPUX: -@file{tm-hp9k320.h} and @file{tm-hp9k320g.h}. Use the former if -you are installing GNU CC alone. The latter is for another option -where GNU CC together with the GNU assembler, linker, debugger -and other utilities are used to replace all of HPUX that deals -with compilation. Not all of the pieces of GNU software needed for -this mode of operation are as yet in distribution; full instructions -will appear here in the future.@refill +If your system is a 68000, don't use the file @file{tm-m68k.h} +directly. Instead, use one of these files: + +@table @file +@item tm-sun3.h +for Sun 3 machines. +@item tm-sun2.h +for Sun 2 machines. +@item tm-3b1.h +for AT&T 3b1 (aka 7300 Unix PC). +@item tm-isi68.h +for Integrated Solutions systems. +@item tm-news800.h +for SONY News systems. +@item tm-hp9k320.h +for HPUX systems, if you are using GNU CC with the system's +assembler and linker. +@item tm-hp9k320g.h +for HPUX systems, if you are using the GNU assembler, linker and +other utilities. Not all of the pieces of GNU software needed +for this mode of operation are as yet in distribution; full +instructions will appear here in the future.@refill +@end table For the vax, use @file{tm-vax.h} on BSD Unix, @file{tm-vaxv.h} on system V, or @file{tm-vms.h} on VMS.@refill -For the SPARC, use @file{tm-sparc.h}. +For the SPARC (Sun 4), use @file{tm-sparc.h}. For the Motorola 88000, use @file{tm-m88k.h}. The support for the 88000 has a few unfinished spots because there was no way to run the output. Bugs are suspected in handling of branch-tables and in the function prologue and epilogue. -For the 80386, don't use @file{tm-i386.h} directly. Use @file{tm-i386v.h} -if the target machine is running system V, or @file{tm-compaq.h} for a -Compaq. +For the 80386, don't use @file{tm-i386.h} directly. Use +@file{tm-i386v.h} if the target machine is running system V, +@file{tm-seq386.h} for a Sequent 386 system, or @file{tm-compaq.h} for +a Compaq. For the 32000, use @file{tm-sequent.h} if you are using a Sequent -machine, or @file{tm-encore.h} for an Encore machine; otherwise, -perhaps @file{tm-ns32k.h} will work for you. If you are trying to use -GNU CC on GENIX, you may need to get the version of @code{malloc} from -GNU Emacs instead of the system library version, and you probably need -to cause the following assembler code to be executed in @file{crt0.o} -in order to run the GNU CC output: - -@example -lprd sb,$0 -sprd mod,r0 -movqd $0,0(r0) -@end example +machine, or @file{tm-encore.h} for an Encore machine, or +@file{tm-gnx.h} if you are using Genix version 3; otherwise, perhaps +@file{tm-ns32k.h} will work for you. + +Note that Genix has bugs in @code{alloca} and @code{malloc}; you must +get the compiled versions of these from GNU Emacs and edit GNU CC's +@file{Makefile} to use them. Note that Encore systems are supported only under BSD. @@ -1044,13 +1092,12 @@ subroutine file for your machine (its na @item Make sure the Bison parser generator is installed. (This is -unnecessary if the Bison output files @file{parse.tab.c} and -@file{cexp.c} are more recent than @file{parse.y} and @file{cexp.y} +unnecessary if the Bison output files @file{c-parse.tab.c} and +@file{cexp.c} are more recent than @file{c-parse.y} and @file{cexp.y} and you do not plan to change the @samp{.y} files.) -Note that if you have an old version of Bison you may get an error -from the line with the @samp{%expect} directive. If so, simply remove -that line from @file{parse.y} and proceed. +Bison versions older that Sept 8, 1988 will produce incorrect output +for @file{c-parse.tab.c}. @item If you are using a Sun, make sure the environment variable @@ -1126,6 +1173,11 @@ program looks for them. It also copies into the directory @file{/usr/local}, so that it appears in typical execution search paths.@refill +@strong{Warning: there is a bug in @code{alloca} in the Sun library. +To avoid this bug, install the binaries of GNU CC that were compiled +by GNU CC. They use @code{alloca} as a built-in function and never +the one in the library.} + @strong{Warning: the GNU CPP may not work for @file{ioctl.h}, @file{ttychars.h} and other system header files unless the @samp{-traditional} option is used.} The bug is in the header files: @@ -1350,6 +1402,16 @@ by Bison grammar rules rather than C cod flag cannot alter it. @item +PCC allows typedef names to be used as function parameters. The +difficulty described immediately above applies here too. + +@item +PCC allows whitespace in the middle of compound assignment operators +such as @samp{+=}. GNU CC, following the ANSI standard, does not +allow this. The difficulty described immediately above applies here +too. + +@item When compiling functions that return @code{float}, PCC converts it to a double. GNU CC actually returns a @code{float}. If you are concerned with PCC compatibility, you should declare your functions to return @@ -1968,7 +2030,10 @@ operands in any instruction pattern in t Output operand expressions must be lvalues; the compiler can check this. The input operands need not be lvalues. The compiler cannot check whether the operands have data types that are reasonable for the instruction being -executed. +executed. It does not parse the assembler instruction template and does +not know what it means, or whether it is valid assembler input. The +extended @code{asm} feature is most often used for machine instructions +that the compiler itself does not know exist. If there are no output operands, and there are input operands, then you should write two colons in a row where the output operands would go. @@ -1993,6 +2058,23 @@ asm ("combine %2,%0" : "=r" (foo) : "0" The constraint @samp{"0"} for operand 1 says that it must occupy the same location as operand 0. +Only a digit in the constraint can guarantee that one operand will be in +the same place as another. The mere fact that @code{foo} is the value of +both operands is not enough to guarantee that they will be in the same +place in the generated assembler code. The following would not work: + +@example +asm ("combine %2,%0" : "=r" (foo) : "r" (foo), "g" (bar)); +@end example + +Various optimizations or reloading could cause operands 0 and 1 to be in +different registers; GNU CC knows no reason not to do so. For example, the +compiler might find a copy of the value of @code{foo} in one register and +use it for operand 1, but generate the output operand 0 in a different +register (copying it afterward to @code{foo}'s own address). Of course, +since the register for operand 1 is not even mentioned in the assembler +code, the result will not work, but GNU CC can't tell that. + Unless an output operand has the @samp{&} constraint modifier, GNU CC may allocate it in the same register as an unrelated input operand, on the assumption that the inputs are consumed before the outputs are produced. @@ -2000,6 +2082,17 @@ This assumption may be false if the asse more than one instruction. In such a case, use @samp{&} for each output operand that may not overlap an input. @xref{Modifiers}. +Some instructions clobber specific hard registers. To describe this, +write a third colon after the input operands, followed by the names of +the clobbered hard registers (given as strings). For example, on the vax, + +@example +asm volatile ("movc3 %0,%1,%2" + : /* no outputs */ + : "g" (from), "g" (to), "g" (count) + : "r0", "r1", "r2", "r3", "r4", "r5"); +@end example + Usually the most convenient way to use these @code{asm} instructions is to encapsulate them in macros that look like functions. For example, @@ -2038,21 +2131,17 @@ example: @example #define set_priority(x) \ -asm volatile ("set_priority %1": \ - "=m" (*(char *)0): "g" (x)) +asm volatile ("set_priority %0": /* no outputs */ : "g" (x)) @end example -@noindent -Note that we have supplied an output operand which is not actually used in -the instruction. This is because @code{asm} requires at least one output -operand. This requirement exists for internal implementation reasons and -we might be able to relax it in the future. - -In this case output operand has the additional benefit effect of giving the -appearance of writing in memory. As a result, GNU CC will assume that data -previously fetched from memory must be fetched again if needed again later. -This may be desirable if you have not employed the @code{volatile} keyword -on all the variable declarations that ought to have it. +It is a natural idea to look for a way to give access to the condition +code left by the assembler instruction. However, when we attempted to +implement this, we found no way to make it work reliably. The problem +is that output operands might need reloading, which would result in +additional following ``store'' instructions. On most machines, these +instructions would alter the condition code before there was time to +test it. This problem doesn't arise for ordinary ``test'' and +``compare'' instructions because they don't have any output operands. @node Asm Labels,,Extended Asm, Extensions @section Controlling Names Used in Assembler Code @@ -2384,27 +2473,43 @@ GNU CC is normally configured to use the normally in use on the target system. This is done with the machine-description macros described (@pxref{Machine Macros}). -However, returning of structure and union values is done differently. -As a result, functions compiled with PCC returning such types cannot -be called from code compiled with GNU CC, and vice versa. This usually -does not cause trouble because the Unix library routines don't return -structures and unions. - -Structures and unions that are 1, 2, 4 or 8 bytes long are returned in the -same registers used for @code{int} or @code{double} return values. (GNU CC -typically allocates variables of such types in registers also.) Structures -and unions of other sizes are returned by storing them into an address -passed by the caller in a register. This method is faster than the one -normally used by PCC and is also reentrant. The register used for passing -the address is specified by the machine-description macro -@code{STRUCT_VALUE}. - -GNU CC always passes arguments on the stack. At some point it will be -extended to pass arguments in registers, for machines which use that as -the standard calling convention. This will make it possible to use such -a convention on other machines as well. However, that would render it -completely incompatible with PCC. We will probably do this once we -have a complete GNU system so we can compile the libraries with GNU CC. +However, returning of structure and union values is done differently on +some target machines. As a result, functions compiled with PCC +returning such types cannot be called from code compiled with GNU CC, +and vice versa. This does not cause trouble often because few Unix +library routines return structures or unions. + +GNU CC code returns structures and unions that are 1, 2, 4 or 8 bytes +long in the same registers used for @code{int} or @code{double} return +values. (GNU CC typically allocates variables of such types in +registers also.) Structures and unions of other sizes are returned by +storing them into an address passed by the caller (usually in a +register). The machine-description macros @code{STRUCT_VALUE} and +@code{STRUCT_INCOMING_VALUE} tell GNU CC where to pass this address. + +By contrast, PCC on most target machines returns structures and unions +of any size by copying the data into an area of static storage, and then +returning the address of that storage as if it were a pointer value. +The caller must copy the data from that memory area to the place where +the value is wanted. This is slower than the method used by GNU CC, and +fails to be reentrant. + +On some target machines, such as RISC machines and the 80386, the +standard system convention is to pass to the subroutine the address of +where to return the value. On these machines, GNU CC has been +configured to be compatible with the standard compiler, when this method +is used. It may not be compatible for structures of 1, 2, 4 or 8 bytes. + +GNU CC uses the system's standard convention for passing arguments. On +some machines, the first few arguments are passed in registers; in +others, all are passed on the stack. It would be possible to use +registers for argument passing on any machine, and this would probably +result in a significant speedup. But the result would be complete +incompatibility with code that follows the standard convention. So this +change is practical only if you are switching to GNU CC as the sole C +compiler for the system. We may implement register argument passing on +certain machines once we have a complete GNU system so that we can +compile the libraries with GNU CC. If you use @code{longjmp}, beware of automatic variables. ANSI C says that automatic variables that are not declared @code{volatile} have undefined @@ -2427,13 +2532,26 @@ go in a register: @} @end example -Code compiled with GNU CC may call certain library routines. The routines -needed on the Vax and 68000 are in the file @file{gnulib.c}. You must -compile this file with the standard C compiler, not with GNU CC, and then -link it with each program you compile with GNU CC. (In actuality, many -programs will not need it.) The usual function call interface is used -for calling the library routines. Some standard parts of the C library, -such as @code{bcopy}, are also called automatically. +Code compiled with GNU CC may call certain library routines. Most of +them handle arithmetic for which there are no instructions. This +includes multiply and divide on some machines, and floating point +operations on any machine for which floating point support is disabled +with @samp{-msoft-float}. Some standard parts of the C library, such as +@code{bcopy} or @code{memcpy}, are also called automatically. The usual +function call interface is used for calling the library routines. + +These library routines should be defined in the library @file{gnulib}, +which GNU CC automatically searches whenever it links a program. On +machines that have multiply and divide instructions, if hardware +floating point is in use, normally @file{gnulib} is not needed, but it +is searched just in case. + +Each arithmetic function is defined in @file{gnulib.c} to use the +corresponding C arithmetic operator. As long as the file is compiled +with another C compiler, which supports all the C arithmetic operators, +this file will work portably. However, @file{gnulib.c} does not work if +compiled with GNU CC, because each arithmetic function would compile +into a call to itself! @node Passes, RTL, Interface, Top @chapter Passes and Files of the Compiler @@ -2482,12 +2600,12 @@ represented as declaration nodes. Constant folding and associative-law simplifications are also done during this pass. -The source files for parsing are @file{parse.y}, @file{decl.c}, -@file{typecheck.c}, @file{stor-layout.c}, @file{fold-const.c}, and -@file{tree.c}. The last three are intended to be language-independent. -There are also header files @file{parse.h}, @file{c-tree.h}, -@file{tree.h} and @file{tree.def}. The last two define the format of -the tree representation.@refill +The source files for parsing are @file{c-parse.y}, @file{c-decl.c}, +@file{c-typeck.c}, @file{c-convert.c}, @file{stor-layout.c}, +@file{fold-const.c}, and @file{tree.c}. The last three files are +intended to be language-independent. There are also header files +@file{c-parse.h}, @file{c-tree.h}, @file{tree.h} and @file{tree.def}. +The last two define the format of the tree representation.@refill @item RTL generation. This is the conversion of syntax tree into RTL code. @@ -3201,6 +3319,11 @@ The compilation parameter @code{WORDS_BI that word number zero is the most significant part; otherwise, it is the least significant part. +Between the combiner pass and the reload pass, it is possible to have +a @samp{subreg} which contains a @samp{mem} instead of a @samp{reg} as +its first operand. The reload pass eliminates these cases by +reloading the @samp{mem} into a suitable register. + Note that it is not valid to access a @code{DFmode} value in @code{SFmode} using a @samp{subreg}. On some machines the most significant part of a @code{DFmode} value does not have the same format as a single-precision @@ -3622,8 +3745,10 @@ used. @item (call @var{function} @var{nargs}) Represents a function call. @var{function} is a @samp{mem} expression -whose address is the address of the function to be called. @var{nargs} -is an expression representing the number of words of argument. +whose address is the address of the function to be called. +@var{nargs} is an expression which can be used for two purposes: on +some machines it represents the number of bytes of stack argument; on +others, it represents the number of argument registers. Each machine has a standard machine mode which @var{function} must have. The machine description defines macro @code{FUNCTION_MODE} to @@ -3682,6 +3807,15 @@ location addressed by it are interchange @code{(reg:SI 1)} appears as a memory address it refers to the value in register 1 @emph{before} the execution of the instruction. +Peephole optimization, which takes place in the last jump-optimization +pass, can produce insns whose patterns consist of a @samp{parallel} +whose elements are the operands needed to output the resulting +assembler code--often @samp{reg}, @samp{mem} or constant expressions. +This would not be well-formed RTL at any other stage in compilation, +but it is ok then because no further optimization remains to be done. +However, the definition of the macro @code{NOTICE_UPDATE_CC} may need +to deal with such insns. + @item (sequence [@var{insns} @dots{}]) Represents a sequence of insns. Each of the @var{insns} that appears in the vector is suitable for appearing in the chain of insns, so it @@ -4305,8 +4439,9 @@ pattern will not match at all. Operand numbers must be chosen consecutively counting from zero in each instruction pattern. There may be only one @samp{match_operand} -expression in the pattern for each expression number, and they must -appear in order of increasing expression number. +expression in the pattern for each operand number. Usually operands +are numbered in the order of appearance in @samp{match_operand} +expressions. @var{testfn} is a string that is the name of a C function that accepts two arguments, a machine mode and an expression. During matching, @@ -4522,6 +4657,20 @@ operand, the constraint letter @samp{o} by both @samp{<} (if the target machine has predecrement addressing) and @samp{>} (if the target machine has preincrement addressing). +When the constraint letter @samp{o} is used, the reload pass may +generate instructions which copy a nonoffsetable address into an index +register. The idea is that the register can be used as a replacement +offsetable address. But this method requires that there be patterns +to copy any kind of address into a register. Auto-increment +and auto-decrement addresses are an exception; there need not be an +instruction that can copy such an address into a register, because +reload handles these cases specially. + +Most older machine designs have ``load address'' instructions which do +just what is needed here. Some RISC machines do not advertise such +instructions, but the possible addresses on these machines are very +limited, so it is easy to fake them. + @item @samp{<} A memory operand with autodecrement addressing (either predecrement or postdecrement) is allowed. @@ -4680,16 +4829,51 @@ results might look like this: @dots{}) @end example -Because insns that don't fit the constraints are fixed up by loading -operands into registers, every instruction pattern's constraints must -permit the case where all the operands are in registers. It need not -permit all classes of registers; the compiler knows how to copy registers -into other registers of the proper class in order to make an instruction -valid. But if no registers are permitted, the compiler will be stymied: it -does not know how to save a register in memory in order to make an -instruction valid. Instruction patterns that reject registers can be -made valid by attaching a condition-expression that refuses to match -an insn at all if the crucial operand is a register. +It is up to you to make sure that each operand, in each pattern, has +constraints that can handle any RTL expression that could be present for +that operand. (When multiple alternatives are in use, each pattern must, +for each possible combination of operand expressions, have at least one +alternative which can handle that combination of operands.) The +constraints don't need to @emph{allow} any possible operand---when this is +the case, they do not constrain---but they must at least point the way to +reloading any possible operand so that it will fit. + +@itemize @bullet +@item +If the constraint accepts whatever operands the predicate permits, +there is no problem: reloading is never necessary for this operand. + +For example, an operand whose constraints permit everything except +registers is safe provided its predicate rejects registers. + +An operand whose predicate accepts only constant values is safe +provided its constraints include the letter @samp{i}. If any possible +constant value is accepted, then nothing less than @samp{i} will do; +if the predicate is more selective, than the constraints may also be +more selective. + +@item +Any operand expression can be reloaded by copying it into a register. +So if an operand's constraints allow some kind of register, it is +certain to be safe. It need not permit all classes of registers; the +compiler knows how to copy a register into another register of the +proper class in order to make an instruction valid. + +@item +A nonoffsetable memory reference can be reloaded by copying the +address into a register. So if the constraint uses the letter +@samp{o}, all memory references are taken care of. + +@item +A constant operand can be reloaded by storing it in memory; it then +becomes an offsetable memory reference. So if the constraint uses the +letters @samp{o} or @samp{m}, constant operands are not a problem. +@end itemize + +If the operand's predicate can recognize registers, but the constraint does +not permit them, it can make the compiler crash. When this operand happens +to be a register, the reload pass will be stymied, because it does not know +how to copy a register temporarily into memory. @node Multi-Alternative, Class Preferences, Simple Constraints, Constraints @subsection Multiple Alternative Constraints @@ -4921,6 +5105,10 @@ machine description, but typically on a pseudo registers that did not get hard registers, while on other machines explicit memory references will get optional reloads. +In addition, the constraints must allow any hard register to be moved +to any other hard register (provided that @code{HARD_REGNO_MODE_OK} +permits mode @var{m} in each of the registers). + @item @samp{movstrict@var{m}} Like @samp{mov@var{m}} except that if operand 0 is a @samp{subreg} with mode @var{m} of a register whose natural mode is wider, @@ -4935,6 +5123,12 @@ means of constraints requiring operands @item @samp{sub@var{m}3}, @samp{mul@var{m}3}, @samp{umul@var{m}3}, @samp{div@var{m}3}, @samp{udiv@var{m}3}, @samp{mod@var{m}3}, @samp{umod@var{m}3}, @samp{and@var{m}3}, @samp{ior@var{m}3}, @samp{xor@var{m}3} Similar, for other arithmetic operations. +There are special considerations for register classes for logical-and +instructions, affecting also the macro @code{PREFERRED_RELOAD_CLASS}. +They apply not only to the patterns with these standard names, but to +any patterns that will match such an instruction. @xref{Register +Classes}. + @item @samp{andcb@var{m}3} Bitwise logical-and operand 1 with the complement of operand 2 and store the result in operand 0. @@ -4980,6 +5174,12 @@ allow negative shift counts often have o shifting left. On such machines, you should define a pattern named @samp{ashl@var{m}3} and leave @samp{lshl@var{m}3} undefined. +There are special considerations for register classes for shift +instructions, affecting also the macro @code{PREFERRED_RELOAD_CLASS}. +They apply not only to the patterns with these standard names, but to +any patterns that will match such an instruction. @xref{Register +Classes}. + @item @samp{neg@var{m}2} Negate operand 1 and store the result in operand 0. @@ -5124,10 +5324,27 @@ that refers to the label to jump to. Ju meet condition @var{cond}. @item @samp{call} -Subroutine call instruction. Operand 1 is the number of bytes of -arguments pushed (in mode @code{SImode}), and operand 0 is the -function to call. Operand 0 should be a @samp{mem} RTX whose address -is the address of the function. +Subroutine call instruction returning no value. Operand 0 is the +function to call; operand 1 is the number of bytes of arguments pushed +(in mode @code{SImode}, except it is normally a @samp{const_int}); +operand 2 is the number of registers used as operands. + +On most machines, operand 2 is not actually stored into the RTL +pattern. It is supplied for the sake of some RISC machines which need +to put this information into the assembler code; they can put it in +the RTL instead of operand 1. + +Operand 0 should be a @samp{mem} RTX whose address is the address of +the function. + +@item @samp{call_value} +Subroutine call instruction returning a value. Operand 0 is the hard +register in which the value is returned. There are three more +operands, the same as the three operands of the @samp{call} +instruction (but with numbers increased by one). + +Subroutines that return @code{BLKmode} objects use the @samp{call} +insn. @item @samp{return} Subroutine return instruction. This instruction pattern name should be @@ -5328,6 +5545,22 @@ Such instructions to extend constants ar optimized away, but they do occasionally happen in nonoptimized compilations. +When an instruction has the constraint letter @samp{o}, the reload +pass may generate instructions which copy a nonoffsetable address into +an index register. The idea is that the register can be used as a +replacement offsetable address. In order for these generated +instructions to work, there must be patterns to copy any kind of valid +address into a register. + +Most older machine designs have ``load address'' instructions which do +just what is needed here. Some RISC machines do not advertise such +instructions, but the possible addresses on these machines are very +limited, so it is easy to fake them. + +Auto-increment and auto-decrement addresses are an exception; there +need not be an instruction that can copy such an address into a +register, because reload handles these cases in a different manner. + @node Jump Patterns, Peephole Definitions, Dependent Patterns, Machine Desc @section Defining Jump Instruction Patterns @@ -5687,8 +5920,10 @@ compiler source files include @file{conf @table @code @item CPP_PREDEFINES -Define this to be a string constant containing @samp{-D} options -to define the predefined macros that identify this machine and system. +Define this to be a string constant containing @samp{-D} options to +define the predefined macros that identify this machine and system. +These macros will be predefined unless the @samp{-ansi} option is +specified. For example, on the Sun, one can use the value @@ -5696,6 +5931,20 @@ For example, on the Sun, one can use the "-Dmc68000 -Dsun -Dunix" @end example +@item 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. + +@item 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. + @item extern int target_flags; This declaration should be present. @@ -5745,12 +5994,14 @@ with opposite meanings, and picks the la @{ "68000", -1@}, \ @{ "", 1@}@} @end example -@end table -Sometimes certain combinations of command options do not make sense on a -particular target machine. You can define a macro @code{OVERRIDE_OPTIONS} -to take account of this. This macro, if defined, is executed once -just after all the command options have been parsed. +@item OVERRIDE_OPTIONS +Sometimes certain combinations of command options do not make sense on +a particular target machine. You can define a macro +@code{OVERRIDE_OPTIONS} to take account of this. This macro, if +defined, is executed once just after all the command options have been +parsed. +@end table @node Storage Layout, Registers, Run-time Target, Machine Macros @section Storage Layout @@ -5787,6 +6038,9 @@ Number of storage units in a word; norma @item POINTER_SIZE Width of a pointer, in bits. +@item POINTER_BOUNDARY +Alignment required for pointers stored in memory, in bits. + @item PARM_BOUNDARY Alignment required for function parameters on the stack, in bits. @@ -5801,7 +6055,7 @@ Alignment required for a function entry @item BIGGEST_ALIGNMENT Biggest alignment that any data type can require on this machine, in bits. -@item EMPTY_FIELD_ALIGNMENT +@item EMPTY_FIELD_BOUNDARY Alignment in bits to be given to a structure bit field that follows an empty field such as @code{int : 0;}. @@ -5857,9 +6111,10 @@ pseudo register's number really is assig 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, the program counter on machines where that is considered one -of the addressable registers, and any other numbered register with a -standard use. +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 @var{n}th number is 1 if @@ -5892,6 +6147,18 @@ 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 +@code{fixed_regs} and @code{call_used_regs} to 1 for each of the +registers in the classes which should not be used by gcc. Also define +the macro @code{REG_CLASS_FROM_LETTER} to return @code{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 @code{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.) + @item OVERLAPPING_REGNO_P (@var{regno}) If defined, this is a C expression whose value is @var{regno} is nonzero if hard register number @var{regno} is an overlapping @@ -6047,7 +6314,7 @@ The register number used for passing a f 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. +does not provide this feature, but you must define the macro. The static chain register need not be a fixed register. @@ -6138,6 +6405,16 @@ classes: for each class, which classes c contained in it; for each pair of classes, the largest class contained in their union. +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 (@code{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 +@code{PREFERRED_RELOAD_CLASS} can always have a possible value to return. + @table @code @item enum reg_class An enumeral type that must be defined with all the register class names @@ -6150,6 +6427,13 @@ Each register class has a number, which the class name to type @code{int}. The number serves as an index in many of the tables described below. +@item N_REG_CLASSES +The number of distinct register classes, defined as follows: + +@example +#define N_REG_CLASSES (int) LIM_REG_CLASSES +@end example + @item 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. @@ -6171,15 +6455,22 @@ A C expression whose value is a register which is @dfn{minimal}, meaning that no smaller class also contains the register. +@item BASE_REG_CLASS +A macro whose definition is the name of the class to which a valid +base register must belong. A base register is one used in an address +which is the register value plus a displacement. + @item INDEX_REG_CLASS -A macro whose definition is the name of the class to which a valid index -register must belong. +A macro whose definition is the name of the class to which a valid +index register must belong. An index register is one used in an +address where its value is either multiplied by a scale factor or +added to another register (as well as added to a displacement). @item REG_CLASS_FROM_LETTER (@var{char}) A C expression which defines the machine-dependent operand constraint -letters for register classes. If @var{char} is such a letter, the value -should be the register class corresponding to it. Otherwise, the value -should be @code{NO_REGS}. +letters for register classes. If @var{char} is such a letter, the +value should be the register class corresponding to it. Otherwise, +the value should be @code{NO_REGS}. @item REGNO_OK_FOR_BASE_P (@var{num}) A C expression which is nonzero if register number @var{num} is @@ -6199,33 +6490,50 @@ two registers, neither one of them scale labeled the ``base'' and the other the ``index''; but whichever labeling is used must fit the machine's constraints of which registers may serve in each capacity. The compiler will try both labelings, -looking for one that is valid, and reload one or both registers only -if neither labeling works. +looking for one that is valid, and will reload one or both registers +only if neither labeling works. @item PREFERRED_RELOAD_CLASS (@var{x}, @var{class}) A C expression that places additional restrictions on the register class to use when it is necessary to copy value @var{x} into a register in class @var{class}. The value is a register class; perhaps @var{class}, or perhaps -another, smaller class. @var{class} is always safe as a value. In fact, -the definition +another, smaller class. On many machines, the definition @example #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS @end example @noindent -is always safe. However, sometimes returning a more restrictive class -makes better code. For example, on the 68000, when @var{x} is an -integer constant that is in range for a @samp{moveq} instruction, -the value of this macro is always @code{DATA_REGS} as long as -@var{class} includes the data registers. Requiring a data register -guarantees that a @samp{moveq} will be used. +is safe. + +Sometimes returning a more restrictive class makes better code. For +example, on the 68000, when @var{x} is an integer constant that is in range +for a @samp{moveq} instruction, the value of this macro is always +@code{DATA_REGS} as long as @var{class} includes the data registers. +Requiring a data register guarantees that a @samp{moveq} will be used. If @var{x} is a @samp{const_double}, by returning @code{NO_REGS} you can force @var{x} into a memory constant. This is useful on certain machines where immediate floating values cannot be loaded into certain kinds of registers. +In a shift instruction or a bitwise-and instruction, the mode of @var{x}, +the value being reloaded, may not be the same as the mode of the +instruction's operand. (They will both be fixed-point modes, however.) In +such a case, @var{class} may not be a safe value to return. @var{class} is +certainly valid for the instruction, but it may not be valid for reloading +@var{x}. This problem can occur on machines such as the 68000 and 80386 +where some registers can handle full-word values but cannot handle +single-byte values. + +On such machines, this macro must examine the mode of @var{x} and return a +subclass of @var{class} which can handle loads and stores of that mode. On +the 68000, where address registers cannot handle @code{QImode}, if @var{x} +has @code{QImode} then you must return @code{DATA_REGS}. If @var{class} is +@code{ADDR_REGS}, then there is no correct value to return; but the shift +and bitwise-and instructions don't use @code{ADDR_REGS}, so this fatal case +never arises. + @item CLASS_MAX_NREGS (@var{class}, @var{mode}) A C expression for the maximum number of consecutive registers of class @var{class} needed to hold a value of mode @var{mode}. @@ -6307,8 +6615,23 @@ alignment. Then the definition should b #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1) @end example -@item FIRST_PARM_OFFSET -Offset from the argument pointer register to the first argument's address. +@item FIRST_PARM_OFFSET (@var{fundecl}) +Offset from the argument pointer register to the first argument's +address. On some machines it may depend on the data type of the +function. (In the next version of GNU CC, the argument will be +changed to the function data type rather than its declaration.) + +@item FIRST_PARM_CALLER_OFFSET (@var{fundecl}) +Define this macro on machines where register parameters have shadow +locations on the stack, at addresses below the nominal parameter. +This matters because certain arguments cannot be passed on the stack. +On these machines, such arguments must be stored into the shadow +locations. + +This macro should expand into a C expression whose value is the offset +of the first parameter's shadow location from the nominal stack +pointer value. (That value is itself computed by adding the value of +@code{STACK_POINTER_OFFSET} to the stack pointer register.) @item RETURN_POPS_ARGS (@var{funtype}) A C expression that should be 1 if a function pops its own arguments @@ -6454,10 +6777,12 @@ of @code{FUNCTION_ARG} and other related machines, the type @code{int} suffices and can hold the number of bytes of argument so far. -@item INIT_CUMULATIVE_ARGS (@var{cum}) +@item INIT_CUMULATIVE_ARGS (@var{cum}, @var{fntype}) A C statement (sans semicolon) for initializing the variable @var{cum} for the state at the beginning of the argument list. The variable has -type @code{CUMULATIVE_ARGS}. +type @code{CUMULATIVE_ARGS}. The value of @var{fntype} is the tree node +for the data type of the function which will receive the args, or 0 +if the args are to a compiler support library function. @item FUNCTION_ARG_ADVANCE (@var{cum}, @var{mode}, @var{type}, @var{named}) Update the summarizer variable @var{cum} to advance past an argument @@ -6556,6 +6881,13 @@ of returning from the function. On thes instruction the name @samp{return} and do not define the macro @code{FUNCTION_EPILOGUE} at all. +Do not define a pattern named @samp{return} if you want the +@code{FUNCTION_EPILOGUE} to be used. If you want the target switches +to control whether return instructions or epilogues are used, define a +@samp{return} pattern with a validity condition that tests the target +switches appropriately. If the @samp{return} pattern's validity +condition is false, epilogues will be used. + On machines where functions may or may not have frame-pointers, the function exit code must vary accordingly. Sometimes the code for these two cases is completely different. To determine whether a frame @@ -6673,6 +7005,28 @@ for index registers, and so on). Then o need have two variants; the higher levels of macros may be the same whether strict or not.@refill +@item REG_OK_FOR_BASE_P (@var{x}) +A C expression that is nonzero if @var{x} (asumed to be a @code{reg} +RTX) is valid for use as a base register. For hard registers, it +should always accept those which the hardware permits and reject the +others. Whether the macro accepts or rejects pseudo registers must be +controlled by @code{REG_OK_STRICT} as described above. This usually +requires two variant definitions, of which @code{REG_OK_STRICT} +controls the one actually used. + +@item REG_OK_FOR_INDEX_P (@var{x}) +A C expression that is nonzero if @var{x} (asumed to be a @code{reg} +RTX) is valid for use as an index register. + +The difference between an index register and a base register is that +the index register may be scaled. If an address involves the sum of +two registers, neither one of them scaled, then either one may be +labeled the ``base'' and the other the ``index''; but whichever +labeling is used must fit the machine's constraints of which registers +may serve in each capacity. The compiler will try both labelings, +looking for one that is valid, and will reload one or both registers +only if neither labeling works. + @item LEGITIMIZE_ADDRESS (@var{x}, @var{oldx}, @var{mode}, @var{win}) A C compound statement that attempts to replace @var{x} with a valid memory address for an operand of mode @var{mode}. @var{win} will be a @@ -6841,7 +7195,7 @@ An alias for the machine mode used for m being called, in @samp{call} RTL expressions. On most machines this should be @code{QImode}. -@item CONST_COST (@var{x}, @var{code}) +@item CONST_COSTS (@var{x}, @var{code}) A part of a C @code{switch} statement that describes the relative costs of constant RTL expressions. It must contain @code{case} labels for expression codes @samp{const_int}, @samp{const}, @samp{symbol_ref}, @samp{label_ref} @@ -6901,6 +7255,14 @@ this, it will no longer be true that it @samp{a4@@(102)}. Therefore, @code{NOTICE_UPDATE_CC} must alter @code{cc_status} in this case to say that nothing is known about the condition code value. + +The definition of @code{NOTICE_UPDATE_CC} must be prepared to deal +with the results of peephole optimization: insns whose patterns are +@samp{parallel} RTXs containing various @samp{reg}, @samp{mem} or +constants which are just the operands. The RTL structure of these +insns is not sufficient to indicate what the insns actually do. What +@code{NOTICE_UPDATE_CC} should do when it sees one is just to run +@code{CC_STATUS_INIT}. @end table @node Assembler Format,, Condition Code, Machine Macros @@ -6922,6 +7284,22 @@ give to GNU CC into options for GNU CC t Do not define this macro if it does not need to do anything. +@item LIB_SPEC +Another C string constant used much like @code{LINK_SPEC}. The difference +between the two is that @code{LIBS_SPEC} is used at the end of the +command given to the linker. + +If this macro is not defined, a default is provided that +loads the standard C library from the usual place. See @file{gcc.c}. + +@item STARTFILE_SPEC +Another C string constant used much like @code{LINK_SPEC}. The +difference between the two is that @code{STARTFILE_SPEC} is used at +the very beginning of the command given to the linker. + +If this macro is not defined, a default is provided that loads the +standard C startup file from the usual place. See @file{gcc.c}. + @item ASM_FILE_START (@var{stream}) A C expression which outputs to the stdio stream @var{stream} some appropriate text to go at the start of an assembler file. @@ -7017,11 +7395,13 @@ the expression @code{assemble_name (@var the name itself; before and after that, output the additional assembler syntax for defining the name, and a newline. -@item ASM_DECLARE_FUNCTION_NAME (@var{stream}, @var{name}) +@item ASM_DECLARE_FUNCTION_NAME (@var{stream}, @var{name}, @var{decl}) A C statement (sans semicolon) to output to the stdio stream -@var{stream} any text necessary for declaring the name of a function -which is being defined. This macro is responsible for outputting -the label definition (perhaps using @code{ASM_OUTPUT_LABEL}). +@var{stream} any text necessary for declaring the name @var{name} of a +function which is being defined. This macro is responsible for +outputting the label definition (perhaps using +@code{ASM_OUTPUT_LABEL}). The argument @var{decl} is the +@code{FUNCTION_DECL} tree node representing the function. If this macro is not defined, then the function name is defined in the usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}). @@ -7034,10 +7414,12 @@ that is, available for reference from ot itself; before and after that, output the additional assembler syntax for making that name global, and a newline. -@item ASM_OUTPUT_EXTERNAL (@var{stream}, @var{name}) +@item ASM_OUTPUT_EXTERNAL (@var{stream}, @var{name}, @var{decl}) A C statement (sans semicolon) to output to the stdio stream @var{stream} any text necessary for declaring the name of an external -symbol which is referenced in this compilation but not defined. +symbol named @var{name} which is referenced in this compilation but +not defined. The value of @var{decl} is the tree node for the +declaration. This macro need not be defined if it does not need to output anything. The GNU assembler and most Unix assemblers don't require anything. @@ -7049,6 +7431,14 @@ should be added to the front of the name operating system, as it is in most Berkeley Unix systems. This macro is used in @code{assemble_name}. +@item ASM_GENERATE_INTERNAL_LABEL (@var{string}, @var{prefix}, @var{num}) +A C statement to store into the string @var{string} a label whose +name is made from the string @var{prefix} and the number @var{num}. + +This string, when output subsequently by @code{ASM_OUTPUT_LABELREF}, +should produce the same output that @code{ASM_OUTPUT_INTERNAL_LABEL} +would produce with the same @var{prefix} and @var{num}. + @item ASM_OUTPUT_INTERNAL_LABEL (@var{stream}, @var{prefix}, @var{num}) A C statement to output to the stdio stream @var{stream} a label whose name is made from the string @var{prefix} and the number @var{num}.