📄 tm.texi
字号:
@findex OVERLAPPING_REGNO_P @item OVERLAPPING_REGNO_P (@var{regno})If defined, this is a C expression whose value is nonzero if hardregister number @var{regno} is an overlapping register. This means ahard register which overlaps a hard register with a different number.(Such overlap is undesirable, but occasionally it allows a machine tobe supported which otherwise could not be.) This macro must returnnonzero for @emph{all} the registers which overlap each other. GNU CCcan use an overlapping register only in certain limited ways. It canbe used for allocation within a basic block, and may be spilled forreloading; that is all.If this macro is not defined, it means that none of the hard registersoverlap each other. This is the usual situation.@findex INSN_CLOBBERS_REGNO_P@item INSN_CLOBBERS_REGNO_P (@var{insn}, @var{regno})If defined, this is a C expression whose value should be nonzero ifthe insn @var{insn} has the effect of mysteriously clobbering thecontents of hard register number @var{regno}. By ``mysterious'' wemean that the insn's RTL expression doesn't describe such an effect.If this macro is not defined, it means that no insn clobbers registersmysteriously. This is the usual situation; all else being equal,it is best for the RTL expression to show all the activity.@cindex death notes@findex PRESERVE_DEATH_INFO_REGNO_P@item PRESERVE_DEATH_INFO_REGNO_P (@var{regno})If defined, this is a C expression whose value is nonzero if accurate@code{REG_DEAD} notes are needed for hard register number @var{regno}at the time of outputting the assembler code. When this is so, a fewoptimizations that take place after register allocation and couldinvalidate the death notes are not done when this register isinvolved.You would arrange to preserve death info for a register when some of thecode in the machine description which is executed to write the assemblercode looks at the death notes. This is necessary only when the actualhardware feature which GNU CC thinks of as a register is not actually aregister of the usual sort. (It might, for example, be a hardwarestack.)If this macro is not defined, it means that no death notes need to bepreserved. This is the usual situation.@end table@node Register Classes@section Register Classes@cindex register class definitions@cindex class definitions, registerOn 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 machinerestrictions are described to the compiler using @dfn{register classes}.You define a number of register classes, giving each one a name and sayingwhich of the registers belong to it. Then you can specify register classesthat are allowed as operands to particular instruction patterns.@findex ALL_REGS@findex NO_REGSIn general, each register will belong to several classes. In fact, oneclass must be named @code{ALL_REGS} and contain all the registers. Anotherclass must be named @code{NO_REGS} and contain no registers. Often theunion of two classes will be another class; however, this is not required.@findex GENERAL_REGSOne of the classes must be named @code{GENERAL_REGS}. There is nothingterribly special about the name, but the operand constraint letters@samp{r} and @samp{g} specify this class. If @code{GENERAL_REGS} isthe same as @code{ALL_REGS}, just define it as a macro which expandsto @code{ALL_REGS}.Order the classes so that if class @var{x} is contained in class @var{y}then @var{x} has a lower class number than @var{y}.The way classes other than @code{GENERAL_REGS} are specified in operandconstraints is through machine-dependent operand constraint letters.You can define such letters to correspond to various classes, then usethem in operand constraints.You should define a class for the union of two classes whenever someinstruction allows both classes. For example, if an instruction allowseither a floating point (coprocessor) register or a general register for acertain operand, you should define a class @code{FLOAT_OR_GENERAL_REGS}which includes both of them. Otherwise you will get suboptimal code.You must also specify certain redundant information about the registerclasses: for each class, which classes contain it and which ones arecontained in it; for each pair of classes, the largest class containedin their union.When a value occupying several consecutive registers is expected in acertain class, all the registers used must belong to that class.Therefore, register classes cannot be used to enforce a requirement fora register pair to start with an even-numbered register. The way tospecify this requirement is with @code{HARD_REGNO_MODE_OK}.Register classes used for input-operands of bitwise-and or shiftinstructions have a special requirement: each such class must have, foreach fixed-point machine mode, a subclass whose registers can transfer thatmode to or from memory. For example, on some machines, the operations forsingle-byte values (@code{QImode}) are limited to certain registers. Whenthis is so, each register class that is used in a bitwise-and or shiftinstruction must have a subclass consisting of registers from whichsingle-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@findex enum reg_class@item enum reg_classAn enumeral type that must be defined with all the register class namesas enumeral values. @code{NO_REGS} must be first. @code{ALL_REGS}must be the last register class, followed by one more enumeral value,@code{LIM_REG_CLASSES}, which is not a register class but rathertells how many classes there are.Each register class has a number, which is the value of castingthe class name to type @code{int}. The number serves as an indexin many of the tables described below.@findex N_REG_CLASSES@item N_REG_CLASSESThe number of distinct register classes, defined as follows:@example#define N_REG_CLASSES (int) LIM_REG_CLASSES@end example@findex REG_CLASS_NAMES@item REG_CLASS_NAMESAn initializer containing the names of the register classes as C stringconstants. These names are used in writing some of the debugging dumps.@findex REG_CLASS_CONTENTS@item REG_CLASS_CONTENTSAn initializer containing the contents of the register classes, as integerswhich are bit masks. The @var{n}th integer specifies the contents of class@var{n}. The way the integer @var{mask} is interpreted is thatregister @var{r} is in the class if @code{@var{mask} & (1 << @var{r})} is 1.When the machine has more than 32 registers, an integer does not suffice.Then the integers are replaced by sub-initializers, braced groupings containingseveral integers. Each sub-initializer must be suitable as an initializerfor the type @code{HARD_REG_SET} which is defined in @file{hard-reg-set.h}.@findex REGNO_REG_CLASS @item REGNO_REG_CLASS (@var{regno})A C expression whose value is a register class containing hard register@var{regno}. In general there is more than one such class; choose a classwhich is @dfn{minimal}, meaning that no smaller class also contains theregister.@findex BASE_REG_CLASS@item BASE_REG_CLASSA macro whose definition is the name of the class to which a validbase register must belong. A base register is one used in an addresswhich is the register value plus a displacement.@findex INDEX_REG_CLASS@item INDEX_REG_CLASSA macro whose definition is the name of the class to which a validindex register must belong. An index register is one used in anaddress where its value is either multiplied by a scale factor oradded to another register (as well as added to a displacement).@findex REG_CLASS_FROM_LETTER@item REG_CLASS_FROM_LETTER (@var{char})A C expression which defines the machine-dependent operand constraintletters for register classes. If @var{char} is such a letter, thevalue should be the register class corresponding to it. Otherwise,the value should be @code{NO_REGS}. The register letter @samp{r},corresponding to class @code{GENERAL_REGS}, will not be passedto this macro; you do not need to handle it.@findex REGNO_OK_FOR_BASE_P@item REGNO_OK_FOR_BASE_P (@var{num})A C expression which is nonzero if register number @var{num} issuitable for use as a base register in operand addresses. It may beeither a suitable hard register or a pseudo register that has beenallocated such a hard register.@findex REGNO_OK_FOR_INDEX_P@item REGNO_OK_FOR_INDEX_P (@var{num})A C expression which is nonzero if register number @var{num} issuitable for use as an index register in operand addresses. It may beeither a suitable hard register or a pseudo register that has beenallocated such a hard register.The difference between an index register and a base register is thatthe index register may be scaled. If an address involves the sum oftwo registers, neither one of them scaled, then either one may belabeled the ``base'' and the other the ``index''; but whicheverlabeling is used must fit the machine's constraints of which registersmay serve in each capacity. The compiler will try both labelings,looking for one that is valid, and will reload one or both registersonly if neither labeling works.@findex PREFERRED_RELOAD_CLASS@item PREFERRED_RELOAD_CLASS (@var{x}, @var{class})A C expression that places additional restrictions on the register classto 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 perhapsanother, smaller class. On many machines, the definition@example#define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS@end example@noindentis safe.Sometimes returning a more restrictive class makes better code. Forexample, on the 68000, when @var{x} is an integer constant that is in rangefor 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 @code{const_double}, by returning @code{NO_REGS}you can force @var{x} into a memory constant. This is useful oncertain machines where immediate floating values cannot be loaded intocertain kinds of registers.@findex PREFERRED_OUTPUT_RELOAD_CLASS@item PREFERRED_OUTPUT_RELOAD_CLASS (@var{x}, @var{class})Like @code{PREFERRED_RELOAD_CLASS}, but for output reloads instead ofinput reloads. If you don't define this macro, the default is to use@var{class}, unchanged.@findex LIMIT_RELOAD_CLASS@item LIMIT_RELOAD_CLASS (@var{mode}, @var{class})A C expression that places additional restrictions on the register classto use when it is necessary to be able to hold a value of mode@var{mode} in a reload register for which class @var{class} wouldordinarily be used.Unlike @code{PREFERRED_RELOAD_CLASS}, this macro should be used whenthere are certain modes that simply can't go in certain reload classes.The value is a register class; perhaps @var{class}, or perhaps another,smaller class.Don't define this macro unless the target machine has limitations whichrequire the macro to do something nontrivial.@findex SECONDARY_RELOAD_CLASS@findex SECONDARY_INPUT_RELOAD_CLASS@findex SECONDARY_OUTPUT_RELOAD_CLASS@item SECONDARY_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})@itemx SECONDARY_INPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})@itemx SECONDARY_OUTPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})Many machines have some registers that cannot be copied directly to orfrom memory or even from other types of registers. An example is the@samp{MQ} register, which on most machines, can only be copied to orfrom general registers, but not memory. Some machines allow copying allregisters to and from memory, but require a scratch register for storesto some memory locations (e.g., those with symbolic address on the RT,and those with certain symbolic address on the Sparc when compilingPIC). In some cases, both an intermediate and a scratch register arerequired.You should define these macros to indicate to the reload phase that it mayneed to allocate at least one register for a reload in addition to theregister to contain the data. Specifically, if copying @var{x} to aregister @var{class} in @var{mode} requires an intermediate register,you should define @code{SECONDARY_INPUT_RELOAD_CLASS} to return thelargest register class all of whose registers can be used asintermediate registers or scratch registers.If copying a register @var{class} in @var{mode} to @var{x} requires anintermediate or scratch register, you should define@code{SECONDARY_OUTPUT_RELOAD_CLASS} to return the largest registerclass required. If the requirements for input and output reloads arethe same, the macro @code{SECONDARY_RELOAD_CLASS} should be used insteadof defining both macros identically.The values returned by these macros are often @code{GENERAL_REGS}.Return @code{NO_REGS} if no spare register is needed; i.e., if @var{x}can be directly copied to or from a register of @var{class} in@var{mode} without requiring a scratch register. Do not define thismacro if it would always return @code{NO_REGS}.If a scratch register is required (either with or without anintermediate register), you should define patterns for@samp{reload_in@var{m}} or @samp{reload_out@var{m}}, as required(@pxref{Standard Names}. These patterns, which will normally beimplemented with a @code{define_expand}, should be similar to the@samp{mov@var{m}} patterns, except that operand 2 is the scratchregister. Define constraints for the reload register and scratch register thatcontain a single register class. If the original reload register (whoseclass is @var{class}) can meet the constraint given in the pattern, thevalue returned by these macros is used for the class of the scratchregister. Otherwise, two additional reload registers are required.Their classes are obtained from the constraints in the insn pattern.@var{x} might be a pseudo-register or a @code{subreg} of apseudo-register, which could either be in a hard register or in memory.Use @code{true_regnum} to find out; it will return -1 if the pseudo isin memory and the hard register number if it is in a register.These macros should not be used in the case where a particular class ofregisters can only be copied to memory and not to another class ofregisters. In that case, secondary reload registers are not needed andwould not be helpful. Instead, a stack location must be used to performthe copy and the @code{mov@var{m}} pattern should use memory as aintermediate storage. This case often occurs between floating-point andgeneral registers.@findex SECONDARY_MEMORY_NEEDED@item SECONDARY_MEMORY_NEEDED (@var{class1}, @var{class2}, @var{m})Certain machines have the property that some registers cannot be copiedto some other registers without using memory. Define this macro onthose machines to be a C expression that is non-zero if objects of mode@var{m} in registers of @var{class1} can only be copied to registers ofclass @var{class2} by storing a register of @var{class1} into memoryand loading that memory location into a register of @var{class2}.Do not define this macro if its value would always be zero. @findex SMALL_REGISTER_CLASSES@item SMALL_REGISTER_CLASSESNormally the compile
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -