|
|
1.1 root 1: @c Copyright (C) 1988, 1989, 1992 Free Software Foundation, Inc.
2: @c This is part of the GCC manual.
3: @c For copying conditions, see the file gcc.texi.
4:
5: @ifset INTERNALS
6: @node Machine Macros, Config, Machine Desc, Top
7: @chapter Machine Description Macros
8: @cindex machine description macros
9: @cindex macros, machine description
10: @cindex @file{tm.h} macros
11:
12: In addition to the file @file{@var{machine}.md}, a machine description
13: includes a C header file conventionally given the name
14: @file{@var{machine}.h}. This header file defines numerous macros
15: that convey the information about the target machine that does not fit
16: into the scheme of the @file{.md} file. The file @file{tm.h} should be
17: a link to @file{@var{machine}.h}. The header file @file{config.h}
18: includes @file{tm.h} and most compiler source files include
19: @file{config.h}.
20:
21: @menu
22: * Driver:: Controlling how the driver runs the compilation passes.
23: * Run-time Target:: Defining @samp{-m} options like @samp{-m68000} and @samp{-m68020}.
24: * Storage Layout:: Defining sizes and alignments of data.
25: * Type Layout:: Defining sizes and properties of basic user data types.
26: * Registers:: Naming and describing the hardware registers.
27: * Register Classes:: Defining the classes of hardware registers.
28: * Stack and Calling:: Defining which way the stack grows and by how much.
29: * Varargs:: Defining the varargs macros.
30: * Trampolines:: Code set up at run time to enter a nested function.
31: * Library Calls:: Controlling how library routines are implicitly called.
32: * Addressing Modes:: Defining addressing modes valid for memory operands.
33: * Condition Code:: Defining how insns update the condition code.
34: * Costs:: Defining relative costs of different operations.
35: * Sections:: Dividing storage into text, data, and other sections.
36: * PIC:: Macros for position independent code.
37: * Assembler Format:: Defining how to write insns and pseudo-ops to output.
38: * Debugging Info:: Defining the format of debugging output.
39: * Cross-compilation:: Handling floating point for cross-compilers.
40: * Misc:: Everything else.
41: @end menu
42:
43: @node Driver, Run-time Target, Machine Macros, Machine Macros
44: @section Controlling the Compilation Driver, @file{gcc}
45: @cindex driver
46: @cindex controlling the compilation driver
47:
48: @table @code
49: @findex SWITCH_TAKES_ARG
50: @item SWITCH_TAKES_ARG (@var{char})
51: A C expression which determines whether the option @samp{-@var{char}}
52: takes arguments. The value should be the number of arguments that
53: option takes--zero, for many options.
54:
55: By default, this macro is defined to handle the standard options
56: properly. You need not define it unless you wish to add additional
57: options which take arguments.
58:
59: @findex WORD_SWITCH_TAKES_ARG
60: @item WORD_SWITCH_TAKES_ARG (@var{name})
61: A C expression which determines whether the option @samp{-@var{name}}
62: takes arguments. The value should be the number of arguments that
63: option takes--zero, for many options. This macro rather than
64: @code{SWITCH_TAKES_ARG} is used for multi-character option names.
65:
66: By default, this macro is defined to handle the standard options
67: properly. You need not define it unless you wish to add additional
68: options which take arguments.
69:
70: @findex SWITCHES_NEED_SPACES
71: @item SWITCHES_NEED_SPACES
72: A string-valued C expression which is nonempty if the linker needs a
73: space between the @samp{-L} or @samp{-o} option and its argument.
74:
75: If this macro is not defined, the default value is 0.
76:
77: @findex CPP_SPEC
78: @item CPP_SPEC
79: A C string constant that tells the GNU CC driver program options to
80: pass to CPP. It can also specify how to translate options you
81: give to GNU CC into options for GNU CC to pass to the CPP.
82:
83: Do not define this macro if it does not need to do anything.
84:
85: @findex SIGNED_CHAR_SPEC
86: @item SIGNED_CHAR_SPEC
87: A C string constant that tells the GNU CC driver program options to
88: pass to CPP. By default, this macro is defined to pass the option
89: @samp{-D__CHAR_UNSIGNED__} to CPP if @code{char} will be treated as
90: @code{unsigned char} by @code{cc1}.
91:
92: Do not define this macro unless you need to override the default
93: definition.
94:
95: @findex CC1_SPEC
96: @item CC1_SPEC
97: A C string constant that tells the GNU CC driver program options to
98: pass to @code{cc1}. It can also specify how to translate options you
99: give to GNU CC into options for GNU CC to pass to the @code{cc1}.
100:
101: Do not define this macro if it does not need to do anything.
102:
103: @findex CC1PLUS_SPEC
104: @item CC1PLUS_SPEC
105: A C string constant that tells the GNU CC driver program options to
106: pass to @code{cc1plus}. It can also specify how to translate options you
107: give to GNU CC into options for GNU CC to pass to the @code{cc1plus}.
108:
109: Do not define this macro if it does not need to do anything.
110:
111: @findex ASM_SPEC
112: @item ASM_SPEC
113: A C string constant that tells the GNU CC driver program options to
114: pass to the assembler. It can also specify how to translate options
115: you give to GNU CC into options for GNU CC to pass to the assembler.
116: See the file @file{sun3.h} for an example of this.
117:
118: Do not define this macro if it does not need to do anything.
119:
120: @findex ASM_FINAL_SPEC
121: @item ASM_FINAL_SPEC
122: A C string constant that tells the GNU CC driver program how to
123: run any programs which cleanup after the normal assembler.
124: Normally, this is not needed. See the file @file{mips.h} for
125: an example of this.
126:
127: Do not define this macro if it does not need to do anything.
128:
129: @findex LINK_SPEC
130: @item LINK_SPEC
131: A C string constant that tells the GNU CC driver program options to
132: pass to the linker. It can also specify how to translate options you
133: give to GNU CC into options for GNU CC to pass to the linker.
134:
135: Do not define this macro if it does not need to do anything.
136:
137: @findex LIB_SPEC
138: @item LIB_SPEC
139: Another C string constant used much like @code{LINK_SPEC}. The difference
140: between the two is that @code{LIB_SPEC} is used at the end of the
141: command given to the linker.
142:
143: If this macro is not defined, a default is provided that
144: loads the standard C library from the usual place. See @file{gcc.c}.
145:
146: @findex STARTFILE_SPEC
147: @item STARTFILE_SPEC
148: Another C string constant used much like @code{LINK_SPEC}. The
149: difference between the two is that @code{STARTFILE_SPEC} is used at
150: the very beginning of the command given to the linker.
151:
152: If this macro is not defined, a default is provided that loads the
153: standard C startup file from the usual place. See @file{gcc.c}.
154:
155: @findex ENDFILE_SPEC
156: @item ENDFILE_SPEC
157: Another C string constant used much like @code{LINK_SPEC}. The
158: difference between the two is that @code{ENDFILE_SPEC} is used at
159: the very end of the command given to the linker.
160:
161: Do not define this macro if it does not need to do anything.
162:
163: @findex LINK_LIBGCC_SPECIAL
164: @item LINK_LIBGCC_SPECIAL
165: Define this macro meaning that @code{gcc} should find the
166: library @file{libgcc.a} by hand, rather than passing the argument
167: @samp{-lgcc} to tell the linker to do the search.
168:
169: @findex RELATIVE_PREFIX_NOT_LINKDIR
170: @item RELATIVE_PREFIX_NOT_LINKDIR
171: Define this macro to tell @code{gcc} that it should only translate
172: a @samp{-B} prefix into a @samp{-L} linker option if the prefix
173: indicates an absolute file name.
174:
175: @findex STANDARD_EXEC_PREFIX
176: @item STANDARD_EXEC_PREFIX
177: Define this macro as a C string constant if you wish to override the
178: standard choice of @file{/usr/local/lib/gcc/} as the default prefix to
179: try when searching for the executable files of the compiler.
180:
181: @findex MD_EXEC_PREFIX
182: @item MD_EXEC_PREFIX
183: If defined, this macro is an additional prefix to try after
184: @code{STANDARD_EXEC_PREFIX}. @code{MD_EXEC_PREFIX} is not searched
185: when the @samp{-b} option is used, or the compiler is built as a cross
186: compiler.
187:
188: @findex STANDARD_STARTFILE_PREFIX
189: @item STANDARD_STARTFILE_PREFIX
190: Define this macro as a C string constant if you wish to override the
191: standard choice of @file{/usr/local/lib/gcc/} as the default prefix to
192: try when searching for startup files such as @file{crt0.o}.
193:
194: @findex MD_STARTFILE_PREFIX
195: @item MD_STARTFILE_PREFIX
196: If defined, this macro supplies an additional prefix to try after
197: the standard prefixes. @code{MD_EXEC_PREFIX} is not searched
198: when the @samp{-b} option is used, or the compiler is built as a cross
199: compiler.
200:
201: @findex LOCAL_INCLUDE_DIR
202: @item LOCAL_INCLUDE_DIR
203: Define this macro as a C string constant if you wish to override the
204: standard choice of @file{/usr/local/include} as the default prefix to
205: try when searching for local header files. @code{LOCAL_INCLUDE_DIR}
206: comes before @code{SYSTEM_INCLUDE_DIR} in the search order.
207:
208: Cross compilers do not use this macro and do not search either
209: @file{/usr/local/include} or its replacement.
210:
211: @findex SYSTEM_INCLUDE_DIR
212: @item SYSTEM_INCLUDE_DIR
213: Define this macro as a C string constant if you wish to specify a
214: system-specific directory to search for header files before the standard
215: directory. @code{SYSTEM_INCLUDE_DIR} comes before
216: @code{STANDARD_INCLUDE_DIR} in the search order.
217:
218: Cross compilers do not use this macro and do not search the directory
219: specified.
220:
221: @findex STANDARD_INCLUDE_DIR
222: @item STANDARD_INCLUDE_DIR
223: Define this macro as a C string constant if you wish to override the
224: standard choice of @file{/usr/include} as the default prefix to
225: try when searching for header files.
226:
227: Cross compilers do not use this macro and do not search either
228: @file{/usr/include} or its replacement.
229:
230: @findex INCLUDE_DEFAULTS
231: @item INCLUDE_DEFAULTS
232: Define this macro if you wish to override the entire default search path
233: for include files. The default search path includes
234: @code{GPLUSPLUS_INCLUDE_DIR}, @code{GCC_INCLUDE_DIR},
235: @code{LOCAL_INCLUDE_DIR}, @code{SYSTEM_INCLUDE_DIR}, and
236: @code{STANDARD_INCLUDE_DIR}. In addition, the macros
237: @code{GPLUSPLUS_INCLUDE_DIR} and @code{GCC_INCLUDE_DIR} are defined
238: automatically by @file{Makefile}, and specify private search areas for
239: GCC. The directory @code{GPLUSPLUS_INCLUDE_DIR} is used only for C++
240: programs.
241:
242: The definition should be an initializer for an array of structures.
243: Each array element should have two elements: the directory name (a
244: string constant) and a flag for C++-only directories. Mark the end of
245: the array with a null element. For example, here is the definition used
246: for VMS:
247:
248: @example
249: #define INCLUDE_DEFAULTS \
250: @{ \
251: @{ "GNU_GXX_INCLUDE:", 1@}, \
252: @{ "GNU_CC_INCLUDE:", 0@}, \
253: @{ "SYS$SYSROOT:[SYSLIB.]", 0@}, \
254: @{ ".", 0@}, \
255: @{ 0, 0@} \
256: @}
257: @end example
258: @end table
259:
260: Here is the order of prefixes tried for exec files:
261:
262: @enumerate
263: @item
264: Any prefixes specified by the user with @samp{-B}.
265:
266: @item
267: The environment variable @code{GCC_EXEC_PREFIX}, if any.
268:
269: @item
270: The directories specified by the environment variable @code{COMPILER_PATH}.
271:
272: @item
273: The macro @code{STANDARD_EXEC_PREFIX}.
274:
275: @item
276: @file{/usr/lib/gcc/}.
277:
278: @item
279: The macro @code{MD_EXEC_PREFIX}, if any.
280: @end enumerate
281:
282: Here is the order of prefixes tried for startfiles:
283:
284: @enumerate
285: @item
286: Any prefixes specified by the user with @samp{-B}.
287:
288: @item
289: The environment variable @code{GCC_EXEC_PREFIX}, if any.
290:
291: @item
292: The directories specified by the environment variable @code{LIBRARY_PATH}.
293:
294: @item
295: The macro @code{STANDARD_EXEC_PREFIX}.
296:
297: @item
298: @file{/usr/lib/gcc/}.
299:
300: @item
301: The macro @code{MD_EXEC_PREFIX}, if any.
302:
303: @item
304: The macro @code{MD_STARTFILE_PREFIX}, if any.
305:
306: @item
307: The macro @code{STANDARD_STARTFILE_PREFIX}.
308:
309: @item
310: @file{/lib/}.
311:
312: @item
313: @file{/usr/lib/}.
314: @end enumerate
315:
316: @node Run-time Target, Storage Layout, Driver, Machine Macros
317: @section Run-time Target Specification
318: @cindex run-time target specification
319: @cindex predefined macros
320: @cindex target specifications
321:
322: @table @code
323: @findex CPP_PREDEFINES
324: @item CPP_PREDEFINES
325: Define this to be a string constant containing @samp{-D} options to
326: define the predefined macros that identify this machine and system.
327: These macros will be predefined unless the @samp{-ansi} option is
328: specified.
329:
330: In addition, a parallel set of macros are predefined, whose names are
331: made by appending @samp{__} at the beginning and at the end. These
332: @samp{__} macros are permitted by the ANSI standard, so they are
333: predefined regardless of whether @samp{-ansi} is specified.
334:
335: For example, on the Sun, one can use the following value:
336:
337: @example
338: "-Dmc68000 -Dsun -Dunix"
339: @end example
340:
341: The result is to define the macros @code{__mc68000__}, @code{__sun__}
342: and @code{__unix__} unconditionally, and the macros @code{mc68000},
343: @code{sun} and @code{unix} provided @samp{-ansi} is not specified.
344:
345: @findex STDC_VALUE
346: @item STDC_VALUE
347: Define the value to be assigned to the built-in macro @code{__STDC__}.
348: The default is the value @samp{1}.
349:
350: @findex extern int target_flags
351: @item extern int target_flags;
352: This declaration should be present.
353:
354: @cindex optional hardware or system features
355: @cindex features, optional, in system conventions
356: @item TARGET_@dots{}
357: This series of macros is to allow compiler command arguments to
358: enable or disable the use of optional features of the target machine.
359: For example, one machine description serves both the 68000 and
360: the 68020; a command argument tells the compiler whether it should
361: use 68020-only instructions or not. This command argument works
362: by means of a macro @code{TARGET_68020} that tests a bit in
363: @code{target_flags}.
364:
365: Define a macro @code{TARGET_@var{featurename}} for each such option.
366: Its definition should test a bit in @code{target_flags}; for example:
367:
368: @example
369: #define TARGET_68020 (target_flags & 1)
370: @end example
371:
372: One place where these macros are used is in the condition-expressions
373: of instruction patterns. Note how @code{TARGET_68020} appears
374: frequently in the 68000 machine description file, @file{m68k.md}.
375: Another place they are used is in the definitions of the other
376: macros in the @file{@var{machine}.h} file.
377:
378: @findex TARGET_SWITCHES
379: @item TARGET_SWITCHES
380: This macro defines names of command options to set and clear
381: bits in @code{target_flags}. Its definition is an initializer
382: with a subgrouping for each command option.
383:
384: Each subgrouping contains a string constant, that defines the option
385: name, and a number, which contains the bits to set in
386: @code{target_flags}. A negative number says to clear bits instead;
387: the negative of the number is which bits to clear. The actual option
388: name is made by appending @samp{-m} to the specified name.
389:
390: One of the subgroupings should have a null string. The number in
391: this grouping is the default value for @code{target_flags}. Any
392: target options act starting with that value.
393:
394: Here is an example which defines @samp{-m68000} and @samp{-m68020}
395: with opposite meanings, and picks the latter as the default:
396:
397: @example
398: #define TARGET_SWITCHES \
399: @{ @{ "68020", 1@}, \
400: @{ "68000", -1@}, \
401: @{ "", 1@}@}
402: @end example
403:
404: @findex TARGET_OPTIONS
405: @item TARGET_OPTIONS
406: This macro is similar to @code{TARGET_SWITCHES} but defines names of command
407: options that have values. Its definition is an initializer with a
408: subgrouping for each command option.
409:
410: Each subgrouping contains a string constant, that defines the fixed part
411: of the option name, and the address of a variable. The variable, type
412: @code{char *}, is set to the variable part of the given option if the fixed
413: part matches. The actual option name is made by appending @samp{-m} to the
414: specified name.
415:
416: Here is an example which defines @samp{-mshort-data-@var{number}}. If the
417: given option is @samp{-mshort-data-512}, the variable @code{m88k_short_data}
418: will be set to the string @code{"512"}.
419:
420: @example
421: extern char *m88k_short_data;
422: #define TARGET_OPTIONS @{ @{ "short-data-", &m88k_short_data @} @}
423: @end example
424:
425: @findex TARGET_VERSION
426: @item TARGET_VERSION
427: This macro is a C statement to print on @code{stderr} a string
428: describing the particular machine description choice. Every machine
429: description should define @code{TARGET_VERSION}. For example:
430:
431: @example
432: #ifdef MOTOROLA
433: #define TARGET_VERSION fprintf (stderr, " (68k, Motorola syntax)");
434: #else
435: #define TARGET_VERSION fprintf (stderr, " (68k, MIT syntax)");
436: #endif
437: @end example
438:
439: @findex OVERRIDE_OPTIONS
440: @item OVERRIDE_OPTIONS
441: Sometimes certain combinations of command options do not make sense on
442: a particular target machine. You can define a macro
443: @code{OVERRIDE_OPTIONS} to take account of this. This macro, if
444: defined, is executed once just after all the command options have been
445: parsed.
446:
447: Don't use this macro to turn on various extra optimizations for
448: @samp{-O}. That is what @code{OPTIMIZATION_OPTIONS} is for.
449:
450: @findex OPTIMIZATION_OPTIONS
451: @item OPTIMIZATION_OPTIONS (@var{level})
452: Some machines may desire to change what optimizations are performed for
453: various optimization levels. This macro, if defined, is executed once
454: just after the optimization level is determined and before the remainder
455: of the command options have been parsed. Values set in this macro are
456: used as the default values for the other command line options.
457:
458: @var{level} is the optimization level specified; 2 if -O2 is specified,
459: 1 if -O is specified, and 0 if neither is specified.
460:
461: @strong{Do not examine @code{write_symbols} in this macro!}
462: The debugging options are not supposed to alter the generated code.
463: @end table
464:
465: @node Storage Layout, Type Layout, Run-time Target, Machine Macros
466: @section Storage Layout
467: @cindex storage layout
468:
469: Note that the definitions of the macros in this table which are sizes or
470: alignments measured in bits do not need to be constant. They can be C
471: expressions that refer to static variables, such as the @code{target_flags}.
472: @xref{Run-time Target}.
473:
474: @table @code
475: @findex BITS_BIG_ENDIAN
476: @item BITS_BIG_ENDIAN
477: Define this macro to be the value 1 if the most significant bit in a
478: byte has the lowest number; otherwise define it to be the value zero.
479: This means that bit-field instructions count from the most significant
480: bit. If the machine has no bit-field instructions, this macro is
481: irrelevant.
482:
483: This macro does not affect the way structure fields are packed into
484: bytes or words; that is controlled by @code{BYTES_BIG_ENDIAN}.
485:
486: @findex BYTES_BIG_ENDIAN
487: @item BYTES_BIG_ENDIAN
488: Define this macro to be 1 if the most significant byte in a word has the
489: lowest number.
490:
491: @findex WORDS_BIG_ENDIAN
492: @item WORDS_BIG_ENDIAN
493: Define this macro to be 1 if, in a multiword object, the most
494: significant word has the lowest number.
495:
496: @findex BITS_PER_UNIT
497: @item BITS_PER_UNIT
498: Number of bits in an addressable storage unit (byte); normally 8.
499:
500: @findex BITS_PER_WORD
501: @item BITS_PER_WORD
502: Number of bits in a word; normally 32.
503:
504: @findex MAX_BITS_PER_WORD
505: @item MAX_BITS_PER_WORD
506: Maximum number of bits in a word. If this is undefined, the default is
507: @code{BITS_PER_WORD}. Otherwise, it is the constant value that is the
508: largest value that @code{BITS_PER_WORD} can have at run-time.
509:
510: @findex UNITS_PER_WORD
511: @item UNITS_PER_WORD
512: Number of storage units in a word; normally 4.
513:
514: @findex POINTER_SIZE
515: @item POINTER_SIZE
516: Width of a pointer, in bits.
517:
518: @findex PARM_BOUNDARY
519: @item PARM_BOUNDARY
520: Normal alignment required for function parameters on the stack, in
521: bits. All stack parameters receive least this much alignment
522: regardless of data type. On most machines, this is the same as the
523: size of an integer.
524:
525: @findex STACK_BOUNDARY
526: @item STACK_BOUNDARY
527: Define this macro if you wish to preserve a certain alignment for
528: the stack pointer. The definition is a C expression
529: for the desired alignment (measured in bits).
530:
531: @cindex @code{PUSH_ROUNDING}, interaction with @code{STACK_BOUNDARY}
532: If @code{PUSH_ROUNDING} is not defined, the stack will always be aligned
533: to the specified boundary. If @code{PUSH_ROUNDING} is defined and specifies a
534: less strict alignment than @code{STACK_BOUNDARY}, the stack may be
535: momentarily unaligned while pushing arguments.
536:
537: @findex FUNCTION_BOUNDARY
538: @item FUNCTION_BOUNDARY
539: Alignment required for a function entry point, in bits.
540:
541: @findex BIGGEST_ALIGNMENT
542: @item BIGGEST_ALIGNMENT
543: Biggest alignment that any data type can require on this machine, in bits.
544:
545: @findex BIGGEST_FIELD_ALIGNMENT
546: @item BIGGEST_FIELD_ALIGNMENT
547: Biggest alignment that any structure field can require on this machine,
548: in bits.
549:
550: @findex MAX_OFILE_ALIGNMENT
551: @item MAX_OFILE_ALIGNMENT
552: Biggest alignment supported by the object file format of this machine.
553: Use this macro to limit the alignment which can be specified using the
554: @code{__attribute__ ((aligned (@var{n})))} construct. If not defined,
555: the default value is @code{BIGGEST_ALIGNMENT}.
556:
557: @findex DATA_ALIGNMENT
558: @item DATA_ALIGNMENT (@var{type}, @var{basic-align})
559: If defined, a C expression to compute the alignment for a static
560: variable. @var{type} is the data type, and @var{basic-align} is the
561: alignment that the object would ordinarily have. The value of this
562: macro is used instead of that alignment to align the object.
563:
564: If this macro is not defined, then @var{basic-align} is used.
565:
566: @findex strcpy
567: One use of this macro is to increase alignment of medium-size data to
568: make it all fit in fewer cache lines. Another is to cause character
569: arrays to be word-aligned so that @code{strcpy} calls that copy
570: constants to character arrays can be done inline.
571:
572: @findex CONSTANT_ALIGNMENT
573: @item CONSTANT_ALIGNMENT (@var{constant}, @var{basic-align})
574: If defined, a C expression to compute the alignment given to a constant
575: that is being placed in memory. @var{constant} is the constant and
576: @var{basic-align} is the alignment that the object would ordinarily
577: have. The value of this macro is used instead of that alignment to
578: align the object.
579:
580: If this macro is not defined, then @var{basic-align} is used.
581:
582: The typical use of this macro is to increase alignment for string
583: constants to be word aligned so that @code{strcpy} calls that copy
584: constants can be done inline.
585:
586: @findex EMPTY_FIELD_BOUNDARY
587: @item EMPTY_FIELD_BOUNDARY
588: Alignment in bits to be given to a structure bit field that follows an
589: empty field such as @code{int : 0;}.
590:
591: @findex STRUCTURE_SIZE_BOUNDARY
592: @item STRUCTURE_SIZE_BOUNDARY
593: Number of bits which any structure or union's size must be a multiple of.
594: Each structure or union's size is rounded up to a multiple of this.
595:
596: If you do not define this macro, the default is the same as
597: @code{BITS_PER_UNIT}.
598:
599: @findex STRICT_ALIGNMENT
600: @item STRICT_ALIGNMENT
601: Define this if instructions will fail to work if given data not
602: on the nominal alignment. If instructions will merely go slower
603: in that case, do not define this macro.
604:
605: @findex PCC_BITFIELD_TYPE_MATTERS
606: @item PCC_BITFIELD_TYPE_MATTERS
607: Define this if you wish to imitate the way many other C compilers handle
608: alignment of bitfields and the structures that contain them.
609:
610: The behavior is that the type written for a bitfield (@code{int},
611: @code{short}, or other integer type) imposes an alignment for the
612: entire structure, as if the structure really did contain an ordinary
613: field of that type. In addition, the bitfield is placed within the
614: structure so that it would fit within such a field, not crossing a
615: boundary for it.
616:
617: Thus, on most machines, a bitfield whose type is written as @code{int}
618: would not cross a four-byte boundary, and would force four-byte
619: alignment for the whole structure. (The alignment used may not be four
620: bytes; it is controlled by the other alignment parameters.)
621:
622: If the macro is defined, its definition should be a C expression;
623: a nonzero value for the expression enables this behavior.
624:
625: Note that if this macro is not defined, or its value is zero, some
626: bitfields may cross more than one alignment boundary. The compiler can
627: support such references if there are @samp{insv}, @samp{extv}, and
628: @samp{extzv} insns that can directly reference memory.
629:
630: The other known way of making bitfields work is to define
631: @code{STRUCTURE_SIZE_BOUNDARY} as large as @code{BIGGEST_ALIGNMENT}.
632: Then every structure can be accessed with fullwords.
633:
634: Unless the machine has bitfield instructions or you define
635: @code{STRUCTURE_SIZE_BOUNDARY} that way, you must define
636: @code{PCC_BITFIELD_TYPE_MATTERS} to have a nonzero value.
637:
638: @findex BITFIELD_NBYTES_LIMITED
639: @item BITFIELD_NBYTES_LIMITED
640: Like PCC_BITFIELD_TYPE_MATTERS except that its effect is limited to
641: aligning a bitfield within the structure.
642:
643: @findex ROUND_TYPE_SIZE
644: @item ROUND_TYPE_SIZE (@var{struct}, @var{size}, @var{align})
645: Define this macro as an expression for the overall size of a structure
646: (given by @var{struct} as a tree node) when the size computed from the
647: fields is @var{size} and the alignment is @var{align}.
648:
649: The default is to round @var{size} up to a multiple of @var{align}.
650:
651: @findex ROUND_TYPE_ALIGN
652: @item ROUND_TYPE_ALIGN (@var{struct}, @var{computed}, @var{specified})
653: Define this macro as an expression for the alignment of a structure
654: (given by @var{struct} as a tree node) if the alignment computed in the
655: usual way is @var{computed} and the alignment explicitly specified was
656: @var{specified}.
657:
658: The default is to use @var{specified} if it is larger; otherwise, use
659: the smaller of @var{computed} and @code{BIGGEST_ALIGNMENT}
660:
661: @findex MAX_FIXED_MODE_SIZE
662: @item MAX_FIXED_MODE_SIZE
663: An integer expression for the size in bits of the largest integer
664: machine mode that should actually be used. All integer machine modes of
665: this size or smaller can be used for structures and unions with the
666: appropriate sizes. If this macro is undefined, @code{GET_MODE_BITSIZE
667: (DImode)} is assumed.
668:
669: @findex CHECK_FLOAT_VALUE
670: @item CHECK_FLOAT_VALUE (@var{mode}, @var{value})
671: A C statement to validate the value @var{value} (of type
672: @code{double}) for mode @var{mode}. This means that you check whether
673: @var{value} fits within the possible range of values for mode
674: @var{mode} on this target machine. The mode @var{mode} is always
675: @code{SFmode} or @code{DFmode}.
676:
677: @findex error
678: If @var{value} is not valid, you should call @code{error} to print an
679: error message and then assign some valid value to @var{value}.
680: Allowing an invalid value to go through the compiler can produce
681: incorrect assembler code which may even cause Unix assemblers to
682: crash.
683:
684: This macro need not be defined if there is no work for it to do.
685:
686: @findex TARGET_FLOAT_FORMAT
687: @item TARGET_FLOAT_FORMAT
688: A code distinguishing the floating point format of the target machine.
689: There are three defined values:
690:
691: @table @code
692: @findex IEEE_FLOAT_FORMAT
693: @item IEEE_FLOAT_FORMAT
694: This code indicates IEEE floating point. It is the default; there is no
695: need to define this macro when the format is IEEE.
696:
697: @findex VAX_FLOAT_FORMAT
698: @item VAX_FLOAT_FORMAT
699: This code indicates the peculiar format used on the Vax.
700:
701: @findex UNKNOWN_FLOAT_FORMAT
702: @item UNKNOWN_FLOAT_FORMAT
703: This code indicates any other format.
704: @end table
705:
706: The value of this macro is compared with @code{HOST_FLOAT_FORMAT}
707: (@pxref{Config}) to determine whether the target machine has the same
708: format as the host machine. If any other formats are actually in use on
709: supported machines, new codes should be defined for them.
710: @end table
711:
712: @node Type Layout, Registers, Storage Layout, Machine Macros
713: @section Layout of Source Language Data Types
714:
715: These macros define the sizes and other characteristics of the standard
716: basic data types used in programs being compiled. Unlike the macros in
717: the previous section, these apply to specific features of C and related
718: languages, rather than to fundamental aspects of storage layout.
719:
720: @table @code
721: @findex INT_TYPE_SIZE
722: @item INT_TYPE_SIZE
723: A C expression for the size in bits of the type @code{int} on the
724: target machine. If you don't define this, the default is one word.
725:
726: @findex SHORT_TYPE_SIZE
727: @item SHORT_TYPE_SIZE
728: A C expression for the size in bits of the type @code{short} on the
729: target machine. If you don't define this, the default is half a word.
730: (If this would be less than one storage unit, it is rounded up to one
731: unit.)
732:
733: @findex LONG_TYPE_SIZE
734: @item LONG_TYPE_SIZE
735: A C expression for the size in bits of the type @code{long} on the
736: target machine. If you don't define this, the default is one word.
737:
738: @findex LONG_LONG_TYPE_SIZE
739: @item LONG_LONG_TYPE_SIZE
740: A C expression for the size in bits of the type @code{long long} on the
741: target machine. If you don't define this, the default is two
742: words.
743:
744: @findex CHAR_TYPE_SIZE
745: @item CHAR_TYPE_SIZE
746: A C expression for the size in bits of the type @code{char} on the
747: target machine. If you don't define this, the default is one quarter
748: of a word. (If this would be less than one storage unit, it is rounded up
749: to one unit.)
750:
751: @findex FLOAT_TYPE_SIZE
752: @item FLOAT_TYPE_SIZE
753: A C expression for the size in bits of the type @code{float} on the
754: target machine. If you don't define this, the default is one word.
755:
756: @findex DOUBLE_TYPE_SIZE
757: @item DOUBLE_TYPE_SIZE
758: A C expression for the size in bits of the type @code{double} on the
759: target machine. If you don't define this, the default is two
760: words.
761:
762: @findex LONG_DOUBLE_TYPE_SIZE
763: @item LONG_DOUBLE_TYPE_SIZE
764: A C expression for the size in bits of the type @code{long double} on
765: the target machine. If you don't define this, the default is two
766: words.
767:
768: @findex DEFAULT_SIGNED_CHAR
769: @item DEFAULT_SIGNED_CHAR
770: An expression whose value is 1 or 0, according to whether the type
771: @code{char} should be signed or unsigned by default. The user can
772: always override this default with the options @samp{-fsigned-char}
773: and @samp{-funsigned-char}.
774:
775: @findex DEFAULT_SHORT_ENUMS
776: @item DEFAULT_SHORT_ENUMS
777: A C expression to determine whether to give an @code{enum} type
778: only as many bytes as it takes to represent the range of possible values
779: of that type. A nonzero value means to do that; a zero value means all
780: @code{enum} types should be allocated like @code{int}.
781:
782: If you don't define the macro, the default is 0.
783:
784: @findex SIZE_TYPE
785: @item SIZE_TYPE
786: A C expression for a string describing the name of the data type to use
787: for size values. The typedef name @code{size_t} is defined using the
788: contents of the string.
789:
790: The string can contain more than one keyword. If so, separate them with
791: spaces, and write first any length keyword, then @code{unsigned} if
792: appropriate, and finally @code{int}. The string must exactly match one
793: of the data type names defined in the function
794: @code{init_decl_processing} in the file @file{c-decl.c}. You may not
795: omit @code{int} or change the order---that would cause the compiler to
796: crash on startup.
797:
798: If you don't define this macro, the default is @code{"long unsigned
799: int"}.
800:
801: @findex PTRDIFF_TYPE
802: @item PTRDIFF_TYPE
803: A C expression for a string describing the name of the data type to use
804: for the result of subtracting two pointers. The typedef name
805: @code{ptrdiff_t} is defined using the contents of the string. See
806: @code{SIZE_TYPE} above for more information.
807:
808: If you don't define this macro, the default is @code{"long int"}.
809:
810: @findex WCHAR_TYPE
811: @item WCHAR_TYPE
812: A C expression for a string describing the name of the data type to use
813: for wide characters. The typedef name @code{wchar_t} is defined using
814: the contents of the string. See @code{SIZE_TYPE} above for more
815: information.
816:
817: If you don't define this macro, the default is @code{"int"}.
818:
819: @findex WCHAR_TYPE_SIZE
820: @item WCHAR_TYPE_SIZE
821: A C expression for the size in bits of the data type for wide
822: characters. This is used in @code{cpp}, which cannot make use of
823: @code{WCHAR_TYPE}.
824:
825: @findex OBJC_INT_SELECTORS
826: @item OBJC_INT_SELECTORS
827: Define this macro if the type of Objective C selectors should be
828: @code{int}.
829:
830: If this macro is not defined, then selectors should have the type
831: @code{struct objc_selector *}.
832:
833: @findex OBJC_NONUNIQUE_SELECTORS
834: @item OBJC_NONUNIQUE_SELECTORS
835: Define this macro if Objective C selector-references will be made unique
836: by the linker (this is the default). In this case, each
837: selector-reference will be given a separate assembler label. Otherwise,
838: the selector-references will be gathered into an array with a single
839: assembler label.
840:
841: @findex MULTIBYTE_CHARS
842: @item MULTIBYTE_CHARS
843: Define this macro to enable support for multibyte characters in the input
844: to GNU CC. This requires that the host system support the ANSI C library
845: functions for converting multibyte characters to wide characters.
846:
847: @findex TARGET_BELL
848: @item TARGET_BELL
849: A C constant expression for the integer value for escape sequence
850: @samp{\a}.
851:
852: @findex TARGET_TAB
853: @findex TARGET_BS
854: @findex TARGET_NEWLINE
855: @item TARGET_BS
856: @itemx TARGET_TAB
857: @itemx TARGET_NEWLINE
858: C constant expressions for the integer values for escape sequences
859: @samp{\b}, @samp{\t} and @samp{\n}.
860:
861: @findex TARGET_VT
862: @findex TARGET_FF
863: @findex TARGET_CR
864: @item TARGET_VT
865: @itemx TARGET_FF
866: @itemx TARGET_CR
867: C constant expressions for the integer values for escape sequences
868: @samp{\v}, @samp{\f} and @samp{\r}.
869: @end table
870:
871: @node Registers, Register Classes, Type Layout, Machine Macros
872: @section Register Usage
873: @cindex register usage
874:
875: This section explains how to describe what registers the target machine
876: has, and how (in general) they can be used.
877:
878: The description of which registers a specific instruction can use is
879: done with register classes; see @ref{Register Classes}. For information
880: on using registers to access a stack frame, see @ref{Frame Registers}.
881: For passing values in registers, see @ref{Register Arguments}.
882: For returning values in registers, see @ref{Scalar Return}.
883:
884: @menu
885: * Register Basics:: Number and kinds of registers.
886: * Allocation Order:: Order in which registers are allocated.
887: * Values in Registers:: What kinds of values each reg can hold.
888: * Leaf Functions:: Renumbering registers for leaf functions.
889: * Stack Registers:: Handling a register stack such as 80387.
890: * Obsolete Register Macros:: Macros formerly used for the 80387.
891: @end menu
892:
893: @node Register Basics
894: @subsection Basic Characteristics of Registers
895:
896: @table @code
897: @findex FIRST_PSEUDO_REGISTER
898: @item FIRST_PSEUDO_REGISTER
899: Number of hardware registers known to the compiler. They receive
900: numbers 0 through @code{FIRST_PSEUDO_REGISTER-1}; thus, the first
901: pseudo register's number really is assigned the number
902: @code{FIRST_PSEUDO_REGISTER}.
903:
904: @item FIXED_REGISTERS
905: @findex FIXED_REGISTERS
906: @cindex fixed register
907: An initializer that says which registers are used for fixed purposes
908: all throughout the compiled code and are therefore not available for
909: general allocation. These would include the stack pointer, the frame
910: pointer (except on machines where that can be used as a general
911: register when no frame pointer is needed), the program counter on
912: machines where that is considered one of the addressable registers,
913: and any other numbered register with a standard use.
914:
915: This information is expressed as a sequence of numbers, separated by
916: commas and surrounded by braces. The @var{n}th number is 1 if
917: register @var{n} is fixed, 0 otherwise.
918:
919: The table initialized from this macro, and the table initialized by
920: the following one, may be overridden at run time either automatically,
921: by the actions of the macro @code{CONDITIONAL_REGISTER_USAGE}, or by
922: the user with the command options @samp{-ffixed-@var{reg}},
923: @samp{-fcall-used-@var{reg}} and @samp{-fcall-saved-@var{reg}}.
924:
925: @findex CALL_USED_REGISTERS
926: @item CALL_USED_REGISTERS
927: @cindex call-used register
928: @cindex call-clobbered register
929: @cindex call-saved register
930: Like @code{FIXED_REGISTERS} but has 1 for each register that is
931: clobbered (in general) by function calls as well as for fixed
932: registers. This macro therefore identifies the registers that are not
933: available for general allocation of values that must live across
934: function calls.
935:
936: If a register has 0 in @code{CALL_USED_REGISTERS}, the compiler
937: automatically saves it on function entry and restores it on function
938: exit, if the register is used within the function.
939:
940: @findex CONDITIONAL_REGISTER_USAGE
941: @findex fixed_regs
942: @findex call_used_regs
943: @item CONDITIONAL_REGISTER_USAGE
944: Zero or more C statements that may conditionally modify two variables
945: @code{fixed_regs} and @code{call_used_regs} (both of type @code{char
946: []}) after they have been initialized from the two preceding macros.
947:
948: This is necessary in case the fixed or call-clobbered registers depend
949: on target flags.
950:
951: You need not define this macro if it has no work to do.
952:
953: @cindex disabling certain registers
954: @cindex controlling register usage
955: If the usage of an entire class of registers depends on the target
956: flags, you may indicate this to GCC by using this macro to modify
957: @code{fixed_regs} and @code{call_used_regs} to 1 for each of the
958: registers in the classes which should not be used by GCC. Also define
959: the macro @code{REG_CLASS_FROM_LETTER} to return @code{NO_REGS} if it
960: is called with a letter for a class that shouldn't be used.
961:
962: (However, if this class is not included in @code{GENERAL_REGS} and all
963: of the insn patterns whose constraints permit this class are
964: controlled by target switches, then GCC will automatically avoid using
965: these registers when the target switches are opposed to them.)
966:
967: @findex NON_SAVING_SETJMP
968: @item NON_SAVING_SETJMP
969: If this macro is defined and has a nonzero value, it means that
970: @code{setjmp} and related functions fail to save the registers, or that
971: @code{longjmp} fails to restore them. To compensate, the compiler
972: avoids putting variables in registers in functions that use
973: @code{setjmp}.
974:
975: @ignore
976: @findex PC_REGNUM
977: @item PC_REGNUM
978: If the program counter has a register number, define this as that
979: register number. Otherwise, do not define it.
980: @end ignore
981: @end table
982:
983: @node Allocation Order
984: @subsection Order of Allocation of Registers
985: @cindex order of register allocation
986: @cindex register allocation order
987:
988: @table @code
989: @findex REG_ALLOC_ORDER
990: @item REG_ALLOC_ORDER
991: If defined, an initializer for a vector of integers, containing the
992: numbers of hard registers in the order in which GNU CC should prefer
993: to use them (from most preferred to least).
994:
995: If this macro is not defined, registers are used lowest numbered first
996: (all else being equal).
997:
998: One use of this macro is on machines where the highest numbered
999: registers must always be saved and the save-multiple-registers
1000: instruction supports only sequences of consecutive registers. On such
1001: machines, define @code{REG_ALLOC_ORDER} to be an initializer that lists
1002: the highest numbered allocatable register first.
1003:
1004: @findex ORDER_REGS_FOR_LOCAL_ALLOC
1005: @item ORDER_REGS_FOR_LOCAL_ALLOC
1006: A C statement (sans semicolon) to choose the order in which to allocate
1007: hard registers for pseudo-registers local to a basic block.
1008:
1009: Store the desired order of registers in the array
1010: @code{reg_alloc_order}. Element 0 should be the register to allocate
1011: first; element 1, the next register; and so on.
1012:
1013: The macro body should not assume anything about the contents of
1014: @code{reg_alloc_order} before execution of the macro.
1015:
1016: On most machines, it is not necessary to define this macro.
1017: @end table
1018:
1019: @node Values in Registers
1020: @subsection How Values Fit in Registers
1021:
1022: This section discusses the macros that describe which kinds of values
1023: (specifically, which machine modes) each register can hold, and how many
1024: consecutive registers are needed for a given mode.
1025:
1026: @table @code
1027: @findex HARD_REGNO_NREGS
1028: @item HARD_REGNO_NREGS (@var{regno}, @var{mode})
1029: A C expression for the number of consecutive hard registers, starting
1030: at register number @var{regno}, required to hold a value of mode
1031: @var{mode}.
1032:
1033: On a machine where all registers are exactly one word, a suitable
1034: definition of this macro is
1035:
1036: @example
1037: #define HARD_REGNO_NREGS(REGNO, MODE) \
1038: ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
1039: / UNITS_PER_WORD))
1040: @end example
1041:
1042: @findex HARD_REGNO_MODE_OK
1043: @item HARD_REGNO_MODE_OK (@var{regno}, @var{mode})
1044: A C expression that is nonzero if it is permissible to store a value
1045: of mode @var{mode} in hard register number @var{regno} (or in several
1046: registers starting with that one). For a machine where all registers
1047: are equivalent, a suitable definition is
1048:
1049: @example
1050: #define HARD_REGNO_MODE_OK(REGNO, MODE) 1
1051: @end example
1052:
1053: It is not necessary for this macro to check for the numbers of fixed
1054: registers, because the allocation mechanism considers them to be always
1055: occupied.
1056:
1057: @cindex register pairs
1058: On some machines, double-precision values must be kept in even/odd
1059: register pairs. The way to implement that is to define this macro
1060: to reject odd register numbers for such modes.
1061:
1062: @ignore
1063: @c I think this is not true now
1064: GNU CC assumes that it can always move values between registers and
1065: (suitably addressed) memory locations. If it is impossible to move a
1066: value of a certain mode between memory and certain registers, then
1067: @code{HARD_REGNO_MODE_OK} must not allow this mode in those registers.
1068: @end ignore
1069:
1070: The minimum requirement for a mode to be OK in a register is that the
1071: @samp{mov@var{mode}} instruction pattern support moves between the
1072: register and any other hard register for which the mode is OK; and that
1073: moving a value into the register and back out not alter it.
1074:
1075: Since the same instruction used to move @code{SImode} will work for all
1076: narrower integer modes, it is not necessary on any machine for
1077: @code{HARD_REGNO_MODE_OK} to distinguish between these modes, provided
1078: you define patterns @samp{movhi}, etc., to take advantage of this. This
1079: is useful because of the interaction between @code{HARD_REGNO_MODE_OK}
1080: and @code{MODES_TIEABLE_P}; it is very desirable for all integer modes
1081: to be tieable.
1082:
1083: Many machines have special registers for floating point arithmetic.
1084: Often people assume that floating point machine modes are allowed only
1085: in floating point registers. This is not true. Any registers that
1086: can hold integers can safely @emph{hold} a floating point machine
1087: mode, whether or not floating arithmetic can be done on it in those
1088: registers. Integer move instructions can be used to move the values.
1089:
1090: On some machines, though, the converse is true: fixed-point machine
1091: modes may not go in floating registers. This is true if the floating
1092: registers normalize any value stored in them, because storing a
1093: non-floating value there would garble it. In this case,
1094: @code{HARD_REGNO_MODE_OK} should reject fixed-point machine modes in
1095: floating registers. But if the floating registers do not automatically
1096: normalize, if you can store any bit pattern in one and retrieve it
1097: unchanged without a trap, then any machine mode may go in a floating
1098: register and this macro should say so.
1099:
1100: The primary significance of special floating registers is rather that
1101: they are the registers acceptable in floating point arithmetic
1102: instructions. However, this is of no concern to
1103: @code{HARD_REGNO_MODE_OK}. You handle it by writing the proper
1104: constraints for those instructions.
1105:
1106: On some machines, the floating registers are especially slow to access,
1107: so that it is better to store a value in a stack frame than in such a
1108: register if floating point arithmetic is not being done. As long as the
1109: floating registers are not in class @code{GENERAL_REGS}, they will not
1110: be used unless some pattern's constraint asks for one.
1111:
1112: @findex MODES_TIEABLE_P
1113: @item MODES_TIEABLE_P (@var{mode1}, @var{mode2})
1114: A C expression that is nonzero if it is desirable to choose register
1115: allocation so as to avoid move instructions between a value of mode
1116: @var{mode1} and a value of mode @var{mode2}.
1117:
1118: If @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode1})} and
1119: @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode2})} are ever different
1120: for any @var{r}, then @code{MODES_TIEABLE_P (@var{mode1},
1121: @var{mode2})} must be zero.
1122: @end table
1123:
1124: @node Leaf Functions
1125: @subsection Handling Leaf Functions
1126:
1127: @cindex leaf functions
1128: @cindex functions, leaf
1129: On some machines, a leaf function (i.e., one which make no calls) can run
1130: more efficiently if it does not make its own register window. Often this
1131: means it is required to receive its arguments in the registers where they
1132: are passed by the caller, instead of the registers where they would
1133: normally arrive. Also, the leaf function may use only those registers for
1134: its own variables and temporaries.
1135:
1136: GNU CC assigns register numbers before it knows whether the function is
1137: suitable for leaf function treatment. So it needs to renumber the
1138: registers in order to output a leaf function. The following macros
1139: accomplish this.
1140:
1141: @table @code
1142: @findex LEAF_REGISTERS
1143: @item LEAF_REGISTERS
1144: A C initializer for a vector, indexed by hard register number, which
1145: contains 1 for a register that is allowable in a candidate for leaf
1146: function treatment.
1147:
1148: If leaf function treatment involves renumbering the registers, then the
1149: registers marked here should be the ones before renumbering---those that
1150: GNU CC would ordinarily allocate. The registers which will actually be
1151: used in the assembler code, after renumbering, should not be marked with 1
1152: in this vector.
1153:
1154: Define this macro only if the target machine offers a way to optimize
1155: the treatment of leaf functions.
1156:
1157: @findex LEAF_REG_REMAP
1158: @item LEAF_REG_REMAP (@var{regno})
1159: A C expression whose value is the register number to which @var{regno}
1160: should be renumbered, when a function is treated as a leaf function.
1161:
1162: If @var{regno} is a register number which should not appear in a leaf
1163: function before renumbering, then the expression should yield -1, which
1164: will cause the compiler to abort.
1165:
1166: Define this macro only if the target machine offers a way to optimize the
1167: treatment of leaf functions, and registers need to be renumbered to do
1168: this.
1169:
1170: @findex REG_LEAF_ALLOC_ORDER
1171: @item REG_LEAF_ALLOC_ORDER
1172: If defined, an initializer for a vector of integers, containing the
1173: numbers of hard registers in the order in which the GNU CC should prefer
1174: to use them (from most preferred to least) in a leaf function. If this
1175: macro is not defined, REG_ALLOC_ORDER is used for both non-leaf and
1176: leaf-functions.
1177: @end table
1178:
1179: @findex leaf_function
1180: Normally, it is necessary for @code{FUNCTION_PROLOGUE} and
1181: @code{FUNCTION_EPILOGUE} to treat leaf functions specially. The C variable
1182: @code{leaf_function} is nonzero for such a function.
1183:
1184: @node Stack Registers
1185: @subsection Registers That Form a Stack
1186:
1187: There are special features to handle computers where some of the
1188: ``registers'' form a stack, as in the 80387 coprocessor for the 80386.
1189: Stack registers are normally written by pushing onto the stack, and are
1190: numbered relative to the top of the stack.
1191:
1192: Currently, GNU CC can only handle one group of stack-like registers, and
1193: they must be consecutively numbered.
1194:
1195: @table @code
1196: @findex STACK_REGS
1197: @item STACK_REGS
1198: Define this if the machine has any stack-like registers.
1199:
1200: @findex FIRST_STACK_REG
1201: @item FIRST_STACK_REG
1202: The number of the first stack-like register. This one is the top
1203: of the stack.
1204:
1205: @findex LAST_STACK_REG
1206: @item LAST_STACK_REG
1207: The number of the last stack-like register. This one is the bottom of
1208: the stack.
1209: @end table
1210:
1211: @node Obsolete Register Macros
1212: @subsection Obsolete Macros for Controlling Register Usage
1213:
1214: These features do not work very well. They exist because they used to
1215: be required to generate correct code for the 80387 coprocessor of the
1216: 80386. They are no longer used by that machine description and may be
1217: removed in a later version of the compiler. Don't use them!
1218:
1219: @table @code
1220: @findex OVERLAPPING_REGNO_P
1221: @item OVERLAPPING_REGNO_P (@var{regno})
1222: If defined, this is a C expression whose value is nonzero if hard
1223: register number @var{regno} is an overlapping register. This means a
1224: hard register which overlaps a hard register with a different number.
1225: (Such overlap is undesirable, but occasionally it allows a machine to
1226: be supported which otherwise could not be.) This macro must return
1227: nonzero for @emph{all} the registers which overlap each other. GNU CC
1228: can use an overlapping register only in certain limited ways. It can
1229: be used for allocation within a basic block, and may be spilled for
1230: reloading; that is all.
1231:
1232: If this macro is not defined, it means that none of the hard registers
1233: overlap each other. This is the usual situation.
1234:
1235: @findex INSN_CLOBBERS_REGNO_P
1236: @item INSN_CLOBBERS_REGNO_P (@var{insn}, @var{regno})
1237: If defined, this is a C expression whose value should be nonzero if
1238: the insn @var{insn} has the effect of mysteriously clobbering the
1239: contents of hard register number @var{regno}. By ``mysterious'' we
1240: mean that the insn's RTL expression doesn't describe such an effect.
1241:
1242: If this macro is not defined, it means that no insn clobbers registers
1243: mysteriously. This is the usual situation; all else being equal,
1244: it is best for the RTL expression to show all the activity.
1245:
1246: @cindex death notes
1247: @findex PRESERVE_DEATH_INFO_REGNO_P
1248: @item PRESERVE_DEATH_INFO_REGNO_P (@var{regno})
1249: If defined, this is a C expression whose value is nonzero if accurate
1250: @code{REG_DEAD} notes are needed for hard register number @var{regno}
1251: at the time of outputting the assembler code. When this is so, a few
1252: optimizations that take place after register allocation and could
1253: invalidate the death notes are not done when this register is
1254: involved.
1255:
1256: You would arrange to preserve death info for a register when some of the
1257: code in the machine description which is executed to write the assembler
1258: code looks at the death notes. This is necessary only when the actual
1259: hardware feature which GNU CC thinks of as a register is not actually a
1260: register of the usual sort. (It might, for example, be a hardware
1261: stack.)
1262:
1263: If this macro is not defined, it means that no death notes need to be
1264: preserved. This is the usual situation.
1265: @end table
1266:
1267: @node Register Classes, Stack and Calling, Registers, Machine Macros
1268: @section Register Classes
1269: @cindex register class definitions
1270: @cindex class definitions, register
1271:
1272: On many machines, the numbered registers are not all equivalent.
1273: For example, certain registers may not be allowed for indexed addressing;
1274: certain registers may not be allowed in some instructions. These machine
1275: restrictions are described to the compiler using @dfn{register classes}.
1276:
1277: You define a number of register classes, giving each one a name and saying
1278: which of the registers belong to it. Then you can specify register classes
1279: that are allowed as operands to particular instruction patterns.
1280:
1281: @findex ALL_REGS
1282: @findex NO_REGS
1283: In general, each register will belong to several classes. In fact, one
1284: class must be named @code{ALL_REGS} and contain all the registers. Another
1285: class must be named @code{NO_REGS} and contain no registers. Often the
1286: union of two classes will be another class; however, this is not required.
1287:
1288: @findex GENERAL_REGS
1289: One of the classes must be named @code{GENERAL_REGS}. There is nothing
1290: terribly special about the name, but the operand constraint letters
1291: @samp{r} and @samp{g} specify this class. If @code{GENERAL_REGS} is
1292: the same as @code{ALL_REGS}, just define it as a macro which expands
1293: to @code{ALL_REGS}.
1294:
1295: Order the classes so that if class @var{x} is contained in class @var{y}
1296: then @var{x} has a lower class number than @var{y}.
1297:
1298: The way classes other than @code{GENERAL_REGS} are specified in operand
1299: constraints is through machine-dependent operand constraint letters.
1300: You can define such letters to correspond to various classes, then use
1301: them in operand constraints.
1302:
1303: You should define a class for the union of two classes whenever some
1304: instruction allows both classes. For example, if an instruction allows
1305: either a floating point (coprocessor) register or a general register for a
1306: certain operand, you should define a class @code{FLOAT_OR_GENERAL_REGS}
1307: which includes both of them. Otherwise you will get suboptimal code.
1308:
1309: You must also specify certain redundant information about the register
1310: classes: for each class, which classes contain it and which ones are
1311: contained in it; for each pair of classes, the largest class contained
1312: in their union.
1313:
1314: When a value occupying several consecutive registers is expected in a
1315: certain class, all the registers used must belong to that class.
1316: Therefore, register classes cannot be used to enforce a requirement for
1317: a register pair to start with an even-numbered register. The way to
1318: specify this requirement is with @code{HARD_REGNO_MODE_OK}.
1319:
1320: Register classes used for input-operands of bitwise-and or shift
1321: instructions have a special requirement: each such class must have, for
1322: each fixed-point machine mode, a subclass whose registers can transfer that
1323: mode to or from memory. For example, on some machines, the operations for
1324: single-byte values (@code{QImode}) are limited to certain registers. When
1325: this is so, each register class that is used in a bitwise-and or shift
1326: instruction must have a subclass consisting of registers from which
1327: single-byte values can be loaded or stored. This is so that
1328: @code{PREFERRED_RELOAD_CLASS} can always have a possible value to return.
1329:
1330: @table @code
1331: @findex enum reg_class
1332: @item enum reg_class
1333: An enumeral type that must be defined with all the register class names
1334: as enumeral values. @code{NO_REGS} must be first. @code{ALL_REGS}
1335: must be the last register class, followed by one more enumeral value,
1336: @code{LIM_REG_CLASSES}, which is not a register class but rather
1337: tells how many classes there are.
1338:
1339: Each register class has a number, which is the value of casting
1340: the class name to type @code{int}. The number serves as an index
1341: in many of the tables described below.
1342:
1343: @findex N_REG_CLASSES
1344: @item N_REG_CLASSES
1345: The number of distinct register classes, defined as follows:
1346:
1347: @example
1348: #define N_REG_CLASSES (int) LIM_REG_CLASSES
1349: @end example
1350:
1351: @findex REG_CLASS_NAMES
1352: @item REG_CLASS_NAMES
1353: An initializer containing the names of the register classes as C string
1354: constants. These names are used in writing some of the debugging dumps.
1355:
1356: @findex REG_CLASS_CONTENTS
1357: @item REG_CLASS_CONTENTS
1358: An initializer containing the contents of the register classes, as integers
1359: which are bit masks. The @var{n}th integer specifies the contents of class
1360: @var{n}. The way the integer @var{mask} is interpreted is that
1361: register @var{r} is in the class if @code{@var{mask} & (1 << @var{r})} is 1.
1362:
1363: When the machine has more than 32 registers, an integer does not suffice.
1364: Then the integers are replaced by sub-initializers, braced groupings containing
1365: several integers. Each sub-initializer must be suitable as an initializer
1366: for the type @code{HARD_REG_SET} which is defined in @file{hard-reg-set.h}.
1367:
1368: @findex REGNO_REG_CLASS
1369: @item REGNO_REG_CLASS (@var{regno})
1370: A C expression whose value is a register class containing hard register
1371: @var{regno}. In general there is more that one such class; choose a class
1372: which is @dfn{minimal}, meaning that no smaller class also contains the
1373: register.
1374:
1375: @findex BASE_REG_CLASS
1376: @item BASE_REG_CLASS
1377: A macro whose definition is the name of the class to which a valid
1378: base register must belong. A base register is one used in an address
1379: which is the register value plus a displacement.
1380:
1381: @findex INDEX_REG_CLASS
1382: @item INDEX_REG_CLASS
1383: A macro whose definition is the name of the class to which a valid
1384: index register must belong. An index register is one used in an
1385: address where its value is either multiplied by a scale factor or
1386: added to another register (as well as added to a displacement).
1387:
1388: @findex REG_CLASS_FROM_LETTER
1389: @item REG_CLASS_FROM_LETTER (@var{char})
1390: A C expression which defines the machine-dependent operand constraint
1391: letters for register classes. If @var{char} is such a letter, the
1392: value should be the register class corresponding to it. Otherwise,
1393: the value should be @code{NO_REGS}.
1394:
1395: @findex REGNO_OK_FOR_BASE_P
1396: @item REGNO_OK_FOR_BASE_P (@var{num})
1397: A C expression which is nonzero if register number @var{num} is
1398: suitable for use as a base register in operand addresses. It may be
1399: either a suitable hard register or a pseudo register that has been
1400: allocated such a hard register.
1401:
1402: @findex REGNO_OK_FOR_INDEX_P
1403: @item REGNO_OK_FOR_INDEX_P (@var{num})
1404: A C expression which is nonzero if register number @var{num} is
1405: suitable for use as an index register in operand addresses. It may be
1406: either a suitable hard register or a pseudo register that has been
1407: allocated such a hard register.
1408:
1409: The difference between an index register and a base register is that
1410: the index register may be scaled. If an address involves the sum of
1411: two registers, neither one of them scaled, then either one may be
1412: labeled the ``base'' and the other the ``index''; but whichever
1413: labeling is used must fit the machine's constraints of which registers
1414: may serve in each capacity. The compiler will try both labelings,
1415: looking for one that is valid, and will reload one or both registers
1416: only if neither labeling works.
1417:
1418: @findex PREFERRED_RELOAD_CLASS
1419: @item PREFERRED_RELOAD_CLASS (@var{x}, @var{class})
1420: A C expression that places additional restrictions on the register class
1421: to use when it is necessary to copy value @var{x} into a register in class
1422: @var{class}. The value is a register class; perhaps @var{class}, or perhaps
1423: another, smaller class. On many machines, the definition
1424:
1425: @example
1426: #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
1427: @end example
1428:
1429: @noindent
1430: is safe.
1431:
1432: Sometimes returning a more restrictive class makes better code. For
1433: example, on the 68000, when @var{x} is an integer constant that is in range
1434: for a @samp{moveq} instruction, the value of this macro is always
1435: @code{DATA_REGS} as long as @var{class} includes the data registers.
1436: Requiring a data register guarantees that a @samp{moveq} will be used.
1437:
1438: If @var{x} is a @code{const_double}, by returning @code{NO_REGS}
1439: you can force @var{x} into a memory constant. This is useful on
1440: certain machines where immediate floating values cannot be loaded into
1441: certain kinds of registers.
1442:
1443: @findex LIMIT_RELOAD_CLASS
1444: @item LIMIT_RELOAD_CLASS (@var{mode}, @var{class})
1445: A C expression that places additional restrictions on the register class
1446: to use when it is necessary to be able to hold a value of mode
1447: @var{mode} in a reload register for which class @var{class} would
1448: ordinarily be used.
1449:
1450: Unlike @code{PREFERRED_RELOAD_CLASS}, this macro should be used when
1451: there are certain modes that simply can't go in certain reload classes.
1452:
1453: The value is a register class; perhaps @var{class}, or perhaps another,
1454: smaller class.
1455:
1456: Don't define this macro unless the target machine has limitations which
1457: require the macro to do something nontrivial.
1458:
1459: @findex SECONDARY_RELOAD_CLASS
1460: @findex SECONDARY_INPUT_RELOAD_CLASS
1461: @findex SECONDARY_OUTPUT_RELOAD_CLASS
1462: @item SECONDARY_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
1463: @itemx SECONDARY_INPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
1464: @itemx SECONDARY_OUTPUT_RELOAD_CLASS (@var{class}, @var{mode}, @var{x})
1465: Many machines have some registers that cannot be copied directly to or
1466: from memory or even from other types of registers. An example is the
1467: @samp{MQ} register, which on most machines, can only be copied to or
1468: from general registers, but not memory. Some machines allow copying all
1469: registers to and from memory, but require a scratch register for stores
1470: to some memory locations (e.g., those with symbolic address on the RT,
1471: and those with certain symbolic address on the Sparc when compiling
1472: PIC). In some cases, both an intermediate and a scratch register are
1473: required.
1474:
1475: You should define these macros to indicate to the reload phase that it may
1476: need to allocate at least one register for a reload in addition to the
1477: register to contain the data. Specifically, if copying @var{x} to a
1478: register @var{class} in @var{mode} requires an intermediate register,
1479: you should define @code{SECONDARY_INPUT_RELOAD_CLASS} to return the
1480: largest register class all of whose registers can be used as
1481: intermediate registers or scratch registers.
1482:
1483: If copying a register @var{class} in @var{mode} to @var{x} requires an
1484: intermediate or scratch register, you should define
1485: @code{SECONDARY_OUTPUT_RELOAD_CLASS} to return the largest register
1486: class required. If the requirements for input and output reloads are
1487: the same, the macro @code{SECONDARY_RELOAD_CLASS} should be used instead
1488: of defining both macros identically.
1489:
1490: The values returned by these macros are often @code{GENERAL_REGS}.
1491: Return @code{NO_REGS} if no spare register is needed; i.e., if @var{x}
1492: can be directly copied to or from a register of @var{class} in
1493: @var{mode} without requiring a scratch register. Do not define this
1494: macro if it would always return @code{NO_REGS}.
1495:
1496: If a scratch register is required (either with or without an
1497: intermediate register), you should define patterns for
1498: @samp{reload_in@var{m}} or @samp{reload_out@var{m}}, as required
1499: (@pxref{Standard Names}. These patterns, which will normally be
1500: implemented with a @code{define_expand}, should be similar to the
1501: @samp{mov@var{m}} patterns, except that operand 2 is the scratch
1502: register.
1503:
1504: Define constraints for the reload register and scratch register that
1505: contain a single register class. If the original reload register (whose
1506: class is @var{class}) can meet the constraint given in the pattern, the
1507: value returned by these macros is used for the class of the scratch
1508: register. Otherwise, two additional reload registers are required.
1509: Their classes are obtained from the constraints in the insn pattern.
1510:
1511: @var{x} might be a pseudo-register or a @code{subreg} of a
1512: pseudo-register, which could either be in a hard register or in memory.
1513: Use @code{true_regnum} to find out; it will return -1 if the pseudo is
1514: in memory and the hard register number if it is in a register.
1515:
1516: These macros should not be used in the case where a particular class of
1517: registers can only be copied to memory and not to another class of
1518: registers. In that case, secondary reload registers are not needed and
1519: would not be helpful. Instead, a stack location must be used to perform
1520: the copy and the @code{mov@var{m}} pattern should use memory as a
1521: intermediate storage. This case often occurs between floating-point and
1522: general registers.
1523:
1524: @findex SMALL_REGISTER_CLASSES
1525: @item SMALL_REGISTER_CLASSES
1526: Normally the compiler will avoid choosing spill registers from registers
1527: that have been explicitly mentioned in the rtl (these registers are
1528: normally those used to pass parameters and return values). However,
1529: some machines have so few registers of certain classes that there would
1530: not be enough registers to use as spill registers if this were done.
1531:
1532: On those machines, you should define @code{SMALL_REGISTER_CLASSES}.
1533: When it is defined, the compiler allows registers explicitly used in the
1534: rtl to be used as spill registers but prevents the compiler from
1535: extending the lifetime of these registers.
1536:
1537: Defining this macro is always safe, but unnecessarily defining this macro
1538: will reduce the amount of optimizations that can be performed in some
1539: cases. If this macro is not defined but needs to be, the compiler will
1540: run out of reload registers and print a fatal error message.
1541:
1542: For most machines, this macro should not be defined.
1543:
1544: @findex CLASS_MAX_NREGS
1545: @item CLASS_MAX_NREGS (@var{class}, @var{mode})
1546: A C expression for the maximum number of consecutive registers
1547: of class @var{class} needed to hold a value of mode @var{mode}.
1548:
1549: This is closely related to the macro @code{HARD_REGNO_NREGS}.
1550: In fact, the value of the macro @code{CLASS_MAX_NREGS (@var{class}, @var{mode})}
1551: should be the maximum value of @code{HARD_REGNO_NREGS (@var{regno}, @var{mode})}
1552: for all @var{regno} values in the class @var{class}.
1553:
1554: This macro helps control the handling of multiple-word values
1555: in the reload pass.
1556: @end table
1557:
1558: Three other special macros describe which operands fit which constraint
1559: letters.
1560:
1561: @table @code
1562: @findex CONST_OK_FOR_LETTER_P
1563: @item CONST_OK_FOR_LETTER_P (@var{value}, @var{c})
1564: A C expression that defines the machine-dependent operand constraint letters
1565: that specify particular ranges of integer values. If @var{c} is one
1566: of those letters, the expression should check that @var{value}, an integer,
1567: is in the appropriate range and return 1 if so, 0 otherwise. If @var{c} is
1568: not one of those letters, the value should be 0 regardless of @var{value}.
1569:
1570: @findex CONST_DOUBLE_OK_FOR_LETTER_P
1571: @item CONST_DOUBLE_OK_FOR_LETTER_P (@var{value}, @var{c})
1572: A C expression that defines the machine-dependent operand constraint
1573: letters that specify particular ranges of @code{const_double} values.
1574:
1575: If @var{c} is one of those letters, the expression should check that
1576: @var{value}, an RTX of code @code{const_double}, is in the appropriate
1577: range and return 1 if so, 0 otherwise. If @var{c} is not one of those
1578: letters, the value should be 0 regardless of @var{value}.
1579:
1580: @code{const_double} is used for all floating-point constants and for
1581: @code{DImode} fixed-point constants. A given letter can accept either
1582: or both kinds of values. It can use @code{GET_MODE} to distinguish
1583: between these kinds.
1584:
1585: @findex EXTRA_CONSTRAINT
1586: @item EXTRA_CONSTRAINT (@var{value}, @var{c})
1587: A C expression that defines the optional machine-dependent constraint
1588: letters that can be used to segregate specific types of operands,
1589: usually memory references, for the target machine. Normally this macro
1590: will not be defined. If it is required for a particular target machine,
1591: it should return 1 if @var{value} corresponds to the operand type
1592: represented by the constraint letter @var{c}. If @var{c} is not defined
1593: as an extra constraint, the value returned should be 0 regardless of
1594: @var{value}.
1595:
1596: For example, on the ROMP, load instructions cannot have their output in r0 if
1597: the memory reference contains a symbolic address. Constraint letter
1598: @samp{Q} is defined as representing a memory address that does
1599: @emph{not} contain a symbolic address. An alternative is specified with
1600: a @samp{Q} constraint on the input and @samp{r} on the output. The next
1601: alternative specifies @samp{m} on the input and a register class that
1602: does not include r0 on the output.
1603: @end table
1604:
1605: @node Stack and Calling, Varargs, Register Classes, Machine Macros
1606: @section Describing Stack Layout and Calling Conventions
1607: @cindex calling conventions
1608:
1609: @menu
1610: * Frame Layout::
1611: * Frame Registers::
1612: * Elimination::
1613: * Stack Arguments::
1614: * Register Arguments::
1615: * Scalar Return::
1616: * Aggregate Return::
1617: * Caller Saves::
1618: * Function Entry::
1619: * Profiling::
1620: @end menu
1621:
1622: @node Frame Layout
1623: @subsection Basic Stack Layout
1624: @cindex stack frame layout
1625: @cindex frame layout
1626:
1627: @table @code
1628: @findex STACK_GROWS_DOWNWARD
1629: @item STACK_GROWS_DOWNWARD
1630: Define this macro if pushing a word onto the stack moves the stack
1631: pointer to a smaller address.
1632:
1633: When we say, ``define this macro if @dots{},'' it means that the
1634: compiler checks this macro only with @code{#ifdef} so the precise
1635: definition used does not matter.
1636:
1637: @findex FRAME_GROWS_DOWNWARD
1638: @item FRAME_GROWS_DOWNWARD
1639: Define this macro if the addresses of local variable slots are at negative
1640: offsets from the frame pointer.
1641:
1642: @findex ARGS_GROW_DOWNWARD
1643: @item ARGS_GROW_DOWNWARD
1644: Define this macro if successive arguments to a function occupy decreasing
1645: addresses on the stack.
1646:
1647: @findex STARTING_FRAME_OFFSET
1648: @item STARTING_FRAME_OFFSET
1649: Offset from the frame pointer to the first local variable slot to be allocated.
1650:
1651: If @code{FRAME_GROWS_DOWNWARD}, the next slot's offset is found by
1652: subtracting the length of the first slot from @code{STARTING_FRAME_OFFSET}.
1653: Otherwise, it is found by adding the length of the first slot to
1654: the value @code{STARTING_FRAME_OFFSET}.
1655:
1656: @findex STACK_POINTER_OFFSET
1657: @item STACK_POINTER_OFFSET
1658: Offset from the stack pointer register to the first location at which
1659: outgoing arguments are placed. If not specified, the default value of
1660: zero is used. This is the proper value for most machines.
1661:
1662: If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above
1663: the first location at which outgoing arguments are placed.
1664:
1665: @findex FIRST_PARM_OFFSET
1666: @item FIRST_PARM_OFFSET (@var{fundecl})
1667: Offset from the argument pointer register to the first argument's
1668: address. On some machines it may depend on the data type of the
1669: function.
1670:
1671: If @code{ARGS_GROW_DOWNWARD}, this is the offset to the location above
1672: the first argument's address.
1673:
1674: @findex STACK_DYNAMIC_OFFSET
1675: @item STACK_DYNAMIC_OFFSET (@var{fundecl})
1676: Offset from the stack pointer register to an item dynamically allocated
1677: on the stack, e.g., by @code{alloca}.
1678:
1679: The default value for this macro is @code{STACK_POINTER_OFFSET} plus the
1680: length of the outgoing arguments. The default is correct for most
1681: machines. See @file{function.c} for details.
1682:
1683: @findex DYNAMIC_CHAIN_ADDRESS
1684: @item DYNAMIC_CHAIN_ADDRESS (@var{frameaddr})
1685: A C expression whose value is RTL representing the address in a stack
1686: frame where the pointer to the caller's frame is stored. Assume that
1687: @var{frameaddr} is an RTL expression for the address of the stack frame
1688: itself.
1689:
1690: If you don't define this macro, the default is to return the value
1691: of @var{frameaddr}---that is, the stack frame address is also the
1692: address of the stack word that points to the previous frame.
1693: @end table
1694:
1695: @node Frame Registers
1696: @subsection Registers That Address the Stack Frame
1697:
1698: @table @code
1699: @findex STACK_POINTER_REGNUM
1700: @item STACK_POINTER_REGNUM
1701: The register number of the stack pointer register, which must also be a
1702: fixed register according to @code{FIXED_REGISTERS}. On most machines,
1703: the hardware determines which register this is.
1704:
1705: @findex FRAME_POINTER_REGNUM
1706: @item FRAME_POINTER_REGNUM
1707: The register number of the frame pointer register, which is used to
1708: access automatic variables in the stack frame. On some machines, the
1709: hardware determines which register this is. On other machines, you can
1710: choose any register you wish for this purpose.
1711:
1712: @findex ARG_POINTER_REGNUM
1713: @item ARG_POINTER_REGNUM
1714: The register number of the arg pointer register, which is used to access
1715: the function's argument list. On some machines, this is the same as the
1716: frame pointer register. On some machines, the hardware determines which
1717: register this is. On other machines, you can choose any register you
1718: wish for this purpose. If this is not the same register as the frame
1719: pointer register, then you must mark it as a fixed register according to
1720: @code{FIXED_REGISTERS}, or arrange to be able to eliminate it
1721: (@pxref{Elimination}).
1722:
1723: @findex STATIC_CHAIN_REGNUM
1724: @findex STATIC_CHAIN_INCOMING_REGNUM
1725: @item STATIC_CHAIN_REGNUM
1726: @itemx STATIC_CHAIN_INCOMING_REGNUM
1727: Register numbers used for passing a function's static chain
1728: pointer. If register windows are used, @code{STATIC_CHAIN_INCOMING_REGNUM}
1729: is the register number as seen by the called function, while
1730: @code{STATIC_CHAIN_REGNUM} is the register number as seen by the calling
1731: function. If these registers are the same,
1732: @code{STATIC_CHAIN_INCOMING_REGNUM} need not be defined.@refill
1733:
1734: The static chain register need not be a fixed register.
1735:
1736: If the static chain is passed in memory, these macros should not be
1737: defined; instead, the next two macros should be defined.
1738:
1739: @findex STATIC_CHAIN
1740: @findex STATIC_CHAIN_INCOMING
1741: @item STATIC_CHAIN
1742: @itemx STATIC_CHAIN_INCOMING
1743: If the static chain is passed in memory, these macros provide rtx giving
1744: @code{mem} expressions that denote where they are stored.
1745: @code{STATIC_CHAIN} and @code{STATIC_CHAIN_INCOMING} give the locations
1746: as seen by the calling and called functions, respectively. Often the former
1747: will be at an offset from the stack pointer and the latter at an offset from
1748: the frame pointer.@refill
1749:
1750: @findex stack_pointer_rtx
1751: @findex frame_pointer_rtx
1752: @findex arg_pointer_rtx
1753: The variables @code{stack_pointer_rtx}, @code{frame_pointer_rtx}, and
1754: @code{arg_pointer_rtx} will have been initialized prior to the use of these
1755: macros and should be used to refer to those items.
1756:
1757: If the static chain is passed in a register, the two previous macros should
1758: be defined instead.
1759: @end table
1760:
1761: @node Elimination
1762: @subsection Eliminating Frame Pointer and Arg Pointer
1763:
1764: @table @code
1765: @findex FRAME_POINTER_REQUIRED
1766: @item FRAME_POINTER_REQUIRED
1767: A C expression which is nonzero if a function must have and use a frame
1768: pointer. This expression is evaluated in the reload pass. If its value is
1769: nonzero the function will have a frame pointer.
1770:
1771: The expression can in principle examine the current function and decide
1772: according to the facts, but on most machines the constant 0 or the
1773: constant 1 suffices. Use 0 when the machine allows code to be generated
1774: with no frame pointer, and doing so saves some time or space. Use 1
1775: when there is no possible advantage to avoiding a frame pointer.
1776:
1777: In certain cases, the compiler does not know how to produce valid code
1778: without a frame pointer. The compiler recognizes those cases and
1779: automatically gives the function a frame pointer regardless of what
1780: @code{FRAME_POINTER_REQUIRED} says. You don't need to worry about
1781: them.@refill
1782:
1783: In a function that does not require a frame pointer, the frame pointer
1784: register can be allocated for ordinary usage, unless you mark it as a
1785: fixed register. See @code{FIXED_REGISTERS} for more information.
1786:
1787: This macro is ignored and need not be defined if @code{ELIMINABLE_REGS}
1788: is defined.
1789:
1790: @findex INITIAL_FRAME_POINTER_OFFSET
1791: @findex get_frame_size
1792: @item INITIAL_FRAME_POINTER_OFFSET (@var{depth-var})
1793: A C statement to store in the variable @var{depth-var} the difference
1794: between the frame pointer and the stack pointer values immediately after
1795: the function prologue. The value would be computed from information
1796: such as the result of @code{get_frame_size ()} and the tables of
1797: registers @code{regs_ever_live} and @code{call_used_regs}.
1798:
1799: If @code{ELIMINABLE_REGS} is defined, this macro will be not be used and
1800: need not be defined. Otherwise, it must be defined even if
1801: @code{FRAME_POINTER_REQUIRED} is defined to always be true; in that
1802: case, you may set @var{depth-var} to anything.
1803:
1804: @findex ELIMINABLE_REGS
1805: @item ELIMINABLE_REGS
1806: If defined, this macro specifies a table of register pairs used to
1807: eliminate unneeded registers that point into the stack frame. If it is not
1808: defined, the only elimination attempted by the compiler is to replace
1809: references to the frame pointer with references to the stack pointer.
1810:
1811: The definition of this macro is a list of structure initializations, each
1812: of which specifies an original and replacement register.
1813:
1814: On some machines, the position of the argument pointer is not known until
1815: the compilation is completed. In such a case, a separate hard register
1816: must be used for the argument pointer. This register can be eliminated by
1817: replacing it with either the frame pointer or the argument pointer,
1818: depending on whether or not the frame pointer has been eliminated.
1819:
1820: In this case, you might specify:
1821: @example
1822: #define ELIMINABLE_REGS \
1823: @{@{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM@}, \
1824: @{ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM@}, \
1825: @{FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM@}@}
1826: @end example
1827:
1828: Note that the elimination of the argument pointer with the stack pointer is
1829: specified first since that is the preferred elimination.
1830:
1831: @findex CAN_ELIMINATE
1832: @item CAN_ELIMINATE (@var{from-reg}, @var{to-reg})
1833: A C expression that returns non-zero if the compiler is allowed to try
1834: to replace register number @var{from-reg} with register number
1835: @var{to-reg}. This macro need only be defined if @code{ELIMINABLE_REGS}
1836: is defined, and will usually be the constant 1, since most of the cases
1837: preventing register elimination are things that the compiler already
1838: knows about.
1839:
1840: @findex INITIAL_ELIMINATION_OFFSET
1841: @item INITIAL_ELIMINATION_OFFSET (@var{from-reg}, @var{to-reg}, @var{offset-var})
1842: This macro is similar to @code{INITIAL_FRAME_POINTER_OFFSET}. It
1843: specifies the initial difference between the specified pair of
1844: registers. This macro must be defined if @code{ELIMINABLE_REGS} is
1845: defined.
1846:
1847: @findex LONGJMP_RESTORE_FROM_STACK
1848: @item LONGJMP_RESTORE_FROM_STACK
1849: Define this macro if the @code{longjmp} function restores registers from
1850: the stack frames, rather than from those saved specifically by
1851: @code{setjmp}. Certain quantities must not be kept in registers across
1852: a call to @code{setjmp} on such machines.
1853: @end table
1854:
1855: @node Stack Arguments
1856: @subsection Passing Function Arguments on the Stack
1857: @cindex arguments on stack
1858: @cindex stack arguments
1859:
1860: The macros in this section control how arguments are passed
1861: on the stack. See the following section for other macros that
1862: control passing certain arguments in registers.
1863:
1864: @table @code
1865: @findex PROMOTE_PROTOTYPES
1866: @item PROMOTE_PROTOTYPES
1867: Define this macro if an argument declared as @code{char} or
1868: @code{short} in a prototype should actually be passed as an
1869: @code{int}. In addition to avoiding errors in certain cases of
1870: mismatch, it also makes for better code on certain machines.
1871:
1872: @findex PUSH_ROUNDING
1873: @item PUSH_ROUNDING (@var{npushed})
1874: A C expression that is the number of bytes actually pushed onto the
1875: stack when an instruction attempts to push @var{npushed} bytes.
1876:
1877: If the target machine does not have a push instruction, do not define
1878: this macro. That directs GNU CC to use an alternate strategy: to
1879: allocate the entire argument block and then store the arguments into
1880: it.
1881:
1882: On some machines, the definition
1883:
1884: @example
1885: #define PUSH_ROUNDING(BYTES) (BYTES)
1886: @end example
1887:
1888: @noindent
1889: will suffice. But on other machines, instructions that appear
1890: to push one byte actually push two bytes in an attempt to maintain
1891: alignment. Then the definition should be
1892:
1893: @example
1894: #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
1895: @end example
1896:
1897: @findex ACCUMULATE_OUTGOING_ARGS
1898: @findex current_function_outgoing_args_size
1899: @item ACCUMULATE_OUTGOING_ARGS
1900: If defined, the maximum amount of space required for outgoing arguments
1901: will be computed and placed into the variable
1902: @code{current_function_outgoing_args_size}. No space will be pushed
1903: onto the stack for each call; instead, the function prologue should
1904: increase the stack frame size by this amount.
1905:
1906: It is not proper to define both @code{PUSH_ROUNDING} and
1907: @code{ACCUMULATE_OUTGOING_ARGS}.
1908:
1909: @findex REG_PARM_STACK_SPACE
1910: @item REG_PARM_STACK_SPACE
1911: Define this macro if functions should assume that stack space has been
1912: allocated for arguments even when their values are passed in
1913: registers.
1914:
1915: The value of this macro is the size, in bytes, of the area reserved for
1916: arguments passed in registers.
1917:
1918: This space can either be allocated by the caller or be a part of the
1919: machine-dependent stack frame: @code{OUTGOING_REG_PARM_STACK_SPACE}
1920: says which.
1921:
1922: @findex OUTGOING_REG_PARM_STACK_SPACE
1923: @item OUTGOING_REG_PARM_STACK_SPACE
1924: Define this if it is the responsibility of the caller to allocate the area
1925: reserved for arguments passed in registers.
1926:
1927: If @code{ACCUMULATE_OUTGOING_ARGS} is defined, this macro controls
1928: whether the space for these arguments counts in the value of
1929: @code{current_function_outgoing_args_size}.
1930:
1931: @findex STACK_PARMS_IN_REG_PARM_AREA
1932: @item STACK_PARMS_IN_REG_PARM_AREA
1933: Define this macro if @code{REG_PARM_STACK_SPACE} is defined but stack
1934: parameters don't skip the area specified by @code{REG_PARM_STACK_SPACE}.
1935:
1936: Normally, when a parameter is not passed in registers, it is placed on the
1937: stack beyond the @code{REG_PARM_STACK_SPACE} area. Defining this macro
1938: suppresses this behavior and causes the parameter to be passed on the
1939: stack in its natural location.
1940:
1941: @findex RETURN_POPS_ARGS
1942: @item RETURN_POPS_ARGS (@var{funtype}, @var{stack-size})
1943: A C expression that should indicate the number of bytes of its own
1944: arguments that a function pops on returning, or 0 if the
1945: function pops no arguments and the caller must therefore pop them all
1946: after the function returns.
1947:
1948: @var{funtype} is a C variable whose value is a tree node that
1949: describes the function in question. Normally it is a node of type
1950: @code{FUNCTION_TYPE} that describes the data type of the function.
1951: From this it is possible to obtain the data types of the value and
1952: arguments (if known).
1953:
1954: When a call to a library function is being considered, @var{funtype}
1955: will contain an identifier node for the library function. Thus, if
1956: you need to distinguish among various library functions, you can do so
1957: by their names. Note that ``library function'' in this context means
1958: a function used to perform arithmetic, whose name is known specially
1959: in the compiler and was not mentioned in the C code being compiled.
1960:
1961: @var{stack-size} is the number of bytes of arguments passed on the
1962: stack. If a variable number of bytes is passed, it is zero, and
1963: argument popping will always be the responsibility of the calling function.
1964:
1965: On the Vax, all functions always pop their arguments, so the definition
1966: of this macro is @var{stack-size}. On the 68000, using the standard
1967: calling convention, no functions pop their arguments, so the value of
1968: the macro is always 0 in this case. But an alternative calling
1969: convention is available in which functions that take a fixed number of
1970: arguments pop them but other functions (such as @code{printf}) pop
1971: nothing (the caller pops all). When this convention is in use,
1972: @var{funtype} is examined to determine whether a function takes a fixed
1973: number of arguments.
1974: @end table
1975:
1976: @node Register Arguments
1977: @subsection Passing Arguments in Registers
1978: @cindex arguments in registers
1979: @cindex registers arguments
1980:
1981: This section describes the macros which let you control how various
1982: types of arguments are passed in registers or how they are arranged in
1983: the stack.
1984:
1985: @table @code
1986: @findex FUNCTION_ARG
1987: @item FUNCTION_ARG (@var{cum}, @var{mode}, @var{type}, @var{named})
1988: A C expression that controls whether a function argument is passed
1989: in a register, and which register.
1990:
1991: The arguments are @var{cum}, which summarizes all the previous
1992: arguments; @var{mode}, the machine mode of the argument; @var{type},
1993: the data type of the argument as a tree node or 0 if that is not known
1994: (which happens for C support library functions); and @var{named},
1995: which is 1 for an ordinary argument and 0 for nameless arguments that
1996: correspond to @samp{@dots{}} in the called function's prototype.
1997:
1998: The value of the expression should either be a @code{reg} RTX for the
1999: hard register in which to pass the argument, or zero to pass the
2000: argument on the stack.
2001:
2002: For machines like the Vax and 68000, where normally all arguments are
2003: pushed, zero suffices as a definition.
2004:
2005: @cindex @file{stdarg.h} and register arguments
2006: The usual way to make the ANSI library @file{stdarg.h} work on a machine
2007: where some arguments are usually passed in registers, is to cause
2008: nameless arguments to be passed on the stack instead. This is done
2009: by making @code{FUNCTION_ARG} return 0 whenever @var{named} is 0.
2010:
2011: @cindex @code{MUST_PASS_IN_STACK}, and @code{FUNCTION_ARG}
2012: @cindex @code{REG_PARM_STACK_SPACE}, and @code{FUNCTION_ARG}
2013: You may use the macro @code{MUST_PASS_IN_STACK (@var{mode}, @var{type})}
2014: in the definition of this macro to determine if this argument is of a
2015: type that must be passed in the stack. If @code{REG_PARM_STACK_SPACE}
2016: is not defined and @code{FUNCTION_ARG} returns non-zero for such an
2017: argument, the compiler will abort. If @code{REG_PARM_STACK_SPACE} is
2018: defined, the argument will be computed in the stack and then loaded into
2019: a register.
2020:
2021: @findex FUNCTION_INCOMING_ARG
2022: @item FUNCTION_INCOMING_ARG (@var{cum}, @var{mode}, @var{type}, @var{named})
2023: Define this macro if the target machine has ``register windows'', so
2024: that the register in which a function sees an arguments is not
2025: necessarily the same as the one in which the caller passed the
2026: argument.
2027:
2028: For such machines, @code{FUNCTION_ARG} computes the register in which
2029: the caller passes the value, and @code{FUNCTION_INCOMING_ARG} should
2030: be defined in a similar fashion to tell the function being called
2031: where the arguments will arrive.
2032:
2033: If @code{FUNCTION_INCOMING_ARG} is not defined, @code{FUNCTION_ARG}
2034: serves both purposes.@refill
2035:
2036: @findex FUNCTION_ARG_PARTIAL_NREGS
2037: @item FUNCTION_ARG_PARTIAL_NREGS (@var{cum}, @var{mode}, @var{type}, @var{named})
2038: A C expression for the number of words, at the beginning of an
2039: argument, must be put in registers. The value must be zero for
2040: arguments that are passed entirely in registers or that are entirely
2041: pushed on the stack.
2042:
2043: On some machines, certain arguments must be passed partially in
2044: registers and partially in memory. On these machines, typically the
2045: first @var{n} words of arguments are passed in registers, and the rest
2046: on the stack. If a multi-word argument (a @code{double} or a
2047: structure) crosses that boundary, its first few words must be passed
2048: in registers and the rest must be pushed. This macro tells the
2049: compiler when this occurs, and how many of the words should go in
2050: registers.
2051:
2052: @code{FUNCTION_ARG} for these arguments should return the first
2053: register to be used by the caller for this argument; likewise
2054: @code{FUNCTION_INCOMING_ARG}, for the called function.
2055:
2056: @findex FUNCTION_ARG_PASS_BY_REFERENCE
2057: @item FUNCTION_ARG_PASS_BY_REFERENCE (@var{cum}, @var{mode}, @var{type}, @var{named})
2058: A C expression that indicates when an argument must be passed by reference.
2059: If nonzero for an argument, a copy of that argument is made in memory and a
2060: pointer to the argument is passed instead of the argument itself.
2061: The pointer is passed in whatever way is appropriate for passing a pointer
2062: to that type.
2063:
2064: On machines where @code{REG_PARM_STACK_SPACE} is not defined, a suitable
2065: definition of this macro might be
2066: @example
2067: #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
2068: MUST_PASS_IN_STACK (MODE, TYPE)
2069: @end example
2070:
2071: @findex CUMULATIVE_ARGS
2072: @item CUMULATIVE_ARGS
2073: A C type for declaring a variable that is used as the first argument of
2074: @code{FUNCTION_ARG} and other related values. For some target machines,
2075: the type @code{int} suffices and can hold the number of bytes of
2076: argument so far.
2077:
2078: There is no need to record in @code{CUMULATIVE_ARGS} anything about the
2079: arguments that have been passed on the stack. The compiler has other
2080: variables to keep track of that. For target machines on which all
2081: arguments are passed on the stack, there is no need to store anything in
2082: @code{CUMULATIVE_ARGS}; however, the data structure must exist and
2083: should not be empty, so use @code{int}.
2084:
2085: @findex INIT_CUMULATIVE_ARGS
2086: @item INIT_CUMULATIVE_ARGS (@var{cum}, @var{fntype}, @var{libname})
2087: A C statement (sans semicolon) for initializing the variable @var{cum}
2088: for the state at the beginning of the argument list. The variable has
2089: type @code{CUMULATIVE_ARGS}. The value of @var{fntype} is the tree node
2090: for the data type of the function which will receive the args, or 0
2091: if the args are to a compiler support library function.
2092:
2093: When processing a call to a compiler support library function,
2094: @var{libname} identifies which one. It is a @code{symbol_ref} rtx which
2095: contains the name of the function, as a string. @var{libname} is 0 when
2096: an ordinary C function call is being processed. Thus, each time this
2097: macro is called, either @var{libname} or @var{fntype} is nonzero, but
2098: never both of them at once.
2099:
2100: @findex INIT_CUMULATIVE_INCOMING_ARGS
2101: @item INIT_CUMULATIVE_INCOMING_ARGS (@var{cum}, @var{fntype}, @var{libname})
2102: Like @code{INIT_CUMULATIVE_ARGS} but overrides it for the purposes of
2103: finding the arguments for the function being compiled. If this macro is
2104: undefined, @code{INIT_CUMULATIVE_ARGS} is used instead.
2105:
2106: The argument @var{libname} exists for symmetry with
2107: @code{INIT_CUMULATIVE_ARGS}. The value passed for @var{libname} is
2108: always 0, since library routines with special calling conventions are
2109: never compiled with GNU CC.
2110:
2111: @findex FUNCTION_ARG_ADVANCE
2112: @item FUNCTION_ARG_ADVANCE (@var{cum}, @var{mode}, @var{type}, @var{named})
2113: A C statement (sans semicolon) to update the summarizer variable
2114: @var{cum} to advance past an argument in the argument list. The
2115: values @var{mode}, @var{type} and @var{named} describe that argument.
2116: Once this is done, the variable @var{cum} is suitable for analyzing
2117: the @emph{following} argument with @code{FUNCTION_ARG}, etc.@refill
2118:
2119: This macro need not do anything if the argument in question was passed
2120: on the stack. The compiler knows how to track the amount of stack space
2121: used for arguments without any special help.
2122:
2123: @findex FUNCTION_ARG_PADDING
2124: @item FUNCTION_ARG_PADDING (@var{mode}, @var{type})
2125: If defined, a C expression which determines whether, and in which direction,
2126: to pad out an argument with extra space. The value should be of type
2127: @code{enum direction}: either @code{upward} to pad above the argument,
2128: @code{downward} to pad below, or @code{none} to inhibit padding.
2129:
2130: This macro does not control the @emph{amount} of padding; that is
2131: always just enough to reach the next multiple of @code{FUNCTION_ARG_BOUNDARY}.
2132:
2133: This macro has a default definition which is right for most systems.
2134: For little-endian machines, the default is to pad upward. For
2135: big-endian machines, the default is to pad downward for an argument of
2136: constant size shorter than an @code{int}, and upward otherwise.
2137:
2138: @findex FUNCTION_ARG_BOUNDARY
2139: @item FUNCTION_ARG_BOUNDARY (@var{mode}, @var{type})
2140: If defined, a C expression that gives the alignment boundary, in bits,
2141: of an argument with the specified mode and type. If it is not defined,
2142: @code{PARM_BOUNDARY} is used for all arguments.
2143:
2144: @findex FUNCTION_ARG_REGNO_P
2145: @item FUNCTION_ARG_REGNO_P (@var{regno})
2146: A C expression that is nonzero if @var{regno} is the number of a hard
2147: register in which function arguments are sometimes passed. This does
2148: @emph{not} include implicit arguments such as the static chain and
2149: the structure-value address. On many machines, no registers can be
2150: used for this purpose since all function arguments are pushed on the
2151: stack.
2152: @end table
2153:
2154: @node Scalar Return
2155: @subsection How Scalar Function Values Are Returned
2156: @cindex return values in registers
2157: @cindex values, returned by functions
2158: @cindex scalars, returned as values
2159:
2160: This section discusses the macros that control returning scalars as
2161: values---values that can fit in registers.
2162:
2163: @table @code
2164: @findex TRADITIONAL_RETURN_FLOAT
2165: @item TRADITIONAL_RETURN_FLOAT
2166: Define this macro if @samp{-traditional} should not cause functions
2167: declared to return @code{float} to convert the value to @code{double}.
2168:
2169: @findex FUNCTION_VALUE
2170: @item FUNCTION_VALUE (@var{valtype}, @var{func})
2171: A C expression to create an RTX representing the place where a
2172: function returns a value of data type @var{valtype}. @var{valtype} is
2173: a tree node representing a data type. Write @code{TYPE_MODE
2174: (@var{valtype})} to get the machine mode used to represent that type.
2175: On many machines, only the mode is relevant. (Actually, on most
2176: machines, scalar values are returned in the same place regardless of
2177: mode).@refill
2178:
2179: If the precise function being called is known, @var{func} is a tree
2180: node (@code{FUNCTION_DECL}) for it; otherwise, @var{func} is a null
2181: pointer. This makes it possible to use a different value-returning
2182: convention for specific functions when all their calls are
2183: known.@refill
2184:
2185: @code{FUNCTION_VALUE} is not used for return vales with aggregate data
2186: types, because these are returned in another way. See
2187: @code{STRUCT_VALUE_REGNUM} and related macros, below.
2188:
2189: @findex FUNCTION_OUTGOING_VALUE
2190: @item FUNCTION_OUTGOING_VALUE (@var{valtype}, @var{func})
2191: Define this macro if the target machine has ``register windows''
2192: so that the register in which a function returns its value is not
2193: the same as the one in which the caller sees the value.
2194:
2195: For such machines, @code{FUNCTION_VALUE} computes the register in
2196: which the caller will see the value, and
2197: @code{FUNCTION_OUTGOING_VALUE} should be defined in a similar fashion
2198: to tell the function where to put the value.@refill
2199:
2200: If @code{FUNCTION_OUTGOING_VALUE} is not defined,
2201: @code{FUNCTION_VALUE} serves both purposes.@refill
2202:
2203: @code{FUNCTION_OUTGOING_VALUE} is not used for return vales with
2204: aggregate data types, because these are returned in another way. See
2205: @code{STRUCT_VALUE_REGNUM} and related macros, below.
2206:
2207: @findex LIBCALL_VALUE
2208: @item LIBCALL_VALUE (@var{mode})
2209: A C expression to create an RTX representing the place where a library
2210: function returns a value of mode @var{mode}. If the precise function
2211: being called is known, @var{func} is a tree node
2212: (@code{FUNCTION_DECL}) for it; otherwise, @var{func} is a null
2213: pointer. This makes it possible to use a different value-returning
2214: convention for specific functions when all their calls are
2215: known.@refill
2216:
2217: Note that ``library function'' in this context means a compiler
2218: support routine, used to perform arithmetic, whose name is known
2219: specially by the compiler and was not mentioned in the C code being
2220: compiled.
2221:
2222: The definition of @code{LIBRARY_VALUE} need not be concerned aggregate
2223: data types, because none of the library functions returns such types.
2224:
2225: @findex FUNCTION_VALUE_REGNO_P
2226: @item FUNCTION_VALUE_REGNO_P (@var{regno})
2227: A C expression that is nonzero if @var{regno} is the number of a hard
2228: register in which the values of called function may come back.
2229:
2230: A register whose use for returning values is limited to serving as the
2231: second of a pair (for a value of type @code{double}, say) need not be
2232: recognized by this macro. So for most machines, this definition
2233: suffices:
2234:
2235: @example
2236: #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
2237: @end example
2238:
2239: If the machine has register windows, so that the caller and the called
2240: function use different registers for the return value, this macro
2241: should recognize only the caller's register numbers.
2242: @end table
2243:
2244: @node Aggregate Return
2245: @subsection How Large Values Are Returnd
2246: @cindex aggregates as return values
2247: @cindex large return values
2248: @cindex returning aggregate values
2249: @cindex structure value address
2250:
2251: When a function value's mode is @code{BLKmode} (and in some other
2252: cases), the value is not returned according to @code{FUNCTION_VALUE}
2253: (@pxref{Scalar Return}). Instead, the caller passes the address of a
2254: block of memory in which the value should be stored. This address
2255: is called the @dfn{structure value address}.
2256:
2257: This section describes how to control returning structure values in
2258: memory.
2259:
2260: @table @code
2261: @findex RETURN_IN_MEMORY
2262: @item RETURN_IN_MEMORY (@var{type})
2263: A C expression which can inhibit the returning of certain function
2264: values in registers, based on the type of value. A nonzero value says
2265: to return the function value in memory, just as large structures are
2266: always returned. Here @var{type} will be a C expression of type
2267: @code{tree}, representing the data type of the value.
2268:
2269: Note that values of mode @code{BLKmode} are returned in memory
2270: regardless of this macro. Also, the option @samp{-fpcc-struct-return}
2271: takes effect regardless of this macro. On most systems, it is
2272: possible to leave the macro undefined; this causes a default
2273: definition to be used, whose value is the constant 0.
2274:
2275: @findex STRUCT_VALUE_REGNUM
2276: @item STRUCT_VALUE_REGNUM
2277: If the structure value address is passed in a register, then
2278: @code{STRUCT_VALUE_REGNUM} should be the number of that register.
2279:
2280: @findex STRUCT_VALUE
2281: @item STRUCT_VALUE
2282: If the structure value address is not passed in a register, define
2283: @code{STRUCT_VALUE} as an expression returning an RTX for the place
2284: where the address is passed. If it returns 0, the address is passed as
2285: an ``invisible'' first argument.
2286:
2287: @findex STRUCT_VALUE_INCOMING_REGNUM
2288: @item STRUCT_VALUE_INCOMING_REGNUM
2289: On some architectures the place where the structure value address
2290: is found by the called function is not the same place that the
2291: caller put it. This can be due to register windows, or it could
2292: be because the function prologue moves it to a different place.
2293:
2294: If the incoming location of the structure value address is in a
2295: register, define this macro as the register number.
2296:
2297: @findex STRUCT_VALUE_INCOMING
2298: @item STRUCT_VALUE_INCOMING
2299: If the incoming location is not a register, define
2300: @code{STRUCT_VALUE_INCOMING} as an expression for an RTX for where the
2301: called function should find the value. If it should find the value on
2302: the stack, define this to create a @code{mem} which refers to the frame
2303: pointer. A definition of 0 means that the address is passed as an
2304: ``invisible'' first argument.
2305:
2306: @findex PCC_STATIC_STRUCT_RETURN
2307: @item PCC_STATIC_STRUCT_RETURN
2308: Define this macro if the usual system convention on the target machine
2309: for returning structures and unions is for the called function to return
2310: the address of a static variable containing the value. GNU CC does not
2311: normally use this convention, even if it is the usual one, but does use
2312: it if @samp{-fpcc-struct-value} is specified.
2313:
2314: Do not define this if the usual system convention is for the caller to
2315: pass an address to the subroutine.
2316: @end table
2317:
2318: @node Caller Saves
2319: @subsection Caller-Saves Register Allocation
2320:
2321: If you enable it, GNU CC can save registers around function calls. This
2322: makes it possible to use call-clobbered registers to hold variables that
2323: must live across calls.
2324:
2325: @table @code
2326: @findex DEFAULT_CALLER_SAVES
2327: @item DEFAULT_CALLER_SAVES
2328: Define this macro if function calls on the target machine do not preserve
2329: any registers; in other words, if @code{CALL_USED_REGISTERS} has 1
2330: for all registers. This macro enables @samp{-fcaller-saves} by default.
2331: Eventually that option will be enabled by default on all machines and both
2332: the option and this macro will be eliminated.
2333:
2334: @findex CALLER_SAVE_PROFITABLE
2335: @item CALLER_SAVE_PROFITABLE (@var{refs}, @var{calls})
2336: A C expression to determine whether it is worthwhile to consider placing
2337: a pseudo-register in a call-clobbered hard register and saving and
2338: restoring it around each function call. The expression should be 1 when
2339: this is worth doing, and 0 otherwise.
2340:
2341: If you don't define this macro, a default is used which is good on most
2342: machines: @code{4 * @var{calls} < @var{refs}}.
2343: @end table
2344:
2345: @node Function Entry
2346: @subsection Function Entry and Exit
2347: @cindex function entry and exit
2348: @cindex prologue
2349: @cindex epilogue
2350:
2351: This section describes the macros that output function entry
2352: (@dfn{prologue}) and exit (@dfn{epilogue}) code.
2353:
2354: @table @code
2355: @findex FUNCTION_PROLOGUE
2356: @item FUNCTION_PROLOGUE (@var{file}, @var{size})
2357: A C compound statement that outputs the assembler code for entry to a
2358: function. The prologue is responsible for setting up the stack frame,
2359: initializing the frame pointer register, saving registers that must be
2360: saved, and allocating @var{size} additional bytes of storage for the
2361: local variables. @var{size} is an integer. @var{file} is a stdio
2362: stream to which the assembler code should be output.
2363:
2364: The label for the beginning of the function need not be output by this
2365: macro. That has already been done when the macro is run.
2366:
2367: @findex regs_ever_live
2368: To determine which registers to save, the macro can refer to the array
2369: @code{regs_ever_live}: element @var{r} is nonzero if hard register
2370: @var{r} is used anywhere within the function. This implies the function
2371: prologue should save register @var{r}, provided it is not one of the
2372: call-used registers. (@code{FUNCTION_EPILOGUE} must likewise use
2373: @code{regs_ever_live}.)
2374:
2375: On machines that have ``register windows'', the function entry code does
2376: not save on the stack the registers that are in the windows, even if
2377: they are supposed to be preserved by function calls; instead it takes
2378: appropriate steps to ``push'' the register stack, if any non-call-used
2379: registers are used in the function.
2380:
2381: @findex frame_pointer_needed
2382: On machines where functions may or may not have frame-pointers, the
2383: function entry code must vary accordingly; it must set up the frame
2384: pointer if one is wanted, and not otherwise. To determine whether a
2385: frame pointer is in wanted, the macro can refer to the variable
2386: @code{frame_pointer_needed}. The variable's value will be 1 at run
2387: time in a function that needs a frame pointer. @xref{Elimination}.
2388:
2389: The function entry code is responsible for allocating any stack space
2390: required for the function. This stack space consists of the regions
2391: listed below. In most cases, these regions are allocated in the
2392: order listed, with the last listed region closest to the top of the
2393: stack (the lowest address if @code{STACK_GROWS_DOWNWARD} is defined, and
2394: the highest address if it is not defined). You can use a different order
2395: for a machine if doing so is more convenient or required for
2396: compatibility reasons. Except in cases where required by standard
2397: or by a debugger, there is no reason why the stack layout used by GCC
2398: need agree with that used by other compilers for a machine.
2399:
2400: @itemize @bullet
2401: @item
2402: @findex current_function_pretend_args_size
2403: A region of @code{current_function_pretend_args_size} bytes of
2404: uninitialized space just underneath the first argument arriving on the
2405: stack. (This may not be at the very start of the allocated stack region
2406: if the calling sequence has pushed anything else since pushing the stack
2407: arguments. But usually, on such machines, nothing else has been pushed
2408: yet, because the function prologue itself does all the pushing.) This
2409: region is used on machines where an argument may be passed partly in
2410: registers and partly in memory, and, in some cases to support the
2411: features in @file{varargs.h} and @file{stdargs.h}.
2412:
2413: @item
2414: An area of memory used to save certain registers used by the function.
2415: The size of this area, which may also include space for such things as
2416: the return address and pointers to previous stack frames, is
2417: machine-specific and usually depends on which registers have been used
2418: in the function. Machines with register windows often do not require
2419: a save area.
2420:
2421: @item
2422: A region of at least @var{size} bytes, possibly rounded up to an allocation
2423: boundary, to contain the local variables of the function. On some machines,
2424: this region and the save area may occur in the opposite order, with the
2425: save area closer to the top of the stack.
2426:
2427: @item
2428: @cindex @code{ACCUMULATE_OUTGOING_ARGS} and stack frames
2429: Optionally, in the case that @code{ACCUMULATE_OUTGOING_ARGS} is defined,
2430: a region of @code{current_function_outgoing_args_size} bytes to be used
2431: for outgoing argument lists of the function. @xref{Stack Arguments}.
2432: @end itemize
2433:
2434: Normally, it is necessary for @code{FUNCTION_PROLOGUE} and
2435: @code{FUNCTION_EPILOGUE} to treat leaf functions specially. The C
2436: variable @code{leaf_function} is nonzero for such a function.
2437:
2438: @findex EXIT_IGNORE_STACK
2439: @item EXIT_IGNORE_STACK
2440: Define this macro as a C expression that is nonzero if the return
2441: instruction or the function epilogue ignores the value of the stack
2442: pointer; in other words, if it is safe to delete an instruction to
2443: adjust the stack pointer before a return from the function.
2444:
2445: Note that this macro's value is relevant only for functions for which
2446: frame pointers are maintained. It is never safe to delete a final
2447: stack adjustment in a function that has no frame pointer, and the
2448: compiler knows this regardless of @code{EXIT_IGNORE_STACK}.
2449:
2450: @findex FUNCTION_EPILOGUE
2451: @item FUNCTION_EPILOGUE (@var{file}, @var{size})
2452: A C compound statement that outputs the assembler code for exit from a
2453: function. The epilogue is responsible for restoring the saved
2454: registers and stack pointer to their values when the function was
2455: called, and returning control to the caller. This macro takes the
2456: same arguments as the macro @code{FUNCTION_PROLOGUE}, and the
2457: registers to restore are determined from @code{regs_ever_live} and
2458: @code{CALL_USED_REGISTERS} in the same way.
2459:
2460: On some machines, there is a single instruction that does all the work
2461: of returning from the function. On these machines, give that
2462: instruction the name @samp{return} and do not define the macro
2463: @code{FUNCTION_EPILOGUE} at all.
2464:
2465: Do not define a pattern named @samp{return} if you want the
2466: @code{FUNCTION_EPILOGUE} to be used. If you want the target switches
2467: to control whether return instructions or epilogues are used, define a
2468: @samp{return} pattern with a validity condition that tests the target
2469: switches appropriately. If the @samp{return} pattern's validity
2470: condition is false, epilogues will be used.
2471:
2472: On machines where functions may or may not have frame-pointers, the
2473: function exit code must vary accordingly. Sometimes the code for
2474: these two cases is completely different. To determine whether a frame
2475: pointer is in wanted, the macro can refer to the variable
2476: @code{frame_pointer_needed}. The variable's value will be 1 at run
2477: time in a function that needs a frame pointer.
2478:
2479: Normally, it is necessary for @code{FUNCTION_PROLOGUE} and
2480: @code{FUNCTION_EPILOGUE} to treat leaf functions specially. The C
2481: variable @code{leaf_function} is nonzero for such a function.
2482: @xref{Leaf Functions}.
2483:
2484: On some machines, some functions pop their arguments on exit while
2485: others leave that for the caller to do. For example, the 68020 when
2486: given @samp{-mrtd} pops arguments in functions that take a fixed
2487: number of arguments.
2488:
2489: @findex current_function_pops_args
2490: Your definition of the macro @code{RETURN_POPS_ARGS} decides which
2491: functions pop their own arguments. @code{FUNCTION_EPILOGUE} needs to
2492: know what was decided. The variable @code{current_function_pops_args}
2493: is the number of bytes of its arguments that a function should pop.
2494: @xref{Scalar Return}.
2495:
2496: @findex DELAY_SLOTS_FOR_EPILOGUE
2497: @item DELAY_SLOTS_FOR_EPILOGUE
2498: Define this macro if the function epilogue contains delay slots to which
2499: instructions from the rest of the function can be ``moved''. The
2500: definition should be a C expression whose value is an integer
2501: representing the number of delay slots there.
2502:
2503: @findex ELIGIBLE_FOR_EPILOGUE_DELAY
2504: @item ELIGIBLE_FOR_EPILOGUE_DELAY (@var{insn}, @var{n})
2505: A C expression that returns 1 if @var{insn} can be placed in delay
2506: slot number @var{n} of the epilogue.
2507:
2508: The argument @var{n} is an integer which identifies the delay slot now
2509: being considered (since different slots may have different rules of
2510: eligibility). It is never negative and is always less than the number
2511: of epilogue delay slots (what @code{DELAY_SLOTS_FOR_EPILOGUE} returns).
2512: If you reject a particular insn for a given delay slot, in principle, it
2513: may be reconsidered for a subsequent delay slot. Also, other insns may
2514: (at least in principle) be considered for the so far unfilled delay
2515: slot.
2516:
2517: @findex current_function_epilogue_delay_list
2518: @findex final_scan_insn
2519: The insns accepted to fill the epilogue delay slots are put in an RTL
2520: list made with @code{insn_list} objects, stored in the variable
2521: @code{current_function_epilogue_delay_list}. The insn for the first
2522: delay slot comes first in the list. Your definition of the macro
2523: @code{FUNCTION_EPILOGUE} should fill the delay slots by outputting the
2524: insns in this list, usually by calling @code{final_scan_insn}.
2525:
2526: You need not define this macro if you did not define
2527: @code{DELAY_SLOTS_FOR_EPILOGUE}.
2528: @end table
2529:
2530: @node Profiling
2531: @subsection Generating Code for Profiling
2532: @cindex profiling, code generation
2533:
2534: @table @code
2535: @findex FUNCTION_PROFILER
2536: @item FUNCTION_PROFILER (@var{file}, @var{labelno})
2537: A C statement or compound statement to output to @var{file} some
2538: assembler code to call the profiling subroutine @code{mcount}.
2539: Before calling, the assembler code must load the address of a
2540: counter variable into a register where @code{mcount} expects to
2541: find the address. The name of this variable is @samp{LP} followed
2542: by the number @var{labelno}, so you would generate the name using
2543: @samp{LP%d} in a @code{fprintf}.
2544:
2545: @findex mcount
2546: The details of how the address should be passed to @code{mcount} are
2547: determined by your operating system environment, not by GNU CC. To
2548: figure them out, compile a small program for profiling using the
2549: system's installed C compiler and look at the assembler code that
2550: results.
2551:
2552: @findex PROFILE_BEFORE_PROLOGUE
2553: @item PROFILE_BEFORE_PROLOGUE
2554: Define this macro if the code for function profiling should come before
2555: the function prologue. Normally, the profiling code comes after.
2556:
2557: @findex FUNCTION_BLOCK_PROFILER
2558: @findex __bb_init_func
2559: @item FUNCTION_BLOCK_PROFILER (@var{file}, @var{labelno})
2560: A C statement or compound statement to output to @var{file} some
2561: assembler code to initialize basic-block profiling for the current
2562: object module. This code should call the subroutine
2563: @code{__bb_init_func} once per object module, passing it as its sole
2564: argument the address of a block allocated in the object module.
2565:
2566: The name of the block is a local symbol made with this statement:
2567:
2568: @example
2569: ASM_GENERATE_INTERNAL_LABEL (@var{buffer}, "LPBX", 0);
2570: @end example
2571:
2572: Of course, since you are writing the definition of
2573: @code{ASM_GENERATE_INTERNAL_LABEL} as well as that of this macro, you
2574: can take a short cut in the definition of this macro and use the name
2575: that you know will result.
2576:
2577: The first word of this block is a flag which will be nonzero if the
2578: object module has already been initialized. So test this word first,
2579: and do not call @code{__bb_init_func} if the flag is nonzero.
2580:
2581: @findex BLOCK_PROFILER
2582: @item BLOCK_PROFILER (@var{file}, @var{blockno})
2583: A C statement or compound statement to increment the count associated
2584: with the basic block number @var{blockno}. Basic blocks are numbered
2585: separately from zero within each compilation. The count associated
2586: with block number @var{blockno} is at index @var{blockno} in a vector
2587: of words; the name of this array is a local symbol made with this
2588: statement:
2589:
2590: @example
2591: ASM_GENERATE_INTERNAL_LABEL (@var{buffer}, "LPBX", 2);
2592: @end example
2593:
2594: Of course, since you are writing the definition of
2595: @code{ASM_GENERATE_INTERNAL_LABEL} as well as that of this macro, you
2596: can take a short cut in the definition of this macro and use the name
2597: that you know will result.
2598: @end table
2599:
2600: @node Varargs, Trampolines, Stack and Calling, Machine Macros
2601: @section Implementing the Varargs Macros
2602: @cindex varargs implementation
2603:
2604: GNU CC comes with an implementation of @file{varargs.h} and
2605: @file{stdarg.h} that work without change on machines that pass arguments
2606: on the stack. Other machines require their own implementations of
2607: varargs, and the two machine independent header files must have
2608: conditionals to include it.
2609:
2610: ANSI @file{stdarg.h} differs from traditional @file{varargs.h} mainly in
2611: the calling convention for @code{va_start}. The traditional
2612: implementation takes just one argument, which is the variable in which
2613: to store the argument pointer. The ANSI implementation takes an
2614: additional first argument, which is the last named argument of the
2615: function. However, it should not use this argument. The way to find
2616: the end of the named arguments is with the built-in functions described
2617: below.
2618:
2619: @table @code
2620: @findex __builtin_saveregs
2621: @item __builtin_saveregs ()
2622: Use this built-in function to save the argument registers in memory so
2623: that the varargs mechanism can access them. Both ANSI and traditional
2624: versions of @code{va_start} must use @code{__builtin_saveregs}, unless
2625: you use @code{SETUP_INCOMING_VARARGS} (see below) instead.
2626:
2627: On some machines, @code{__builtin_saveregs} is open-coded under the
2628: control of the macro @code{EXPAND_BUILTIN_SAVEREGS}. On other machines,
2629: it calls a routine written in assembler language, found in
2630: @file{libgcc2.c}.
2631:
2632: Regardless of what code is generated for the call to
2633: @code{__builtin_saveregs}, it appears at the beginning of the function,
2634: not where the call to @code{__builtin_saveregs} is written. This is
2635: because the registers must be saved before the function starts to use
2636: them for its own purposes.
2637:
2638: @findex __builtin_args_info
2639: @item __builtin_args_info (@var{category})
2640: Use this built-in function to find the first anonymous arguments in
2641: registers.
2642:
2643: In general, a machine may have several categories of registers used for
2644: arguments, each for a particular category of data types. (For example,
2645: on some machines, floating-point registers are used for floating-point
2646: arguments while other arguments are passed in the general registers.)
2647: To make non-varargs functions use the proper calling convention, you
2648: have defined the @code{CUMULATIVE_ARGS} data type to record how many
2649: registers in each category have been used so far
2650:
2651: @code{__builtin_args_info} accesses the same data structure of type
2652: @code{CUMULATIVE_ARGS} after the ordinary argument layout is finished
2653: with it, with @var{category} specifying which word to access. Thus, the
2654: value indicates the first unused register in a given category.
2655:
2656: Normally, you would use @code{__builtin_args_info} in the implementation
2657: of @code{va_start}, accessing each category just once and storing the
2658: value in the @code{va_list} object. This is because @code{va_list} will
2659: have to update the values, and there is no way to alter the
2660: values accessed by @code{__builtin_args_info}.
2661:
2662: @findex __builtin_next_arg
2663: @item __builtin_next_arg ()
2664: This is the equivalent of @code{__builtin_args_info}, for stack
2665: arguments. It returns the address of the first anonymous stack
2666: argument, as type @code{void *}. If @code{ARGS_GROW_DOWNWARD}, it
2667: returns the address of the location above the first anonymous stack
2668: argument. Use it in @code{va_start} to initialize the pointer for
2669: fetching arguments from the stack.
2670:
2671: @findex __builtin_classify_type
2672: @item __builtin_classify_type (@var{object})
2673: Since each machine has its own conventions for which data types are
2674: passed in which kind of register, your implementation of @code{va_arg}
2675: has to embody these conventions. The easiest way to categorize the
2676: specified data type is to use @code{__builtin_classify_type} together
2677: with @code{sizeof} and @code{__alignof__}.
2678:
2679: @code{__builtin_classify_type} ignores the value of @var{object},
2680: considering only its data type. It returns an integer describing what
2681: kind of type that is---integer, floating, pointer, structure, and so on.
2682:
2683: The file @file{typeclass.h} defines an enumeration that you can use to
2684: interpret the values of @code{__builtin_classify_type}.
2685: @end table
2686:
2687: These machine description macros help implement varargs:
2688:
2689: @table @code
2690: @findex EXPAND_BUILTIN_SAVEREGS
2691: @item EXPAND_BUILTIN_SAVEREGS (@var{args})
2692: If defined, is a C expression that produces the machine-specific code
2693: for a call to @code{__builtin_saveregs}. This code will be moved to the
2694: very beginning of the function, before any parameter access are made.
2695: The return value of this function should be an RTX that contains the
2696: value to use as the return of @code{__builtin_saveregs}.
2697:
2698: The argument @var{args} is a @code{tree_list} containing the arguments
2699: that were passed to @code{__builtin_saveregs}.
2700:
2701: If this macro is not defined, the compiler will output an ordinary
2702: call to the library function @samp{__builtin_saveregs}.
2703:
2704: @findex SETUP_INCOMING_VARARGS
2705: @item SETUP_INCOMING_VARARGS (@var{args_so_far}, @var{mode}, @var{type}, @var{pretend_args_size}, @var{second_time})
2706: This macro offers an alternative to using @code{__builtin_saveregs} and
2707: defining the macro @code{EXPAND_BUILTIN_SAVEREGS}. Use it to store the
2708: anonymous register arguments into the stack so that all the arguments
2709: appear to have been passed consecutively on the stack. Once this is
2710: done, you can use the standard implementation of varargs that works for
2711: machines that pass all their arguments on the stack.
2712:
2713: The argument @var{args_so_far} is the @code{CUMULATIVE_ARGS} data
2714: structure, containing the values that obtain after processing of the
2715: named arguments. The arguments @var{mode} and @var{type} describe the
2716: last named argument---its machine mode and its data type as a tree node.
2717:
2718: The macro implementation should do two things: first, push onto the
2719: stack all the argument registers @emph{not} used for the named
2720: arguments, and second, store the size of the data thus pushed into the
2721: @code{int}-valued variable whose name is supplied as the argument
2722: @var{pretend_args_size}. The value that you store here will serve as
2723: additional offset for setting up the stack frame.
2724:
2725: Because you must generate code to push the anonymous arguments at
2726: compile time without knowing their data types,
2727: @code{SETUP_INCOMING_VARARGS} is only useful on machines that have just
2728: a single category of argument register and use it uniformly for all data
2729: types.
2730:
2731: If the argument @var{second_time} is nonzero, it means that the
2732: arguments of the function are being analyzed for the second time. This
2733: happens for an inline function, which is not actually compiled until the
2734: end of the source file. The macro @code{SETUP_INCOMING_VARARGS} should
2735: not generate any instructions in this case.
2736: @end table
2737:
2738: @node Trampolines, Library Calls, Varargs, Machine Macros
2739: @section Trampolines for Nested Functions
2740: @cindex trampolines for nested functions
2741: @cindex nested functions, trampolines for
2742:
2743: A @dfn{trampoline} is a small piece of code that is created at run time
2744: when the address of a nested function is taken. It normally resides on
2745: the stack, in the stack frame of the containing function. These macros
2746: tell GNU CC how to generate code to allocate and initialize a
2747: trampoline.
2748:
2749: The instructions in the trampoline must do two things: load a constant
2750: address into the static chain register, and jump to the real address of
2751: the nested function. On CISC machines such as the m68k, this requires
2752: two instructions, a move immediate and a jump. Then the two addresses
2753: exist in the trampoline as word-long immediate operands. On RISC
2754: machines, it is often necessary to load each address into a register in
2755: two parts. Then pieces of each address form separate immediate
2756: operands.
2757:
2758: The code generated to initialize the trampoline must store the variable
2759: parts---the static chain value and the function address---into the
2760: immediate operands of the instructions. On a CISC machine, this is
2761: simply a matter of copying each address to a memory reference at the
2762: proper offset from the start of the trampoline. On a RISC machine, it
2763: may be necessary to take out pieces of the address and store them
2764: separately.
2765:
2766: @table @code
2767: @findex TRAMPOLINE_TEMPLATE
2768: @item TRAMPOLINE_TEMPLATE (@var{file})
2769: A C statement to output, on the stream @var{file}, assembler code for a
2770: block of data that contains the constant parts of a trampoline. This
2771: code should not include a label---the label is taken care of
2772: automatically.
2773:
2774: @findex TRAMPOLINE_SIZE
2775: @item TRAMPOLINE_SIZE
2776: A C expression for the size in bytes of the trampoline, as an integer.
2777:
2778: @findex TRAMPOLINE_ALIGNMENT
2779: @item TRAMPOLINE_ALIGNMENT
2780: Alignment required for trampolines, in bits.
2781:
2782: If you don't define this macro, the value of @code{BIGGEST_ALIGNMENT}
2783: is used for aligning trampolines.
2784:
2785: @findex INITIALIZE_TRAMPOLINE
2786: @item INITIALIZE_TRAMPOLINE (@var{addr}, @var{fnaddr}, @var{static_chain})
2787: A C statement to initialize the variable parts of a trampoline.
2788: @var{addr} is an RTX for the address of the trampoline; @var{fnaddr} is
2789: an RTX for the address of the nested function; @var{static_chain} is an
2790: RTX for the static chain value that should be passed to the function
2791: when it is called.
2792:
2793: @findex ALLOCATE_TRAMPOLINE
2794: @item ALLOCATE_TRAMPOLINE (@var{fp})
2795: A C expression to allocate run-time space for a trampoline. The
2796: expression value should be an RTX representing a memory reference to the
2797: space for the trampoline.
2798:
2799: @cindex @code{FUNCTION_EPILOGUE} and trampolines
2800: @cindex @code{FUNCTION_PROLOGUE} and trampolines
2801: If this macro is not defined, by default the trampoline is allocated as
2802: a stack slot. This default is right for most machines. The exceptions
2803: are machines where it is impossible to execute instructions in the stack
2804: area. On such machines, you may have to implement a separate stack,
2805: using this macro in conjunction with @code{FUNCTION_PROLOGUE} and
2806: @code{FUNCTION_EPILOGUE}.
2807:
2808: @var{fp} points to a data structure, a @code{struct function}, which
2809: describes the compilation status of the immediate containing function of
2810: the function which the trampoline is for. Normally (when
2811: @code{ALLOCATE_TRAMPOLINE} is not defined), the stack slot for the
2812: trampoline is in the stack frame of this containing function. Other
2813: allocation strategies probably must do something analogous with this
2814: information.
2815: @end table
2816:
2817: Implementing trampolines is difficult on many machines because they have
2818: separate instruction and data caches. Writing into a stack location
2819: fails to clear the memory in the instruction cache, so when the program
2820: jumps to that location, it executes the old contents.
2821:
2822: Here are two possible solutions. One is to clear the relevant parts of
2823: the instruction cache whenever a trampoline is set up. The other is to
2824: make all trampolines identical, by having them jump to a standard
2825: subroutine. The former technique makes trampoline execution faster; the
2826: latter makes initialization faster.
2827:
2828: To clear the instruction cache when a trampoline is initialized, define
2829: the following macros which describe the shape of the cache.
2830:
2831: @table @code
2832: @findex INSN_CACHE_SIZE
2833: @item INSN_CACHE_SIZE
2834: The total size in bytes of the cache.
2835:
2836: @findex INSN_CACHE_LINE_WIDTH
2837: @item INSN_CACHE_LINE_WIDTH
2838: The length in bytes of each cache line. The cache is divided into cache
2839: lines which are disjoint slots, each holding a contiguous chunk of data
2840: fetched from memory. Each time data is brought into the cache, an
2841: entire line is read at once. The data loaded into a cache line is
2842: always aligned on a boundary equal to the line size.
2843:
2844: @findex INSN_CACHE_DEPTH
2845: @item INSN_CACHE_DEPTH
2846: The number of alternative cache lines that can hold any particular memory
2847: location.
2848: @end table
2849:
2850: To use a standard subroutine, define the following macro. In addition,
2851: you must make sure that the instructions in a trampoline fill an entire
2852: cache line with identical instructions, or else ensure that the
2853: beginning of the trampoline code is always aligned at the same point in
2854: its cache line. Look in @file{m68k.h} as a guide.
2855:
2856: @table @code
2857: @findex TRANSFER_FROM_TRAMPOLINE
2858: @item TRANSFER_FROM_TRAMPOLINE
2859: Define this macro if trampolines need a special subroutine to do their
2860: work. The macro should expand to a series of @code{asm} statements
2861: which will be compiled with GNU CC. They go in a library function named
2862: @code{__transfer_from_trampoline}.
2863:
2864: If you need to avoid executing the ordinary prologue code of a compiled
2865: C function when you jump to the subroutine, you can do so by placing a
2866: special label of your own in the assembler code. Use one @code{asm}
2867: statement to generate an assembler label, and another to make the label
2868: global. Then trampolines can use that label to jump directly to your
2869: special assembler code.
2870: @end table
2871:
2872: @node Library Calls, Addressing Modes, Trampolines, Machine Macros
2873: @section Implicit Calls to Library Routines
2874: @cindex library subroutine names
2875: @cindex @file{libgcc.a}
2876:
2877: @table @code
2878: @findex MULSI3_LIBCALL
2879: @item MULSI3_LIBCALL
2880: A C string constant giving the name of the function to call for
2881: multiplication of one signed full-word by another. If you do not
2882: define this macro, the default name is used, which is @code{__mulsi3},
2883: a function defined in @file{libgcc.a}.
2884:
2885: @findex DIVSI3_LIBCALL
2886: @item DIVSI3_LIBCALL
2887: A C string constant giving the name of the function to call for
2888: division of one signed full-word by another. If you do not define
2889: this macro, the default name is used, which is @code{__divsi3}, a
2890: function defined in @file{libgcc.a}.
2891:
2892: @findex UDIVSI3_LIBCALL
2893: @item UDIVSI3_LIBCALL
2894: A C string constant giving the name of the function to call for
2895: division of one unsigned full-word by another. If you do not define
2896: this macro, the default name is used, which is @code{__udivsi3}, a
2897: function defined in @file{libgcc.a}.
2898:
2899: @findex MODSI3_LIBCALL
2900: @item MODSI3_LIBCALL
2901: A C string constant giving the name of the function to call for the
2902: remainder in division of one signed full-word by another. If you do
2903: not define this macro, the default name is used, which is
2904: @code{__modsi3}, a function defined in @file{libgcc.a}.
2905:
2906: @findex UMODSI3_LIBCALL
2907: @item UMODSI3_LIBCALL
2908: A C string constant giving the name of the function to call for the
2909: remainder in division of one unsigned full-word by another. If you do
2910: not define this macro, the default name is used, which is
2911: @code{__umodsi3}, a function defined in @file{libgcc.a}.
2912:
2913: @findex MULDI3_LIBCALL
2914: @item MULDI3_LIBCALL
2915: A C string constant giving the name of the function to call for
2916: multiplication of one signed double-word by another. If you do not
2917: define this macro, the default name is used, which is @code{__muldi3},
2918: a function defined in @file{libgcc.a}.
2919:
2920: @findex DIVDI3_LIBCALL
2921: @item DIVDI3_LIBCALL
2922: A C string constant giving the name of the function to call for
2923: division of one signed double-word by another. If you do not define
2924: this macro, the default name is used, which is @code{__divdi3}, a
2925: function defined in @file{libgcc.a}.
2926:
2927: @findex UDIVDI3_LIBCALL
2928: @item UDIVDI3_LIBCALL
2929: A C string constant giving the name of the function to call for
2930: division of one unsigned full-word by another. If you do not define
2931: this macro, the default name is used, which is @code{__udivdi3}, a
2932: function defined in @file{libgcc.a}.
2933:
2934: @findex MODDI3_LIBCALL
2935: @item MODDI3_LIBCALL
2936: A C string constant giving the name of the function to call for the
2937: remainder in division of one signed double-word by another. If you do
2938: not define this macro, the default name is used, which is
2939: @code{__moddi3}, a function defined in @file{libgcc.a}.
2940:
2941: @findex UMODDI3_LIBCALL
2942: @item UMODDI3_LIBCALL
2943: A C string constant giving the name of the function to call for the
2944: remainder in division of one unsigned full-word by another. If you do
2945: not define this macro, the default name is used, which is
2946: @code{__umoddi3}, a function defined in @file{libgcc.a}.
2947:
2948: @findex TARGET_MEM_FUNCTIONS
2949: @cindex @code{bcopy}, implicit usage
2950: @cindex @code{memcpy}, implicit usage
2951: @cindex @code{bzero}, implicit usage
2952: @cindex @code{memset}, implicit usage
2953: @item TARGET_MEM_FUNCTIONS
2954: Define this macro if GNU CC should generate calls to the System V
2955: (and ANSI C) library functions @code{memcpy} and @code{memset}
2956: rather than the BSD functions @code{bcopy} and @code{bzero}.
2957:
2958: @findex LIBGCC_NEEDS_DOUBLE
2959: @item LIBGCC_NEEDS_DOUBLE
2960: Define this macro if only @code{float} arguments cannot be passed to
2961: library routines (so they must be converted to @code{double}). This
2962: macro affects both how library calls are generated and how the library
2963: routines in @file{libgcc1.c} accept their arguments. It is useful on
2964: machines where floating and fixed point arguments are passed
2965: differently, such as the i860.
2966:
2967: @findex FLOAT_ARG_TYPE
2968: @item FLOAT_ARG_TYPE
2969: Define this macro to override the type used by the library routines to
2970: pick up arguments of type @code{float}. (By default, they use a union
2971: of @code{float} and @code{int}.)
2972:
2973: The obvious choice would be @code{float}---but that won't work with
2974: traditional C compilers that expect all arguments declared as @code{float}
2975: to arrive as @code{double}. To avoid this conversion, the library routines
2976: ask for the value as some other type and then treat it as a @code{float}.
2977:
2978: On some systems, no other type will work for this. For these systems,
2979: you must use @code{LIBGCC_NEEDS_DOUBLE} instead, to force conversion of
2980: the values @code{double} before they are passed.
2981:
2982: @findex FLOATIFY
2983: @item FLOATIFY (@var{passed-value})
2984: Define this macro to override the way library routines redesignate a
2985: @code{float} argument as a @code{float} instead of the type it was
2986: passed as. The default is an expression which takes the @code{float}
2987: field of the union.
2988:
2989: @findex FLOAT_VALUE_TYPE
2990: @item FLOAT_VALUE_TYPE
2991: Define this macro to override the type used by the library routines to
2992: return values that ought to have type @code{float}. (By default, they
2993: use @code{int}.)
2994:
2995: The obvious choice would be @code{float}---but that won't work with
2996: traditional C compilers gratuitously convert values declared as
2997: @code{float} into @code{double}.
2998:
2999: @findex INTIFY
3000: @item INTIFY (@var{float-value})
3001: Define this macro to override the way the value of a
3002: @code{float}-returning library routine should be packaged in order to
3003: return it. These functions are actually declared to return type
3004: @code{FLOAT_VALUE_TYPE} (normally @code{int}).
3005:
3006: These values can't be returned as type @code{float} because traditional
3007: C compilers would gratuitously convert the value to a @code{double}.
3008:
3009: A local variable named @code{intify} is always available when the macro
3010: @code{INTIFY} is used. It is a union of a @code{float} field named
3011: @code{f} and a field named @code{i} whose type is
3012: @code{FLOAT_VALUE_TYPE} or @code{int}.
3013:
3014: If you don't define this macro, the default definition works by copying
3015: the value through that union.
3016:
3017: @findex SItype
3018: @item SItype
3019: Define this macro as the name of the data type corresponding to
3020: @code{SImode} in the system's own C compiler.
3021:
3022: You need not define this macro if that type is @code{int}, as it usually
3023: is.
3024:
3025: @findex perform_@dots{}
3026: @item perform_@dots{}
3027: Define these macros to supply explicit C statements to carry out various
3028: arithmetic operations on types @code{float} and @code{double} in the
3029: library routines in @file{libgcc1.c}. See that file for a full list
3030: of these macros and their arguments.
3031:
3032: On most machines, you don't need to define any of these macros, because
3033: the C compiler that comes with the system takes care of doing them.
3034:
3035: @findex NEXT_OBJC_RUNTIME
3036: @item NEXT_OBJC_RUNTIME
3037: Define this macro to generate code for Objective C message sending using
3038: the calling convention of the NeXT system. This calling convention
3039: involves passing the object, the selector and the method arguments all
3040: at once to the method-lookup library function.
3041:
3042: The default calling convention passes just the object and the selector
3043: to the lookup function, which returns a pointer to the method.
3044: @end table
3045:
3046: @node Addressing Modes, Condition Code, Library Calls, Machine Macros
3047: @section Addressing Modes
3048: @cindex addressing modes
3049:
3050: @table @code
3051: @findex HAVE_POST_INCREMENT
3052: @item HAVE_POST_INCREMENT
3053: Define this macro if the machine supports post-increment addressing.
3054:
3055: @findex HAVE_PRE_INCREMENT
3056: @findex HAVE_POST_DECREMENT
3057: @findex HAVE_PRE_DECREMENT
3058: @item HAVE_PRE_INCREMENT
3059: @itemx HAVE_POST_DECREMENT
3060: @itemx HAVE_PRE_DECREMENT
3061: Similar for other kinds of addressing.
3062:
3063: @findex CONSTANT_ADDRESS_P
3064: @item CONSTANT_ADDRESS_P (@var{x})
3065: A C expression that is 1 if the RTX @var{x} is a constant which
3066: is a valid address. On most machines, this can be defined as
3067: @code{CONSTANT_P (@var{x})}, but a few machines are more restrictive
3068: in which constant addresses are supported.
3069:
3070: @findex CONSTANT_P
3071: @code{CONSTANT_P} accepts integer-values expressions whose values are
3072: not explicitly known, such as @code{symbol_ref}, @code{label_ref}, and
3073: @code{high} expressions and @code{const} arithmetic expressions, in
3074: addition to @code{const_int} and @code{const_double} expressions.
3075:
3076: @findex MAX_REGS_PER_ADDRESS
3077: @item MAX_REGS_PER_ADDRESS
3078: A number, the maximum number of registers that can appear in a valid
3079: memory address. Note that it is up to you to specify a value equal to
3080: the maximum number that @code{GO_IF_LEGITIMATE_ADDRESS} would ever
3081: accept.
3082:
3083: @findex GO_IF_LEGITIMATE_ADDRESS
3084: @item GO_IF_LEGITIMATE_ADDRESS (@var{mode}, @var{x}, @var{label})
3085: A C compound statement with a conditional @code{goto @var{label};}
3086: executed if @var{x} (an RTX) is a legitimate memory address on the
3087: target machine for a memory operand of mode @var{mode}.
3088:
3089: It usually pays to define several simpler macros to serve as
3090: subroutines for this one. Otherwise it may be too complicated to
3091: understand.
3092:
3093: This macro must exist in two variants: a strict variant and a
3094: non-strict one. The strict variant is used in the reload pass. It
3095: must be defined so that any pseudo-register that has not been
3096: allocated a hard register is considered a memory reference. In
3097: contexts where some kind of register is required, a pseudo-register
3098: with no hard register must be rejected.
3099:
3100: The non-strict variant is used in other passes. It must be defined to
3101: accept all pseudo-registers in every context where some kind of
3102: register is required.
3103:
3104: @findex REG_OK_STRICT
3105: Compiler source files that want to use the strict variant of this
3106: macro define the macro @code{REG_OK_STRICT}. You should use an
3107: @code{#ifdef REG_OK_STRICT} conditional to define the strict variant
3108: in that case and the non-strict variant otherwise.
3109:
3110: Typically among the subroutines used to define
3111: @code{GO_IF_LEGITIMATE_ADDRESS} are subroutines to check for
3112: acceptable registers for various purposes (one for base registers, one
3113: for index registers, and so on). Then only these subroutine macros
3114: need have two variants; the higher levels of macros may be the same
3115: whether strict or not.@refill
3116:
3117: Normally, constant addresses which are the sum of a @code{symbol_ref}
3118: and an integer are stored inside a @code{const} RTX to mark them as
3119: constant. Therefore, there is no need to recognize such sums
3120: specifically as legitimate addresses. Normally you would simply
3121: recognize any @code{const} as legitimate.
3122:
3123: Usually @code{PRINT_OPERAND_ADDRESS} is not prepared to handle constant
3124: sums that are not marked with @code{const}. It assumes that a naked
3125: @code{plus} indicates indexing. If so, then you @emph{must} reject such
3126: naked constant sums as illegitimate addresses, so that none of them will
3127: be given to @code{PRINT_OPERAND_ADDRESS}.
3128:
3129: @cindex @code{ENCODE_SECTION_INFO} and address validation
3130: On some machines, whether a symbolic address is legitimate depends on
3131: the section that the address refers to. On these machines, define the
3132: macro @code{ENCODE_SECTION_INFO} to store the information into the
3133: @code{symbol_ref}, and then check for it here. When you see a
3134: @code{const}, you will have to look inside it to find the
3135: @code{symbol_ref} in order to determine the section. @xref{Assembler
3136: Format}.
3137:
3138: @findex saveable_obstack
3139: The best way to modify the name string is by adding text to the
3140: beginning, with suitable punctuation to prevent any ambiguity. Allocate
3141: the new name in @code{saveable_obstack}. You will have to modify
3142: @code{ASM_OUTPUT_LABELREF} to remove and decode the added text and
3143: output the name accordingly.
3144:
3145: You can check the information stored here into the @code{symbol_ref} in
3146: the definitions of @code{GO_IF_LEGITIMATE_ADDRESS} and
3147: @code{PRINT_OPERAND_ADDRESS}.
3148:
3149: @findex REG_OK_FOR_BASE_P
3150: @item REG_OK_FOR_BASE_P (@var{x})
3151: A C expression that is nonzero if @var{x} (assumed to be a @code{reg}
3152: RTX) is valid for use as a base register. For hard registers, it
3153: should always accept those which the hardware permits and reject the
3154: others. Whether the macro accepts or rejects pseudo registers must be
3155: controlled by @code{REG_OK_STRICT} as described above. This usually
3156: requires two variant definitions, of which @code{REG_OK_STRICT}
3157: controls the one actually used.
3158:
3159: @findex REG_OK_FOR_INDEX_P
3160: @item REG_OK_FOR_INDEX_P (@var{x})
3161: A C expression that is nonzero if @var{x} (assumed to be a @code{reg}
3162: RTX) is valid for use as an index register.
3163:
3164: The difference between an index register and a base register is that
3165: the index register may be scaled. If an address involves the sum of
3166: two registers, neither one of them scaled, then either one may be
3167: labeled the ``base'' and the other the ``index''; but whichever
3168: labeling is used must fit the machine's constraints of which registers
3169: may serve in each capacity. The compiler will try both labelings,
3170: looking for one that is valid, and will reload one or both registers
3171: only if neither labeling works.
3172:
3173: @findex LEGITIMIZE_ADDRESS
3174: @item LEGITIMIZE_ADDRESS (@var{x}, @var{oldx}, @var{mode}, @var{win})
3175: A C compound statement that attempts to replace @var{x} with a valid
3176: memory address for an operand of mode @var{mode}. @var{win} will be a
3177: C statement label elsewhere in the code; the macro definition may use
3178:
3179: @example
3180: GO_IF_LEGITIMATE_ADDRESS (@var{mode}, @var{x}, @var{win});
3181: @end example
3182:
3183: @noindent
3184: to avoid further processing if the address has become legitimate.
3185:
3186: @findex break_out_memory_refs
3187: @var{x} will always be the result of a call to @code{break_out_memory_refs},
3188: and @var{oldx} will be the operand that was given to that function to produce
3189: @var{x}.
3190:
3191: The code generated by this macro should not alter the substructure of
3192: @var{x}. If it transforms @var{x} into a more legitimate form, it
3193: should assign @var{x} (which will always be a C variable) a new value.
3194:
3195: It is not necessary for this macro to come up with a legitimate
3196: address. The compiler has standard ways of doing so in all cases. In
3197: fact, it is safe for this macro to do nothing. But often a
3198: machine-dependent strategy can generate better code.
3199:
3200: @findex GO_IF_MODE_DEPENDENT_ADDRESS
3201: @item GO_IF_MODE_DEPENDENT_ADDRESS (@var{addr}, @var{label})
3202: A C statement or compound statement with a conditional @code{goto
3203: @var{label};} executed if memory address @var{x} (an RTX) can have
3204: different meanings depending on the machine mode of the memory
3205: reference it is used for.
3206:
3207: Autoincrement and autodecrement addresses typically have mode-dependent
3208: effects because the amount of the increment or decrement is the size
3209: of the operand being addressed. Some machines have other mode-dependent
3210: addresses. Many RISC machines have no mode-dependent addresses.
3211:
3212: You may assume that @var{addr} is a valid address for the machine.
3213:
3214: @findex LEGITIMATE_CONSTANT_P
3215: @item LEGITIMATE_CONSTANT_P (@var{x})
3216: A C expression that is nonzero if @var{x} is a legitimate constant for
3217: an immediate operand on the target machine. You can assume that
3218: @var{x} satisfies @code{CONSTANT_P}, so you need not check this. In fact,
3219: @samp{1} is a suitable definition for this macro on machines where
3220: anything @code{CONSTANT_P} is valid.@refill
3221:
3222: @findex LEGITIMATE_PIC_OPERAND_P
3223: @item LEGITIMATE_PIC_OPERAND_P (@var{x})
3224: A C expression that is nonzero if @var{x} is a legitimate immediate
3225: operand on the target machine when generating position independent code.
3226: You can assume that @var{x} satisfies @code{CONSTANT_P}, so you need not
3227: check this. You can also assume @var{flag_pic} is true, so you need not
3228: check it either. You need not define this macro if all constants
3229: (including @code{SYMBOL_REF}) can be immediate operands when generating
3230: position independent code.
3231: @end table
3232:
3233: @node Condition Code, Costs, Addressing Modes, Machine Macros
3234: @section Condition Code Status
3235: @cindex condition code status
3236:
3237: @findex cc_status
3238: The file @file{conditions.h} defines a variable @code{cc_status} to
3239: describe how the condition code was computed (in case the interpretation of
3240: the condition code depends on the instruction that it was set by). This
3241: variable contains the RTL expressions on which the condition code is
3242: currently based, and several standard flags.
3243:
3244: Sometimes additional machine-specific flags must be defined in the machine
3245: description header file. It can also add additional machine-specific
3246: information by defining @code{CC_STATUS_MDEP}.
3247:
3248: @table @code
3249: @findex CC_STATUS_MDEP
3250: @item CC_STATUS_MDEP
3251: C code for a data type which is used for declaring the @code{mdep}
3252: component of @code{cc_status}. It defaults to @code{int}.
3253:
3254: This macro is not used on machines that do not use @code{cc0}.
3255:
3256: @findex CC_STATUS_MDEP_INIT
3257: @item CC_STATUS_MDEP_INIT
3258: A C expression to initialize the @code{mdep} field to ``empty''.
3259: The default definition does nothing, since most machines don't use
3260: the field anyway. If you want to use the field, you should probably
3261: define this macro to initialize it.
3262:
3263: This macro is not used on machines that do not use @code{cc0}.
3264:
3265: @findex NOTICE_UPDATE_CC
3266: @item NOTICE_UPDATE_CC (@var{exp}, @var{insn})
3267: A C compound statement to set the components of @code{cc_status}
3268: appropriately for an insn @var{insn} whose body is @var{exp}. It is
3269: this macro's responsibility to recognize insns that set the condition
3270: code as a byproduct of other activity as well as those that explicitly
3271: set @code{(cc0)}.
3272:
3273: This macro is not used on machines that do not use @code{cc0}.
3274:
3275: If there are insns that do not set the condition code but do alter
3276: other machine registers, this macro must check to see whether they
3277: invalidate the expressions that the condition code is recorded as
3278: reflecting. For example, on the 68000, insns that store in address
3279: registers do not set the condition code, which means that usually
3280: @code{NOTICE_UPDATE_CC} can leave @code{cc_status} unaltered for such
3281: insns. But suppose that the previous insn set the condition code
3282: based on location @samp{a4@@(102)} and the current insn stores a new
3283: value in @samp{a4}. Although the condition code is not changed by
3284: this, it will no longer be true that it reflects the contents of
3285: @samp{a4@@(102)}. Therefore, @code{NOTICE_UPDATE_CC} must alter
3286: @code{cc_status} in this case to say that nothing is known about the
3287: condition code value.
3288:
3289: The definition of @code{NOTICE_UPDATE_CC} must be prepared to deal
3290: with the results of peephole optimization: insns whose patterns are
3291: @code{parallel} RTXs containing various @code{reg}, @code{mem} or
3292: constants which are just the operands. The RTL structure of these
3293: insns is not sufficient to indicate what the insns actually do. What
3294: @code{NOTICE_UPDATE_CC} should do when it sees one is just to run
3295: @code{CC_STATUS_INIT}.
3296:
3297: A possible definition of @code{NOTICE_UPDATE_CC} is to call a function
3298: that looks at an attribute (@pxref{Insn Attributes}) named, for example,
3299: @samp{cc}. This avoids having detailed information about patterns in
3300: two places, the @file{md} file and in @code{NOTICE_UPDATE_CC}.
3301:
3302: @findex EXTRA_CC_MODES
3303: @item EXTRA_CC_MODES
3304: A list of names to be used for additional modes for condition code
3305: values in registers (@pxref{Jump Patterns}). These names are added
3306: to @code{enum machine_mode} and all have class @code{MODE_CC}. By
3307: convention, they should start with @samp{CC} and end with @samp{mode}.
3308:
3309: You should only define this macro if your machine does not use @code{cc0}
3310: and only if additional modes are required.
3311:
3312: @findex EXTRA_CC_NAMES
3313: @item EXTRA_CC_NAMES
3314: A list of C strings giving the names for the modes listed in
3315: @code{EXTRA_CC_MODES}. For example, the Sparc defines this macro and
3316: @code{EXTRA_CC_MODES} as
3317:
3318: @example
3319: #define EXTRA_CC_MODES CC_NOOVmode, CCFPmode
3320: #define EXTRA_CC_NAMES "CC_NOOV", "CCFP"
3321: @end example
3322:
3323: This macro is not required if @code{EXTRA_CC_MODES} is not defined.
3324:
3325: @findex SELECT_CC_MODE
3326: @item SELECT_CC_MODE (@var{op}, @var{x})
3327: Returns a mode from class @code{MODE_CC} to be used when comparison operation
3328: code @var{op} is applied to rtx @var{x}. For example, on the Sparc,
3329: @code{SELECT_CC_MODE} is defined as (see @pxref{Jump Patterns} for a
3330: description of the reason for this definition)
3331:
3332: @example
3333: #define SELECT_CC_MODE(OP,X) \
3334: (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT ? CCFPmode \
3335: : (GET_CODE (X) == PLUS || GET_CODE (X) == MINUS \
3336: || GET_CODE (X) == NEG) \
3337: ? CC_NOOVmode : CCmode)
3338: @end example
3339:
3340: This macro is not required if @code{EXTRA_CC_MODES} is not defined.
3341: @end table
3342:
3343: @node Costs, Sections, Condition Code, Machine Macros
3344: @section Describing Relative Costs of Operations
3345: @cindex costs of instructions
3346: @cindex relative costs
3347: @cindex speed of instructions
3348:
3349: These macros let you describe the relative speed of various operations
3350: on the target machine.
3351:
3352: @table @code
3353: @findex CONST_COSTS
3354: @item CONST_COSTS (@var{x}, @var{code})
3355: A part of a C @code{switch} statement that describes the relative costs
3356: of constant RTL expressions. It must contain @code{case} labels for
3357: expression codes @code{const_int}, @code{const}, @code{symbol_ref},
3358: @code{label_ref} and @code{const_double}. Each case must ultimately
3359: reach a @code{return} statement to return the relative cost of the use
3360: of that kind of constant value in an expression. The cost may depend on
3361: the precise value of the constant, which is available for examination in
3362: @var{x}.
3363:
3364: @var{code} is the expression code---redundant, since it can be
3365: obtained with @code{GET_CODE (@var{x})}.
3366:
3367: @findex RTX_COSTS
3368: @findex COSTS_N_INSNS
3369: @item RTX_COSTS (@var{x}, @var{code})
3370: Like @code{CONST_COSTS} but applies to nonconstant RTL expressions.
3371: This can be used, for example, to indicate how costly a multiply
3372: instruction is. In writing this macro, you can use the construct
3373: @code{COSTS_N_INSNS (@var{n})} to specify a cost equal to @var{n} fast
3374: instructions.
3375:
3376: This macro is optional; do not define it if the default cost assumptions
3377: are adequate for the target machine.
3378:
3379: @findex ADDRESS_COST
3380: @item ADDRESS_COST (@var{address})
3381: An expression giving the cost of an addressing mode that contains
3382: @var{address}. If not defined, the cost is computed from
3383: the @var{address} expression and the @code{CONST_COSTS} values.
3384:
3385: For most CISC machines, the default cost is a good approximation of the
3386: true cost of the addressing mode. However, on RISC machines, all
3387: instructions normally have the same length and execution time. Hence
3388: all addresses will have equal costs.
3389:
3390: In cases where more than one form of an address is known, the form with
3391: the lowest cost will be used. If multiple forms have the same, lowest,
3392: cost, the one that is the most complex will be used.
3393:
3394: For example, suppose an address that is equal to the sum of a register
3395: and a constant is used twice in the same basic block. When this macro
3396: is not defined, the address will be computed in a register and memory
3397: references will be indirect through that register. On machines where
3398: the cost of the addressing mode containing the sum is no higher than
3399: that of a simple indirect reference, this will produce an additional
3400: instruction and possibly require an additional register. Proper
3401: specification of this macro eliminates this overhead for such machines.
3402:
3403: Similar use of this macro is made in strength reduction of loops.
3404:
3405: @var{address} need not be valid as an address. In such a case, the cost
3406: is not relevant and can be any value; invalid addresses need not be
3407: assigned a different cost.
3408:
3409: On machines where an address involving more than one register is as
3410: cheap as an address computation involving only one register, defining
3411: @code{ADDRESS_COST} to reflect this can cause two registers to be live
3412: over a region of code where only one would have been if
3413: @code{ADDRESS_COST} were not defined in that manner. This effect should
3414: be considered in the definition of this macro. Equivalent costs should
3415: probably only be given to addresses with different numbers of registers
3416: on machines with lots of registers.
3417:
3418: This macro will normally either not be defined or be defined as a
3419: constant.
3420:
3421: @findex REGISTER_MOVE_COST
3422: @item REGISTER_MOVE_COST (@var{from}, @var{to})
3423: A C expression for the cost of moving data from a register in class
3424: @var{from} to one in class @var{to}. The classes are expressed using
3425: the enumeration values such as @code{GENERAL_REGS}. A value of 2 is the
3426: default; other values are interpreted relative to that.
3427:
3428: It is not required that the cost always equal 2 when @var{from} is the
3429: same as @var{to}; on some machines it is expensive to move between
3430: registers if they are not general registers.
3431:
3432: If reload sees an insn consisting of a single @code{set} between two
3433: hard registers, and if @code{REGISTER_MOVE_COST} applied to their
3434: classes returns a value of 2, reload does not check to ensure that the
3435: constraints of the insn are met. Setting a cost of other than 2 will
3436: allow reload to verify that the constraints are met. You should do this
3437: if the @samp{mov@var{m}} pattern's constraints do not allow such copying.
3438:
3439: @findex MEMORY_MOVE_COST
3440: @item MEMORY_MOVE_COST (@var{m})
3441: A C expression for the cost of moving data of mode @var{m} between a
3442: register and memory. A value of 2 is the default; this cost is relative
3443: to those in @code{REGISTER_MOVE_COST}.
3444:
3445: If moving between registers and memory is more expensive than between
3446: two registers, you should define this macro to express the relative cost.
3447:
3448: @findex BRANCH_COST
3449: @item BRANCH_COST
3450: A C expression for the cost of a branch instruction. A value of 1 is
3451: the default; other values are interpreted relative to that.
3452: @end table
3453:
3454: Here are additional macros which do not specify precise relative costs,
3455: but only that certain actions are more expensive than GNU CC would
3456: ordinarily expect.
3457:
3458: @table @code
3459: @findex SLOW_BYTE_ACCESS
3460: @item SLOW_BYTE_ACCESS
3461: Define this macro as a C expression which is nonzero if accessing less
3462: than a word of memory (i.e. a @code{char} or a @code{short}) is no
3463: faster than accessing a word of memory, i.e., if such access
3464: require more than one instruction or if there is no difference in cost
3465: between byte and (aligned) word loads.
3466:
3467: When this macro is not defined, the compiler will access a field by
3468: finding the smallest containing object; when it is defined, a fullword
3469: load will be used if alignment permits. Unless bytes accesses are
3470: faster than word accesses, using word accesses is preferable since it
3471: may eliminate subsequent memory access if subsequent accesses occur to
3472: other fields in the same word of the structure, but to different bytes.
3473:
3474: @findex SLOW_ZERO_EXTEND
3475: @item SLOW_ZERO_EXTEND
3476: Define this macro if zero-extension (of a @code{char} or @code{short}
3477: to an @code{int}) can be done faster if the destination is a register
3478: that is known to be zero.
3479:
3480: If you define this macro, you must have instruction patterns that
3481: recognize RTL structures like this:
3482:
3483: @example
3484: (set (strict_low_part (subreg:QI (reg:SI @dots{}) 0)) @dots{})
3485: @end example
3486:
3487: @noindent
3488: and likewise for @code{HImode}.
3489:
3490: @findex SLOW_UNALIGNED_ACCESS
3491: @item SLOW_UNALIGNED_ACCESS
3492: Define this macro if unaligned accesses have a cost many times greater
3493: than aligned accesses, for example if they are emulated in a trap
3494: handler.
3495:
3496: When this macro is defined, the compiler will act as if
3497: @code{STRICT_ALIGNMENT} were defined when generating code for block
3498: moves. This can cause significantly more instructions to be produced.
3499: Therefore, do not define this macro if unaligned accesses only add a
3500: cycle or two to the time for a memory access.
3501:
3502: @findex DONT_REDUCE_ADDR
3503: @item DONT_REDUCE_ADDR
3504: Define this macro to inhibit strength reduction of memory addresses.
3505: (On some machines, such strength reduction seems to do harm rather
3506: than good.)
3507:
3508: @findex MOVE_RATIO
3509: @item MOVE_RATIO
3510: The number of scalar move insns which should be generated instead of a
3511: string move insn or a library call. Increasing the value will always
3512: make code faster, but eventually incurs high cost in increased code size.
3513:
3514: If you don't define this, a reasonable default is used.
3515:
3516: @findex NO_FUNCTION_CSE
3517: @item NO_FUNCTION_CSE
3518: Define this macro if it is as good or better to call a constant
3519: function address than to call an address kept in a register.
3520:
3521: @findex NO_RECURSIVE_FUNCTION_CSE
3522: @item NO_RECURSIVE_FUNCTION_CSE
3523: Define this macro if it is as good or better for a function to call
3524: itself with an explicit address than to call an address kept in a
3525: register.
3526: @end table
3527:
3528: @node Sections, PIC, Costs, Machine Macros
3529: @section Dividing the Output into Sections (Texts, Data, @dots{})
3530:
3531: An object file is divided into sections containing different types of
3532: data. In the most common case, there are three sections: the @dfn{text
3533: section}, which holds instructions and read-only data; the @dfn{data
3534: section}, which holds initialized writable data; and the @dfn{bss
3535: section}, which holds uninitialized data. Some systems have other kinds
3536: of sections.
3537:
3538: The compiler must tell the assembler when to switch sections. These
3539: macros control what commands to output to tell the assembler this. You
3540: can also define additional sections.
3541:
3542: @table @code
3543: @findex TEXT_SECTION_ASM_OP
3544: @item TEXT_SECTION_ASM_OP
3545: A C string constant for the assembler operation that should precede
3546: instructions and read-only data. Normally @code{".text"} is right.
3547:
3548: @findex DATA_SECTION_ASM_OP
3549: @item DATA_SECTION_ASM_OP
3550: A C string constant for the assembler operation to identify the
3551: following data as writable initialized data. Normally @code{".data"}
3552: is right.
3553:
3554: @findex SHARED_SECTION_ASM_OP
3555: @item SHARED_SECTION_ASM_OP
3556: If defined, a C string constant for the assembler operation to identify the
3557: following data as shared data. If not defined, @code{DATA_SECTION_ASM_OP}
3558: will be used.
3559:
3560: @findex INIT_SECTION_ASM_OP
3561: @item INIT_SECTION_ASM_OP
3562: If defined, a C string constant for the assembler operation to identify the
3563: following data as initialization code. If not defined, GNU CC will
3564: assume such a section does not exist.
3565:
3566: @findex EXTRA_SECTIONS
3567: @findex in_text
3568: @findex in_data
3569: @item EXTRA_SECTIONS
3570: A list of names for sections other than the standard two, which are
3571: @code{in_text} and @code{in_data}. You need not define this macro
3572: on a system with no other sections (that GCC needs to use).
3573:
3574: @findex EXTRA_SECTION_FUNCTIONS
3575: @findex text_section
3576: @findex data_section
3577: @item EXTRA_SECTION_FUNCTIONS
3578: One or more functions to be defined in @file{varasm.c}. These
3579: functions should do jobs analogous to those of @code{text_section} and
3580: @code{data_section}, for your additional sections. Do not define this
3581: macro if you do not define @code{EXTRA_SECTIONS}.
3582:
3583: @findex READONLY_DATA_SECTION
3584: @item READONLY_DATA_SECTION
3585: On most machines, read-only variables, constants, and jump tables are
3586: placed in the text section. If this is not the case on your machine,
3587: this macro should be defined to be the name of a function (either
3588: @code{data_section} or a function defined in @code{EXTRA_SECTIONS}) that
3589: switches to the section to be used for read-only items.
3590:
3591: If these items should be placed in the text section, this macro should
3592: not be defined.
3593:
3594: @findex SELECT_SECTION
3595: @item SELECT_SECTION (@var{exp}, @var{reloc})
3596: A C statement or statements to switch to the appropriate section for
3597: output of @var{exp}. You can assume that @var{exp} is either a
3598: @code{VAR_DECL} node or a constant of some sort. @var{reloc}
3599: indicates whether the initial value of @var{exp} requires link-time
3600: relocations. Select the section by calling @code{text_section} or one
3601: of the alternatives for other sections.
3602:
3603: Do not define this macro if you put all read-only variables and
3604: constants in the read-only data section (usually the text section).
3605:
3606: @findex SELECT_RTX_SECTION
3607: @item SELECT_RTX_SECTION (@var{mode}, @var{rtx})
3608: A C statement or statements to switch to the appropriate section for
3609: output of @var{rtx} in mode @var{mode}. You can assume that @var{rtx}
3610: is some kind of constant in RTL. The argument @var{mode} is redundant
3611: except in the case of a @code{const_int} rtx. Select the section by
3612: calling @code{text_section} or one of the alternatives for other
3613: sections.
3614:
3615: Do not define this macro if you put all constants in the read-only
3616: data section.
3617:
3618: @findex JUMP_TABLES_IN_TEXT_SECTION
3619: @item JUMP_TABLES_IN_TEXT_SECTION
3620: Define this macro if jump tables (for @code{tablejump} insns) should be
3621: output in the text section, along with the assembler instructions.
3622: Otherwise, the readonly data section is used.
3623:
3624: This macro is irrelevant if there is no separate readonly data section.
3625:
3626: @findex ENCODE_SECTION_INFO
3627: @item ENCODE_SECTION_INFO (@var{decl})
3628: Define this macro if references to a symbol must be treated differently
3629: depending on something about the variable or function named by the
3630: symbol (such as what section it is in).
3631:
3632: The macro definition, if any, is executed immediately after the rtl for
3633: @var{decl} has been created and stored in @code{DECL_RTL (@var{decl})}.
3634: The value of the rtl will be a @code{mem} whose address is a
3635: @code{symbol_ref}.
3636:
3637: @cindex @code{SYMBOL_REF_FLAG}, in @code{ENCODE_SECTION_INFO}
3638: The usual thing for this macro to do is to record a flag in the
3639: @code{symbol_ref} (such as @code{SYMBOL_REF_FLAG}) or to store a
3640: modified name string in the @code{symbol_ref} (if one bit is not enough
3641: information).
3642: @end table
3643:
3644: @node PIC, Assembler Format, Sections, Machine Macros
3645: @section Position Independent Code
3646: @cindex position independent code
3647: @cindex PIC
3648:
3649: This section describes macros that help implement generation of position
3650: independent code. Simply defining these macros is not enough to
3651: generate valid PIC; you must also add support to the macros
3652: @code{GO_IF_LEGITIMATE_ADDRESS} and @code{LEGITIMIZE_ADDRESS}, and
3653: @code{PRINT_OPERAND_ADDRESS} as well. You must modify the definition of
3654: @samp{movsi} to do something appropriate when the source operand
3655: contains a symbolic address. You may also need to alter the handling of
3656: switch statements so that they use relative addresses.
3657:
3658: @table @code
3659: @findex PIC_OFFSET_TABLE_REGNUM
3660: @item PIC_OFFSET_TABLE_REGNUM
3661: The register number of the register used to address a table of static
3662: data addresses in memory. In some cases this register is defined by a
3663: processor's ``application binary interface'' (ABI). When this macro
3664: is defined, RTL is generated for this register once, as with the stack
3665: pointer and frame pointer registers. If this macro is not defined, it
3666: is up to the machine-dependent files to allocate such a register (if
3667: necessary).
3668:
3669: @findex FINALIZE_PIC
3670: @item FINALIZE_PIC
3671: By generating position-independent code, when two different programs (A
3672: and B) share a common library (libC.a), the text of the library can be
3673: shared whether or not the library is linked at the same address for both
3674: programs. In some of these environments, position-independent code
3675: requires not only the use of different addressing modes, but also
3676: special code to enable the use of these addressing modes.
3677:
3678: The @code{FINALIZE_PIC} macro serves as a hook to emit these special
3679: codes once the function is being compiled into assembly code, but not
3680: before. (It is not done before, because in the case of compiling an
3681: inline function, it would lead to multiple PIC prologues being
3682: included in functions which used inline functions and were compiled to
3683: assembly language.)
3684:
3685: @end table
3686:
3687: @node Assembler Format, Debugging Info, PIC, Machine Macros
3688: @section Defining the Output Assembler Language
3689:
3690: This section describes macros whose principal purpose is to describe how
3691: to write instructions in assembler language--rather than what the
3692: instructions do.
3693:
3694: @menu
3695: * File Framework:: Structural information for the assembler file.
3696: * Data Output:: Output of constants (numbers, strings, addresses).
3697: * Uninitialized Data:: Output of uninitialized variables.
3698: * Label Output:: Output and generation of labels.
3699: * Constructor Output:: Output of initialization and termination routines.
3700: * Instruction Output:: Output of actual instructions.
3701: * Dispatch Tables:: Output of jump tables.
3702: * Alignment Output:: Pseudo ops for alignment and skipping data.
3703: @end menu
3704:
3705: @node File Framework, Data Output, Assembler Format, Assembler Format
3706: @subsection The Overall Framework of an Assembler File
3707: @cindex assembler format
3708: @cindex output of assembler code
3709:
3710: @table @code
3711: @findex ASM_FILE_START
3712: @item ASM_FILE_START (@var{stream})
3713: A C expression which outputs to the stdio stream @var{stream}
3714: some appropriate text to go at the start of an assembler file.
3715:
3716: Normally this macro is defined to output a line containing
3717: @samp{#NO_APP}, which is a comment that has no effect on most
3718: assemblers but tells the GNU assembler that it can save time by not
3719: checking for certain assembler constructs.
3720:
3721: On systems that use SDB, it is necessary to output certain commands;
3722: see @file{attasm.h}.
3723:
3724: @findex ASM_FILE_END
3725: @item ASM_FILE_END (@var{stream})
3726: A C expression which outputs to the stdio stream @var{stream}
3727: some appropriate text to go at the end of an assembler file.
3728:
3729: If this macro is not defined, the default is to output nothing
3730: special at the end of the file. Most systems don't require any
3731: definition.
3732:
3733: On systems that use SDB, it is necessary to output certain commands;
3734: see @file{attasm.h}.
3735:
3736: @findex ASM_IDENTIFY_GCC
3737: @item ASM_IDENTIFY_GCC (@var{file})
3738: A C statement to output assembler commands which will identify
3739: the object file as having been compiled with GNU CC (or another
3740: GNU compiler).
3741:
3742: If you don't define this macro, the string @samp{gcc_compiled.:}
3743: is output. This string is calculated to define a symbol which,
3744: on BSD systems, will never be defined for any other reason.
3745: GDB checks for the presence of this symbol when reading the
3746: symbol table of an executable.
3747:
3748: On non-BSD systems, you must arrange communication with GDB in
3749: some other fashion. If GDB is not used on your system, you can
3750: define this macro with an empty body.
3751:
3752: @findex ASM_COMMENT_START
3753: @item ASM_COMMENT_START
3754: A C string constant describing how to begin a comment in the target
3755: assembler language. The compiler assumes that the comment will end at
3756: the end of the line.
3757:
3758: @findex ASM_APP_ON
3759: @item ASM_APP_ON
3760: A C string constant for text to be output before each @code{asm}
3761: statement or group of consecutive ones. Normally this is
3762: @code{"#APP"}, which is a comment that has no effect on most
3763: assemblers but tells the GNU assembler that it must check the lines
3764: that follow for all valid assembler constructs.
3765:
3766: @findex ASM_APP_OFF
3767: @item ASM_APP_OFF
3768: A C string constant for text to be output after each @code{asm}
3769: statement or group of consecutive ones. Normally this is
3770: @code{"#NO_APP"}, which tells the GNU assembler to resume making the
3771: time-saving assumptions that are valid for ordinary compiler output.
3772:
3773: @findex ASM_OUTPUT_SOURCE_FILENAME
3774: @item ASM_OUTPUT_SOURCE_FILENAME (@var{stream}, @var{name})
3775: A C statement to output COFF information or DWARF debugging information
3776: which indicates that filename @var{name} is the current source file to
3777: the stdio stream @var{stream}.
3778:
3779: This macro need not be defined if the standard form of output
3780: for the file format in use is appropriate.
3781:
3782: @findex ASM_OUTPUT_SOURCE_LINE
3783: @item ASM_OUTPUT_SOURCE_LINE (@var{stream}, @var{line})
3784: A C statement to output DBX or SDB debugging information before code
3785: for line number @var{line} of the current source file to the
3786: stdio stream @var{stream}.
3787:
3788: This macro need not be defined if the standard form of debugging
3789: information for the debugger in use is appropriate.
3790:
3791: @findex ASM_OUTPUT_IDENT
3792: @item ASM_OUTPUT_IDENT (@var{stream}, @var{string})
3793: A C statement to output something to the assembler file to handle a
3794: @samp{#ident} directive containing the text @var{string}. If this
3795: macro is not defined, nothing is output for a @samp{#ident} directive.
3796:
3797: @findex OBJC_PROLOGUE
3798: @item OBJC_PROLOGUE
3799: A C statement to output any assembler statements which are required to
3800: precede any Objective C object definitions or message sending. The
3801: statement is executed only when compiling an Objective C program.
3802: @end table
3803:
3804: @node Data Output, Uninitialized Data, File Framework, Assembler Format
3805: @subsection Output of Data
3806:
3807: @table @code
3808: @findex ASM_OUTPUT_LONG_DOUBLE
3809: @findex ASM_OUTPUT_DOUBLE
3810: @findex ASM_OUTPUT_FLOAT
3811: @item ASM_OUTPUT_LONG_DOUBLE (@var{stream}, @var{value})
3812: @item ASM_OUTPUT_DOUBLE (@var{stream}, @var{value})
3813: @item ASM_OUTPUT_FLOAT (@var{stream}, @var{value})
3814: A C statement to output to the stdio stream @var{stream} an assembler
3815: instruction to assemble a floating-point constant of @code{TFmode},
3816: @code{DFmode} or @code{SFmode}, respectively, whose value is
3817: @var{value}. @var{value} will be a C expression of type
3818: @code{REAL_VALUE__TYPE}, usually @code{double}.@refill
3819:
3820: @findex ASM_OUTPUT_QUADRUPLE_INT
3821: @findex ASM_OUTPUT_DOUBLE_INT
3822: @findex ASM_OUTPUT_INT
3823: @findex ASM_OUTPUT_SHORT
3824: @findex ASM_OUTPUT_CHAR
3825: @findex output_addr_const
3826: @item ASM_OUTPUT_QUADRUPLE_INT (@var{stream}, @var{exp})
3827: @item ASM_OUTPUT_DOUBLE_INT (@var{stream}, @var{exp})
3828: @item ASM_OUTPUT_INT (@var{stream}, @var{exp})
3829: @itemx ASM_OUTPUT_SHORT (@var{stream}, @var{exp})
3830: @itemx ASM_OUTPUT_CHAR (@var{stream}, @var{exp})
3831: A C statement to output to the stdio stream @var{stream} an assembler
3832: instruction to assemble an integer of 16, 8, 4, 2 or 1 bytes,
3833: respectively, whose value is @var{value}. The argument @var{exp} will
3834: be an RTL expression which represents a constant value. Use
3835: @samp{output_addr_const (@var{stream}, @var{exp})} to output this value
3836: as an assembler expression.@refill
3837:
3838: For sizes larger than @code{UNITS_PER_WORD}, if the action of a macro
3839: would be identical to repeatedly calling the macro corresponding to
3840: a size of @code{UNITS_PER_WORD}, once for each word, you need not define
3841: the macro.
3842:
3843: @findex ASM_OUTPUT_BYTE
3844: @item ASM_OUTPUT_BYTE (@var{stream}, @var{value})
3845: A C statement to output to the stdio stream @var{stream} an assembler
3846: instruction to assemble a single byte containing the number @var{value}.
3847:
3848: @findex ASM_BYTE_OP
3849: @item ASM_BYTE_OP
3850: A C string constant giving the pseudo-op to use for a sequence of
3851: single-byte constants. If this macro is not defined, the default is
3852: @code{"byte"}.
3853:
3854: @findex ASM_OUTPUT_ASCII
3855: @item ASM_OUTPUT_ASCII (@var{stream}, @var{ptr}, @var{len})
3856: A C statement to output to the stdio stream @var{stream} an assembler
3857: instruction to assemble a string constant containing the @var{len}
3858: bytes at @var{ptr}. @var{ptr} will be a C expression of type
3859: @code{char *} and @var{len} a C expression of type @code{int}.
3860:
3861: If the assembler has a @code{.ascii} pseudo-op as found in the
3862: Berkeley Unix assembler, do not define the macro
3863: @code{ASM_OUTPUT_ASCII}.
3864:
3865: @findex ASM_OUTPUT_POOL_PROLOGUE
3866: @item ASM_OUTPUT_POOL_PROLOGUE (@var{file} @var{funname} @var{fundecl} @var{size})
3867: A C statement to output assembler commands to define the start of the
3868: constant pool for a function. @var{funname} is a string giving
3869: the name of the function. Should the return type of the function
3870: be required, it can be obtained via @var{fundecl}. @var{size}
3871: is the size, in bytes, of the constant pool that will be written
3872: immediately after this call.
3873:
3874: If no constant-pool prefix is required, the usual case, this macro need
3875: not be defined.
3876:
3877: @findex ASM_OUTPUT_SPECIAL_POOL_ENTRY
3878: @item ASM_OUTPUT_SPECIAL_POOL_ENTRY (@var{file}, @var{x}, @var{mode}, @var{align}, @var{labelno}, @var{jumpto})
3879: A C statement (with or without semicolon) to output a constant in the
3880: constant pool, if it needs special treatment. (This macro need not do
3881: anything for RTL expressions that can be output normally.)
3882:
3883: The argument @var{file} is the standard I/O stream to output the
3884: assembler code on. @var{x} is the RTL expression for the constant to
3885: output, and @var{mode} is the machine mode (in case @var{x} is a
3886: @samp{const_int}). @var{align} is the required alignment for the value
3887: @var{x}; you should output an assembler directive to force this much
3888: alignment.
3889:
3890: The argument @var{labelno} is a number to use in an internal label for
3891: the address of this pool entry. The definition of this macro is
3892: responsible for outputting the label definition at the proper place.
3893: Here is how to do this:
3894:
3895: @example
3896: ASM_OUTPUT_INTERNAL_LABEL (@var{file}, "LC", @var{labelno});
3897: @end example
3898:
3899: When you output a pool entry specially, you should end with a
3900: @code{goto} to the label @var{jumpto}. This will prevent the same pool
3901: entry from being output a second time in the usual manner.
3902:
3903: You need not define this macro if it would do nothing.
3904:
3905: @findex ASM_OPEN_PAREN
3906: @findex ASM_CLOSE_PAREN
3907: @item ASM_OPEN_PAREN
3908: @itemx ASM_CLOSE_PAREN
3909: These macros are defined as C string constant, describing the syntax
3910: in the assembler for grouping arithmetic expressions. The following
3911: definitions are correct for most assemblers:
3912:
3913: @example
3914: #define ASM_OPEN_PAREN "("
3915: #define ASM_CLOSE_PAREN ")"
3916: @end example
3917: @end table
3918:
3919: @node Uninitialized Data, Label Output, Data Output, Assembler Format
3920: @subsection Output of Uninitialized Variables
3921:
3922: Each of the macros in this section is used to do the whole job of
3923: outputting a single uninitialized variable.
3924:
3925: @table @code
3926: @findex ASM_OUTPUT_COMMON
3927: @item ASM_OUTPUT_COMMON (@var{stream}, @var{name}, @var{size}, @var{rounded})
3928: A C statement (sans semicolon) to output to the stdio stream
3929: @var{stream} the assembler definition of a common-label named
3930: @var{name} whose size is @var{size} bytes. The variable @var{rounded}
3931: is the size rounded up to whatever alignment the caller wants.
3932:
3933: Use the expression @code{assemble_name (@var{stream}, @var{name})} to
3934: output the name itself; before and after that, output the additional
3935: assembler syntax for defining the name, and a newline.
3936:
3937: This macro controls how the assembler definitions of uninitialized
3938: global variables are output.
3939:
3940: @findex ASM_OUTPUT_ALIGNED_COMMON
3941: @item ASM_OUTPUT_ALIGNED_COMMON (@var{stream}, @var{name}, @var{size}, @var{alignment})
3942: Like @code{ASM_OUTPUT_COMMON} except takes the required alignment as a
3943: separate, explicit argument. If you define this macro, it is used in
3944: place of @code{ASM_OUTPUT_COMMON}, and gives you more flexibility in
3945: handling the required alignment of the variable.
3946:
3947: @findex ASM_OUTPUT_SHARED_COMMON
3948: @item ASM_OUTPUT_SHARED_COMMON (@var{stream}, @var{name}, @var{size}, @var{rounded})
3949: If defined, it is similar to @code{ASM_OUTPUT_COMMON}, except that it
3950: is used when @var{name} is shared. If not defined, @code{ASM_OUTPUT_COMMON}
3951: will be used.
3952:
3953: @findex ASM_OUTPUT_LOCAL
3954: @item ASM_OUTPUT_LOCAL (@var{stream}, @var{name}, @var{size}, @var{rounded})
3955: A C statement (sans semicolon) to output to the stdio stream
3956: @var{stream} the assembler definition of a local-common-label named
3957: @var{name} whose size is @var{size} bytes. The variable @var{rounded}
3958: is the size rounded up to whatever alignment the caller wants.
3959:
3960: Use the expression @code{assemble_name (@var{stream}, @var{name})} to
3961: output the name itself; before and after that, output the additional
3962: assembler syntax for defining the name, and a newline.
3963:
3964: This macro controls how the assembler definitions of uninitialized
3965: static variables are output.
3966:
3967: @findex ASM_OUTPUT_ALIGNED_LOCAL
3968: @item ASM_OUTPUT_ALIGNED_LOCAL (@var{stream}, @var{name}, @var{size}, @var{alignment})
3969: Like @code{ASM_OUTPUT_LOCAL} except takes the required alignment as a
3970: separate, explicit argument. If you define this macro, it is used in
3971: place of @code{ASM_OUTPUT_LOCAL}, and gives you more flexibility in
3972: handling the required alignment of the variable.
3973:
3974: @findex ASM_OUTPUT_SHARED_LOCAL
3975: @item ASM_OUTPUT_SHARED_LOCAL (@var{stream}, @var{name}, @var{size}, @var{rounded})
3976: If defined, it is similar to @code{ASM_OUTPUT_LOCAL}, except that it
3977: is used when @var{name} is shared. If not defined, @code{ASM_OUTPUT_LOCAL}
3978: will be used.
3979: @end table
3980:
3981: @node Label Output, Constructor Output, Uninitialized Data, Assembler Format
3982: @subsection Output and Generation of Labels
3983:
3984: @table @code
3985: @findex ASM_OUTPUT_LABEL
3986: @findex assemble_name
3987: @item ASM_OUTPUT_LABEL (@var{stream}, @var{name})
3988: A C statement (sans semicolon) to output to the stdio stream
3989: @var{stream} the assembler definition of a label named @var{name}.
3990: Use the expression @code{assemble_name (@var{stream}, @var{name})} to
3991: output the name itself; before and after that, output the additional
3992: assembler syntax for defining the name, and a newline.
3993:
3994: @findex ASM_DECLARE_FUNCTION_NAME
3995: @item ASM_DECLARE_FUNCTION_NAME (@var{stream}, @var{name}, @var{decl})
3996: A C statement (sans semicolon) to output to the stdio stream
3997: @var{stream} any text necessary for declaring the name @var{name} of a
3998: function which is being defined. This macro is responsible for
3999: outputting the label definition (perhaps using
4000: @code{ASM_OUTPUT_LABEL}). The argument @var{decl} is the
4001: @code{FUNCTION_DECL} tree node representing the function.
4002:
4003: If this macro is not defined, then the function name is defined in the
4004: usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
4005:
4006: @findex ASM_DECLARE_FUNCTION_SIZE
4007: @item ASM_DECLARE_FUNCTION_SIZE (@var{stream}, @var{name}, @var{decl})
4008: A C statement (sans semicolon) to output to the stdio stream
4009: @var{stream} any text necessary for declaring the size of a function
4010: which is being defined. The argument @var{name} is the name of the
4011: function. The argument @var{decl} is the @code{FUNCTION_DECL} tree node
4012: representing the function.
4013:
4014: If this macro is not defined, then the function size is not defined.
4015:
4016: @findex ASM_DECLARE_OBJECT_NAME
4017: @item ASM_DECLARE_OBJECT_NAME (@var{stream}, @var{name}, @var{decl})
4018: A C statement (sans semicolon) to output to the stdio stream
4019: @var{stream} any text necessary for declaring the name @var{name} of an
4020: initialized variable which is being defined. This macro must output the
4021: label definition (perhaps using @code{ASM_OUTPUT_LABEL}). The argument
4022: @var{decl} is the @code{VAR_DECL} tree node representing the variable.
4023:
4024: If this macro is not defined, then the variable name is defined in the
4025: usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
4026:
4027: @findex ASM_GLOBALIZE_LABEL
4028: @item ASM_GLOBALIZE_LABEL (@var{stream}, @var{name})
4029: A C statement (sans semicolon) to output to the stdio stream
4030: @var{stream} some commands that will make the label @var{name} global;
4031: that is, available for reference from other files. Use the expression
4032: @code{assemble_name (@var{stream}, @var{name})} to output the name
4033: itself; before and after that, output the additional assembler syntax
4034: for making that name global, and a newline.
4035:
4036: @findex ASM_OUTPUT_EXTERNAL
4037: @item ASM_OUTPUT_EXTERNAL (@var{stream}, @var{decl}, @var{name})
4038: A C statement (sans semicolon) to output to the stdio stream
4039: @var{stream} any text necessary for declaring the name of an external
4040: symbol named @var{name} which is referenced in this compilation but
4041: not defined. The value of @var{decl} is the tree node for the
4042: declaration.
4043:
4044: This macro need not be defined if it does not need to output anything.
4045: The GNU assembler and most Unix assemblers don't require anything.
4046:
4047: @findex ASM_OUTPUT_EXTERNAL_LIBCALL
4048: @item ASM_OUTPUT_EXTERNAL_LIBCALL (@var{stream}, @var{symref})
4049: A C statement (sans semicolon) to output on @var{stream} an assembler
4050: pseudo-op to declare a library function name external. The name of the
4051: library function is given by @var{symref}, which has type @code{rtx} and
4052: is a @code{symbol_ref}.
4053:
4054: This macro need not be defined if it does not need to output anything.
4055: The GNU assembler and most Unix assemblers don't require anything.
4056:
4057: @findex ASM_OUTPUT_LABELREF
4058: @item ASM_OUTPUT_LABELREF (@var{stream}, @var{name})
4059: A C statement (sans semicolon) to output to the stdio stream
4060: @var{stream} a reference in assembler syntax to a label named
4061: @var{name}. This should add @samp{_} to the front of the name, if that
4062: is customary on your operating system, as it is in most Berkeley Unix
4063: systems. This macro is used in @code{assemble_name}.
4064:
4065: @findex ASM_OUTPUT_LABELREF_AS_INT
4066: @item ASM_OUTPUT_LABELREF_AS_INT (@var{file}, @var{label})
4067: Define this macro for systems that use the program @code{collect2}.
4068: The definition should be a C statement to output a word containing
4069: a reference to the label @var{label}.
4070:
4071: @findex ASM_GENERATE_INTERNAL_LABEL
4072: @item ASM_GENERATE_INTERNAL_LABEL (@var{string}, @var{prefix}, @var{num})
4073: A C statement to store into the string @var{string} a label whose name
4074: is made from the string @var{prefix} and the number @var{num}.
4075:
4076: This string, when output subsequently by @code{ASM_OUTPUT_LABELREF},
4077: should produce the same output that @code{ASM_OUTPUT_INTERNAL_LABEL}
4078: would produce with the same @var{prefix} and @var{num}.
4079:
4080: @findex ASM_OUTPUT_INTERNAL_LABEL
4081: @item ASM_OUTPUT_INTERNAL_LABEL (@var{stream}, @var{prefix}, @var{num})
4082: A C statement to output to the stdio stream @var{stream} a label whose
4083: name is made from the string @var{prefix} and the number @var{num}.
4084: These labels are used for internal purposes, and there is no reason
4085: for them to appear in the symbol table of the object file. On many
4086: systems, the letter @samp{L} at the beginning of a label has this
4087: effect. The usual definition of this macro is as follows:
4088:
4089: @example
4090: fprintf (@var{stream}, "L%s%d:\n", @var{prefix}, @var{num})
4091: @end example
4092:
4093: @findex ASM_FORMAT_PRIVATE_NAME
4094: @item ASM_FORMAT_PRIVATE_NAME (@var{outvar}, @var{name}, @var{number})
4095: A C expression to assign to @var{outvar} (which is a variable of type
4096: @code{char *}) a newly allocated string made from the string
4097: @var{name} and the number @var{number}, with some suitable punctuation
4098: added. Use @code{alloca} to get space for the string.
4099:
4100: This string will be used as the argument to @code{ASM_OUTPUT_LABELREF}
4101: to produce an assembler label for an internal static variable whose
4102: name is @var{name}. Therefore, the string must be such as to result
4103: in valid assembler code. The argument @var{number} is different each
4104: time this macro is executed; it prevents conflicts between
4105: similarly-named internal static variables in different scopes.
4106:
4107: Ideally this string should not be a valid C identifier, to prevent any
4108: conflict with the user's own symbols. Most assemblers allow periods
4109: or percent signs in assembler symbols; putting at least one of these
4110: between the name and the number will suffice.
4111:
4112: @findex OBJC_GEN_METHOD_LABEL
4113: @item OBJC_GEN_METHOD_LABEL (@var{buf}, @var{is_inst}, @var{class_name}, @var{cat_name}, @var{sel_name})
4114: Define this macro to override the default assembler names used for
4115: Objective C methods.
4116:
4117: The default name is a unique method number followed by the name of the
4118: class (e.g.@: @samp{_1_Foo}). For methods in categories, the name of
4119: the category is also included in the assembler name (e.g.@:
4120: @samp{_1_Foo_Bar}).
4121:
4122: These names are safe on most systems, but make debugging difficult since
4123: the method's selector is not present in the name. Therefore, particular
4124: systems define other ways of computing names.
4125:
4126: @var{buf} is a buffer in which to store the name (256 chars max);
4127: @var{is_inst} specifies whether the method is an instance method or a
4128: class method; @var{class_name} is the name of the class; @var{cat_name}
4129: is the name of the category (or NULL if the method is not in a category);
4130: and @var{sel_name} is the name of the selector.
4131:
4132: On systems where the assembler can handle quoted names, you can use this
4133: macro to provide more human-readable names.
4134: @end table
4135:
4136: @node Constructor Output, Instruction Output, Label Output, Assembler Format
4137: @subsection Output of Initialization Routines
4138: @cindex initialization routines
4139: @cindex termination routines
4140: @cindex constructors, output of
4141: @cindex destructors, output of
4142:
4143: The compiled code for certain languages includes @dfn{constructors}
4144: (also called @dfn{initialization routines})---functions to initialize
4145: data in the program when the program is started. These functions need
4146: to be called before the program is ``started''---that is to say, before
4147: @code{main} is called.
4148:
4149: Compiling some languages generates @dfn{destructors} (also called
4150: @dfn{termination routines}) that should be called when the program
4151: terminates.
4152:
4153: To make the initialization and termination functions work, the compiler
4154: must output something in the assembler code to cause those functions to
4155: be called at the appropriate time. When you port the compiler to a new
4156: system, you need to specify what assembler code is needed to do this.
4157:
4158: Here are the two macros you should define if necessary:
4159:
4160: @table @code
4161: @item ASM_OUTPUT_CONSTRUCTOR (@var{stream}, @var{name})
4162: @findex ASM_OUTPUT_CONSTRUCTOR
4163: Define this macro as a C statement to output on the stream @var{stream}
4164: the assembler code to arrange to call the function named @var{name} at
4165: initialization time.
4166:
4167: Assume that @var{name} is the name of a C function generated
4168: automatically by the compiler. This function takes no arguments. Use
4169: the function @code{assemble_name} to output the name @var{name}; this
4170: performs any system-specific syntactic transformations such as adding an
4171: underscore.
4172:
4173: If you don't define this macro, nothing special is output to arrange to
4174: call the function. This is correct when the function will be called in
4175: some other manner---for example, by means of the @code{collect} program,
4176: which looks through the symbol table to find these functions by their
4177: names. If you want to use @code{collect}, then you need to arrange for
4178: it to be built and installed and used on your system.
4179:
4180: @item ASM_OUTPUT_DESTRUCTOR (@var{stream}, @var{name})
4181: @findex ASM_OUTPUT_DESTRUCTOR
4182: This is like @code{ASM_OUTPUT_CONSTRUCTOR} but used for termination
4183: functions rather than initialization functions.
4184: @end table
4185:
4186: @node Instruction Output, Dispatch Tables, Constructor Output, Assembler Format
4187: @subsection Output of Assembler Instructions
4188:
4189: @table @code
4190: @findex REGISTER_NAMES
4191: @item REGISTER_NAMES
4192: A C initializer containing the assembler's names for the machine
4193: registers, each one as a C string constant. This is what translates
4194: register numbers in the compiler into assembler language.
4195:
4196: @findex ADDITIONAL_REGISTER_NAMES
4197: @item ADDITIONAL_REGISTER_NAMES
4198: If defined, a C initializer for an array of structures containing a name
4199: and a register number. This macro defines additional names for hard
4200: registers, thus allowing the @code{asm} option in declarations to refer
4201: to registers using alternate names.
4202:
4203: @findex ASM_OUTPUT_OPCODE
4204: @item ASM_OUTPUT_OPCODE (@var{stream}, @var{ptr})
4205: Define this macro if you are using an unusual assembler that
4206: requires different names for the machine instructions.
4207:
4208: The definition is a C statement or statements which output an
4209: assembler instruction opcode to the stdio stream @var{stream}. The
4210: macro-operand @var{ptr} is a variable of type @code{char *} which
4211: points to the opcode name in its ``internal'' form---the form that is
4212: written in the machine description. The definition should output the
4213: opcode name to @var{stream}, performing any translation you desire, and
4214: increment the variable @var{ptr} to point at the end of the opcode
4215: so that it will not be output twice.
4216:
4217: In fact, your macro definition may process less than the entire opcode
4218: name, or more than the opcode name; but if you want to process text
4219: that includes @samp{%}-sequences to substitute operands, you must take
4220: care of the substitution yourself. Just be sure to increment
4221: @var{ptr} over whatever text should not be output normally.
4222:
4223: @findex recog_operand
4224: If you need to look at the operand values, they can be found as the
4225: elements of @code{recog_operand}.
4226:
4227: If the macro definition does nothing, the instruction is output
4228: in the usual way.
4229:
4230: @findex FINAL_PRESCAN_INSN
4231: @item FINAL_PRESCAN_INSN (@var{insn}, @var{opvec}, @var{noperands})
4232: If defined, a C statement to be executed just prior to the output of
4233: assembler code for @var{insn}, to modify the extracted operands so
4234: they will be output differently.
4235:
4236: Here the argument @var{opvec} is the vector containing the operands
4237: extracted from @var{insn}, and @var{noperands} is the number of
4238: elements of the vector which contain meaningful data for this insn.
4239: The contents of this vector are what will be used to convert the insn
4240: template into assembler code, so you can change the assembler output
4241: by changing the contents of the vector.
4242:
4243: This macro is useful when various assembler syntaxes share a single
4244: file of instruction patterns; by defining this macro differently, you
4245: can cause a large class of instructions to be output differently (such
4246: as with rearranged operands). Naturally, variations in assembler
4247: syntax affecting individual insn patterns ought to be handled by
4248: writing conditional output routines in those patterns.
4249:
4250: If this macro is not defined, it is equivalent to a null statement.
4251:
4252: @findex PRINT_OPERAND
4253: @item PRINT_OPERAND (@var{stream}, @var{x}, @var{code})
4254: A C compound statement to output to stdio stream @var{stream} the
4255: assembler syntax for an instruction operand @var{x}. @var{x} is an
4256: RTL expression.
4257:
4258: @var{code} is a value that can be used to specify one of several ways
4259: of printing the operand. It is used when identical operands must be
4260: printed differently depending on the context. @var{code} comes from
4261: the @samp{%} specification that was used to request printing of the
4262: operand. If the specification was just @samp{%@var{digit}} then
4263: @var{code} is 0; if the specification was @samp{%@var{ltr}
4264: @var{digit}} then @var{code} is the ASCII code for @var{ltr}.
4265:
4266: @findex reg_names
4267: If @var{x} is a register, this macro should print the register's name.
4268: The names can be found in an array @code{reg_names} whose type is
4269: @code{char *[]}. @code{reg_names} is initialized from
4270: @code{REGISTER_NAMES}.
4271:
4272: When the machine description has a specification @samp{%@var{punct}}
4273: (a @samp{%} followed by a punctuation character), this macro is called
4274: with a null pointer for @var{x} and the punctuation character for
4275: @var{code}.
4276:
4277: @findex PRINT_OPERAND_PUNCT_VALID_P
4278: @item PRINT_OPERAND_PUNCT_VALID_P (@var{code})
4279: A C expression which evaluates to true if @var{code} is a valid
4280: punctuation character for use in the @code{PRINT_OPERAND} macro. If
4281: @code{PRINT_OPERAND_PUNCT_VALID_P} is not defined, it means that no
4282: punctuation characters (except for the standard one, @samp{%}) are used
4283: in this way.
4284:
4285: @findex PRINT_OPERAND_ADDRESS
4286: @item PRINT_OPERAND_ADDRESS (@var{stream}, @var{x})
4287: A C compound statement to output to stdio stream @var{stream} the
4288: assembler syntax for an instruction operand that is a memory reference
4289: whose address is @var{x}. @var{x} is an RTL expression.
4290:
4291: @cindex @code{ENCODE_SECTION_INFO} usage
4292: On some machines, the syntax for a symbolic address depends on the
4293: section that the address refers to. On these machines, define the macro
4294: @code{ENCODE_SECTION_INFO} to store the information into the
4295: @code{symbol_ref}, and then check for it here. @xref{Assembler Format}.
4296:
4297: @findex DBR_OUTPUT_SEQEND
4298: @findex dbr_sequence_length
4299: @item DBR_OUTPUT_SEQEND(@var{file})
4300: A C statement, to be executed after all slot-filler instructions have
4301: been output. If necessary, call @code{dbr_sequence_length} to
4302: determine the number of slots filled in a sequence (zero if not
4303: currently outputting a sequence), to decide how many no-ops to output,
4304: or whatever.
4305:
4306: Don't define this macro if it has nothing to do, but it is helpful in
4307: reading assembly output if the extent of the delay sequence is made
4308: explicit (e.g. with white space).
4309:
4310: @findex final_sequence
4311: Note that output routines for instructions with delay slots must be
4312: prepared to deal with not being output as part of a sequence (i.e.
4313: when the scheduling pass is not run, or when no slot fillers could be
4314: found.) The variable @code{final_sequence} is null when not
4315: processing a sequence, otherwise it contains the @code{sequence} rtx
4316: being output.
4317:
4318: @findex REGISTER_PREFIX
4319: @findex LOCAL_LABEL_PREFIX
4320: @findex USER_LABEL_PREFIX
4321: @findex IMMEDIATE_PREFIX
4322: @findex asm_fprintf
4323: @item REGISTER_PREFIX
4324: @itemx LOCAL_LABEL_PREFIX
4325: @itemx USER_LABEL_PREFIX
4326: @itemx IMMEDIATE_PREFIX
4327: If defined, C string expressions to be used for the @samp{%R}, @samp{%L},
4328: @samp{%U}, and @samp{%I} options of @code{asm_fprintf} (see
4329: @file{final.c}). These are useful when a single @file{md} file must
4330: support multiple assembler formats. In that case, the various @file{tm.h}
4331: files can define these macros differently.
4332:
4333: @findex ASM_OUTPUT_REG_PUSH
4334: @item ASM_OUTPUT_REG_PUSH (@var{stream}, @var{regno})
4335: A C expression to output to @var{stream} some assembler code
4336: which will push hard register number @var{regno} onto the stack.
4337: The code need not be optimal, since this macro is used only when
4338: profiling.
4339:
4340: @findex ASM_OUTPUT_REG_POP
4341: @item ASM_OUTPUT_REG_POP (@var{stream}, @var{regno})
4342: A C expression to output to @var{stream} some assembler code
4343: which will pop hard register number @var{regno} off of the stack.
4344: The code need not be optimal, since this macro is used only when
4345: profiling.
4346: @end table
4347:
4348: @node Dispatch Tables, Alignment Output, Instruction Output, Assembler Format
4349: @subsection Output of Dispatch Tables
4350:
4351: @table @code
4352: @cindex dispatch table
4353: @findex ASM_OUTPUT_ADDR_DIFF_ELT
4354: @item ASM_OUTPUT_ADDR_DIFF_ELT (@var{stream}, @var{value}, @var{rel})
4355: This macro should be provided on machines where the addresses
4356: in a dispatch table are relative to the table's own address.
4357:
4358: The definition should be a C statement to output to the stdio stream
4359: @var{stream} an assembler pseudo-instruction to generate a difference
4360: between two labels. @var{value} and @var{rel} are the numbers of two
4361: internal labels. The definitions of these labels are output using
4362: @code{ASM_OUTPUT_INTERNAL_LABEL}, and they must be printed in the same
4363: way here. For example,
4364:
4365: @example
4366: fprintf (@var{stream}, "\t.word L%d-L%d\n",
4367: @var{value}, @var{rel})
4368: @end example
4369:
4370: @findex ASM_OUTPUT_ADDR_VEC_ELT
4371: @item ASM_OUTPUT_ADDR_VEC_ELT (@var{stream}, @var{value})
4372: This macro should be provided on machines where the addresses
4373: in a dispatch table are absolute.
4374:
4375: The definition should be a C statement to output to the stdio stream
4376: @var{stream} an assembler pseudo-instruction to generate a reference to
4377: a label. @var{value} is the number of an internal label whose
4378: definition is output using @code{ASM_OUTPUT_INTERNAL_LABEL}.
4379: For example,
4380:
4381: @example
4382: fprintf (@var{stream}, "\t.word L%d\n", @var{value})
4383: @end example
4384:
4385: @findex ASM_OUTPUT_CASE_LABEL
4386: @item ASM_OUTPUT_CASE_LABEL (@var{stream}, @var{prefix}, @var{num}, @var{table})
4387: Define this if the label before a jump-table needs to be output
4388: specially. The first three arguments are the same as for
4389: @code{ASM_OUTPUT_INTERNAL_LABEL}; the fourth argument is the
4390: jump-table which follows (a @code{jump_insn} containing an
4391: @code{addr_vec} or @code{addr_diff_vec}).
4392:
4393: This feature is used on system V to output a @code{swbeg} statement
4394: for the table.
4395:
4396: If this macro is not defined, these labels are output with
4397: @code{ASM_OUTPUT_INTERNAL_LABEL}.
4398:
4399: @findex ASM_OUTPUT_CASE_END
4400: @item ASM_OUTPUT_CASE_END (@var{stream}, @var{num}, @var{table})
4401: Define this if something special must be output at the end of a
4402: jump-table. The definition should be a C statement to be executed
4403: after the assembler code for the table is written. It should write
4404: the appropriate code to stdio stream @var{stream}. The argument
4405: @var{table} is the jump-table insn, and @var{num} is the label-number
4406: of the preceding label.
4407:
4408: If this macro is not defined, nothing special is output at the end of
4409: the jump-table.
4410: @end table
4411:
4412: @node Alignment Output,, Dispatch Tables, Assembler Format
4413: @subsection Assembler Commands for Alignment
4414:
4415: @table @code
4416: @findex ASM_OUTPUT_ALIGN_CODE
4417: @item ASM_OUTPUT_ALIGN_CODE (@var{file})
4418: A C expression to output text to align the location counter in the way
4419: that is desirable at a point in the code that is reached only by
4420: jumping.
4421:
4422: This macro need not be defined if you don't want any special alignment
4423: to be done at such a time. Most machine descriptions do not currently
4424: define the macro.
4425:
4426: @findex ASM_OUTPUT_LOOP_ALIGN
4427: @item ASM_OUTPUT_LOOP_ALIGN (@var{file})
4428: A C expression to output text to align the location counter in the way
4429: that is desirable at the beginning of a loop.
4430:
4431: This macro need not be defined if you don't want any special alignment
4432: to be done at such a time. Most machine descriptions do not currently
4433: define the macro.
4434:
4435: @findex ASM_OUTPUT_SKIP
4436: @item ASM_OUTPUT_SKIP (@var{stream}, @var{nbytes})
4437: A C statement to output to the stdio stream @var{stream} an assembler
4438: instruction to advance the location counter by @var{nbytes} bytes.
4439: Those bytes should be zero when loaded. @var{nbytes} will be a C
4440: expression of type @code{int}.
4441:
4442: @findex ASM_NO_SKIP_IN_TEXT
4443: @item ASM_NO_SKIP_IN_TEXT
4444: Define this macro if @code{ASM_OUTPUT_SKIP} should not be used in the
4445: text section because it fails put zeros in the bytes that are skipped.
4446: This is true on many Unix systems, where the pseudo--op to skip bytes
4447: produces no-op instructions rather than zeros when used in the text
4448: section.
4449:
4450: @findex ASM_OUTPUT_ALIGN
4451: @item ASM_OUTPUT_ALIGN (@var{stream}, @var{power})
4452: A C statement to output to the stdio stream @var{stream} an assembler
4453: command to advance the location counter to a multiple of 2 to the
4454: @var{power} bytes. @var{power} will be a C expression of type @code{int}.
4455: @end table
4456:
4457: @node Debugging Info, Cross-compilation, Assembler Format, Machine Macros
4458: @section Controlling Debugging Information Format
4459:
4460: @table @code
4461: @findex DBX_REGISTER_NUMBER
4462: @item DBX_REGISTER_NUMBER (@var{regno})
4463: A C expression that returns the DBX register number for the compiler
4464: register number @var{regno}. In simple cases, the value of this
4465: expression may be @var{regno} itself. But sometimes there are some
4466: registers that the compiler knows about and DBX does not, or vice
4467: versa. In such cases, some register may need to have one number in
4468: the compiler and another for DBX.
4469:
4470: If two registers have consecutive numbers inside GNU CC, and they can be
4471: used as a pair to hold a multiword value, then they @emph{must} have
4472: consecutive numbers after renumbering with @code{DBX_REGISTER_NUMBER}.
4473: Otherwise, debuggers will be unable to access such a pair, because they
4474: expect register pairs to be consecutive in their own numbering scheme.
4475:
4476: If you find yourself defining @code{DBX_REGISTER_NUMBER} in way that
4477: does not preserve register pairs, then what you must do instead is
4478: redefine the actual register numbering scheme.
4479:
4480: @findex DBX_DEBUGGING_INFO
4481: @item DBX_DEBUGGING_INFO
4482: Define this macro if GNU CC should produce debugging output for DBX
4483: in response to the @samp{-g} option.
4484:
4485: @findex SDB_DEBUGGING_INFO
4486: @item SDB_DEBUGGING_INFO
4487: Define this macro if GNU CC should produce COFF-style debugging output
4488: for SDB in response to the @samp{-g} option.
4489:
4490: @findex DWARF_DEBUGGING_INFO
4491: @item DWARF_DEBUGGING_INFO
4492: Define this macro if GNU CC should produce dwarf format debugging output
4493: in response to the @samp{-g} option.
4494:
4495: @findex DEFAULT_GDB_EXTENSIONS
4496: @item DEFAULT_GDB_EXTENSIONS
4497: Define this macro to control whether GNU CC should by default generate
4498: GDB's extended version of DBX debugging information (assuming DBX-format
4499: debugging information is enabled at all). If you don't define the
4500: macro, the default is 1: always generate the extended information.
4501:
4502: @findex DEBUG_SYMS_TEXT
4503: @item DEBUG_SYMS_TEXT
4504: Define this macro if all @code{.stabs} commands should be output while
4505: in the text section.
4506:
4507: @findex DEBUGGER_AUTO_OFFSET
4508: @item DEBUGGER_AUTO_OFFSET (@var{x})
4509: A C expression that returns the integer offset value for an automatic
4510: variable having address @var{x} (an RTL expression). The default
4511: computation assumes that @var{x} is based on the frame-pointer and
4512: gives the offset from the frame-pointer. This is required for targets
4513: that produce debugging output for DBX or COFF-style debugging output
4514: for SDB and allow the frame-pointer to be eliminated when the
4515: @samp{-g} options is used.
4516:
4517: @findex DEBUGGER_ARG_OFFSET
4518: @item DEBUGGER_ARG_OFFSET (@var{offset}, @var{x})
4519: A C expression that returns the integer offset value for an argument
4520: having address @var{x} (an RTL expression). The nominal offset is
4521: @var{offset}.
4522:
4523: @findex ASM_STABS_OP
4524: @item ASM_STABS_OP
4525: A C string constant naming the assembler pseudo op to use instead of
4526: @code{.stabs} to define an ordinary debugging symbol. If you don't
4527: define this macro, @code{.stabs} is used. This macro applies only to
4528: DBX debugging information format.
4529:
4530: @findex ASM_STABD_OP
4531: @item ASM_STABD_OP
4532: A C string constant naming the assembler pseudo op to use instead of
4533: @code{.stabd} to define a debugging symbol whose value is the current
4534: location. If you don't define this macro, @code{.stabd} is used.
4535: This macro applies only to DBX debugging information format.
4536:
4537: @findex ASM_STABN_OP
4538: @item ASM_STABN_OP
4539: A C string constant naming the assembler pseudo op to use instead of
4540: @code{.stabn} to define a debugging symbol with no name. If you don't
4541: define this macro, @code{.stabn} is used. This macro applies only to
4542: DBX debugging information format.
4543:
4544: @findex PUT_SDB_@dots{}
4545: @item PUT_SDB_@dots{}
4546: Define these macros to override the assembler syntax for the special
4547: SDB assembler directives. See @file{sdbout.c} for a list of these
4548: macros and their arguments. If the standard syntax is used, you need
4549: not define them yourself.
4550:
4551: @findex SDB_DELIM
4552: @item SDB_DELIM
4553: Some assemblers do not support a semicolon as a delimiter, even between
4554: SDB assembler directives. In that case, define this macro to be the
4555: delimiter to use (usually @samp{\n}). It is not necessary to define
4556: a new set of @code{PUT_SDB_@var{op}} macros if this is the only change
4557: required.
4558:
4559: @findex SDB_GENERATE_FAKE
4560: @item SDB_GENERATE_FAKE
4561: Define this macro to override the usual method of constructing a dummy
4562: name for anonymous structure and union types. See @file{sdbout.c} for
4563: more information.
4564:
4565: @findex SDB_ALLOW_UNKNOWN_REFERENCES
4566: @item SDB_ALLOW_UNKNOWN_REFERENCES
4567: Define this macro to allow references to unknown structure,
4568: union, or enumeration tags to be emitted. Standard COFF does not
4569: allow handling of unknown references, MIPS ECOFF has support for
4570: it.
4571:
4572: @findex SDB_ALLOW_FORWARD_REFERENCES
4573: @item SDB_ALLOW_FORWARD_REFERENCES
4574: Define this macro to allow references to structure, union, or
4575: enumeration tags that have not yet been seen to be handled. Some
4576: assemblers choke if forward tags are used, while some require it.
4577:
4578: @findex DBX_NO_XREFS
4579: @item DBX_NO_XREFS
4580: Define this macro if DBX on your system does not support the construct
4581: @samp{xs@var{tagname}}. On some systems, this construct is used to
4582: describe a forward reference to a structure named @var{tagname}.
4583: On other systems, this construct is not supported at all.
4584:
4585: @findex DBX_CONTIN_LENGTH
4586: @item DBX_CONTIN_LENGTH
4587: A symbol name in DBX-format debugging information is normally
4588: continued (split into two separate @code{.stabs} directives) when it
4589: exceeds a certain length (by default, 80 characters). On some
4590: operating systems, DBX requires this splitting; on others, splitting
4591: must not be done. You can inhibit splitting by defining this macro
4592: with the value zero. You can override the default splitting-length by
4593: defining this macro as an expression for the length you desire.
4594:
4595: @findex DBX_CONTIN_CHAR
4596: @item DBX_CONTIN_CHAR
4597: Normally continuation is indicated by adding a @samp{\} character to
4598: the end of a @code{.stabs} string when a continuation follows. To use
4599: a different character instead, define this macro as a character
4600: constant for the character you want to use. Do not define this macro
4601: if backslash is correct for your system.
4602:
4603: @findex DBX_STATIC_STAB_DATA_SECTION
4604: @item DBX_STATIC_STAB_DATA_SECTION
4605: Define this macro if it is necessary to go to the data section before
4606: outputting the @samp{.stabs} pseudo-op for a non-global static
4607: variable.
4608:
4609: @findex DBX_LBRAC_FIRST
4610: @item DBX_LBRAC_FIRST
4611: Define this macro if the @code{N_LBRAC} symbol for a block should
4612: precede the debugging information for variables and functions defined in
4613: that block. Normally, in DBX format, the @code{N_LBRAC} symbol comes
4614: first.
4615:
4616: @findex DBX_FUNCTION_FIRST
4617: @item DBX_FUNCTION_FIRST
4618: Define this macro if the DBX information for a function and its
4619: arguments should precede the assembler code for the function. Normally,
4620: in DBX format, the debugging information entirely follows the assembler
4621: code.
4622:
4623: @findex DBX_OUTPUT_FUNCTION_END
4624: @item DBX_OUTPUT_FUNCTION_END (@var{stream}, @var{function})
4625: Define this macro if the target machine requires special output at the
4626: end of the debugging information for a function. The definition should
4627: be a C statement (sans semicolon) to output the appropriate information
4628: to @var{stream}. @var{function} is the @code{FUNCTION_DECL} node for
4629: the function.
4630:
4631: @findex DBX_OUTPUT_STANDARD_TYPES
4632: @item DBX_OUTPUT_STANDARD_TYPES (@var{syms})
4633: Define this macro if you need to control the order of output of the
4634: standard data types at the beginning of compilation. The argument
4635: @var{syms} is a @code{tree} which is a chain of all the predefined
4636: global symbols, including names of data types.
4637:
4638: Normally, DBX output starts with definitions of the types for integers
4639: and characters, followed by all the other predefined types of the
4640: particular language in no particular order.
4641:
4642: On some machines, it is necessary to output different particular types
4643: first. To do this, define @code{DBX_OUTPUT_STANDARD_TYPES} to output
4644: those symbols in the necessary order. Any predefined types that you
4645: don't explicitly output will be output afterward in no particular order.
4646:
4647: Be careful not to define this macro so that it works only for C. There
4648: are no global variables to access most of the built-in types, because
4649: another language may have another set of types. The way to output a
4650: particular type is to look through @var{syms} to see if you can find it.
4651: Here is an example:
4652:
4653: @example
4654: @{
4655: tree decl;
4656: for (decl = syms; decl; decl = TREE_CHAIN (decl))
4657: if (!strcmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "long int"))
4658: dbxout_symbol (decl);
4659: @dots{}
4660: @}
4661: @end example
4662:
4663: @noindent
4664: This does nothing if the expected type does not exist.
4665:
4666: See the function @code{init_decl_processing} in source file
4667: @file{c-decl.c} to find the names to use for all the built-in C types.
4668:
4669: @findex DBX_OUTPUT_MAIN_SOURCE_FILENAME
4670: @item DBX_OUTPUT_MAIN_SOURCE_FILENAME (@var{stream}, @var{name})
4671: A C statement to output DBX debugging information to the stdio stream
4672: @var{stream} which indicates that file @var{name} is the main source
4673: file---the file specified as the input file for compilation.
4674: This macro is called only once, at the beginning of compilation.
4675:
4676: This macro need not be defined if the standard form of output
4677: for DBX debugging information is appropriate.
4678:
4679: @findex DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
4680: @item DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (@var{stream}, @var{name})
4681: A C statement to output DBX debugging information to the stdio stream
4682: @var{stream} which indicates that the current directory during
4683: compilation is named @var{name}.
4684:
4685: This macro need not be defined if the standard form of output
4686: for DBX debugging information is appropriate.
4687:
4688: @findex DBX_OUTPUT_MAIN_SOURCE_FILE_END
4689: @item DBX_OUTPUT_MAIN_SOURCE_FILE_END (@var{stream}, @var{name})
4690: A C statement to output DBX debugging information at the end of
4691: compilation of the main source file @var{name}.
4692:
4693: If you don't define this macro, nothing special is output at the end
4694: of compilation, which is correct for most machines.
4695:
4696: @findex DBX_OUTPUT_SOURCE_FILENAME
4697: @item DBX_OUTPUT_SOURCE_FILENAME (@var{stream}, @var{name})
4698: A C statement to output DBX debugging information to the stdio stream
4699: @var{stream} which indicates that file @var{name} is the current source
4700: file. This output is generated each time input shifts to a different
4701: source file as a result of @samp{#include}, the end of an included file,
4702: or a @samp{#line} command.
4703:
4704: This macro need not be defined if the standard form of output
4705: for DBX debugging information is appropriate.
4706: @end table
4707:
4708: @node Cross-compilation, Misc, Debugging INfo, Machine Macros
4709: @section Cross Compilation and Floating Point Format
4710: @cindex cross compilation and floating point
4711: @cindex floating point format and cross compilation
4712:
4713: While all modern machines use 2's complement representation for integers,
4714: there are a variety of representations for floating point numbers. This
4715: means that in a cross-compiler the representation of floating point numbers
4716: in the compiled program may be different from that used in the machine
4717: doing the compilation.
4718:
4719: @findex atof
4720: Because different representation systems may offer different amounts of
4721: range and precision, the cross compiler cannot safely use the host
4722: machine's floating point arithmetic. Therefore, floating point constants
4723: must be represented in the target machine's format. This means that the
4724: cross compiler cannot use @code{atof} to parse a floating point constant;
4725: it must have its own special routine to use instead. Also, constant
4726: folding must emulate the target machine's arithmetic (or must not be done
4727: at all).
4728:
4729: The macros in the following table should be defined only if you are cross
4730: compiling between different floating point formats.
4731:
4732: Otherwise, don't define them. Then default definitions will be set up which
4733: use @code{double} as the data type, @code{==} to test for equality, etc.
4734:
4735: You don't need to worry about how many times you use an operand of any
4736: of these macros. The compiler never uses operands which have side effects.
4737:
4738: @table @code
4739: @findex REAL_VALUE_TYPE
4740: @item REAL_VALUE_TYPE
4741: A macro for the C data type to be used to hold a floating point value
4742: in the target machine's format. Typically this would be a
4743: @code{struct} containing an array of @code{int}.
4744:
4745: @findex REAL_VALUES_EQUAL
4746: @item REAL_VALUES_EQUAL (@var{x}, @var{y})
4747: A macro for a C expression which compares for equality the two values,
4748: @var{x} and @var{y}, both of type @code{REAL_VALUE_TYPE}.
4749:
4750: @findex REAL_VALUES_LESS
4751: @item REAL_VALUES_LESS (@var{x}, @var{y})
4752: A macro for a C expression which tests whether @var{x} is less than
4753: @var{y}, both values being of type @code{REAL_VALUE_TYPE} and
4754: interpreted as floating point numbers in the target machine's
4755: representation.
4756:
4757: @findex REAL_VALUE_LDEXP
4758: @findex ldexp
4759: @item REAL_VALUE_LDEXP (@var{x}, @var{scale})
4760: A macro for a C expression which performs the standard library
4761: function @code{ldexp}, but using the target machine's floating point
4762: representation. Both @var{x} and the value of the expression have
4763: type @code{REAL_VALUE_TYPE}. The second argument, @var{scale}, is an
4764: integer.
4765:
4766: @findex REAL_VALUE_FIX
4767: @item REAL_VALUE_FIX (@var{x})
4768: A macro whose definition is a C expression to convert the target-machine
4769: floating point value @var{x} to a signed integer. @var{x} has type
4770: @code{REAL_VALUE_TYPE}.
4771:
4772: @findex REAL_VALUE_UNSIGNED_FIX
4773: @item REAL_VALUE_UNSIGNED_FIX (@var{x})
4774: A macro whose definition is a C expression to convert the target-machine
4775: floating point value @var{x} to an unsigned integer. @var{x} has type
4776: @code{REAL_VALUE_TYPE}.
4777:
4778: @findex REAL_VALUE_FIX_TRUNCATE
4779: @item REAL_VALUE_FIX_TRUNCATE (@var{x})
4780: A macro whose definition is a C expression to convert the target-machine
4781: floating point value @var{x} to a signed integer, rounding toward 0.
4782: @var{x} has type @code{REAL_VALUE_TYPE}.
4783:
4784: @findex REAL_VALUE_UNSIGNED_FIX_TRUNCATE
4785: @item REAL_VALUE_UNSIGNED_FIX_TRUNCATE (@var{x})
4786: A macro whose definition is a C expression to convert the target-machine
4787: floating point value @var{x} to an unsigned integer, rounding toward 0.
4788: @var{x} has type @code{REAL_VALUE_TYPE}.
4789:
4790: @findex REAL_VALUE_ATOF
4791: @item REAL_VALUE_ATOF (@var{string})
4792: A macro for a C expression which converts @var{string}, an expression
4793: of type @code{char *}, into a floating point number in the target
4794: machine's representation. The value has type @code{REAL_VALUE_TYPE}.
4795:
4796: @findex REAL_INFINITY
4797: @item REAL_INFINITY
4798: Define this macro if infinity is a possible floating point value, and
4799: therefore division by 0 is legitimate.
4800:
4801: @findex REAL_VALUE_ISINF
4802: @findex isinf
4803: @item REAL_VALUE_ISINF (@var{x})
4804: A macro for a C expression which determines whether @var{x}, a floating
4805: point value, is infinity. The value has type @code{int}.
4806: By default, this is defined to call @code{isinf}.
4807:
4808: @findex REAL_VALUE_ISNAN
4809: @findex isnan
4810: @item REAL_VALUE_ISNAN (@var{x})
4811: A macro for a C expression which determines whether @var{x}, a floating
4812: point value, is a ``nan'' (not-a-number). The value has type
4813: @code{int}. By default, this is defined to call @code{isnan}.
4814: @end table
4815:
4816: @cindex constant folding and floating point
4817: Define the following additional macros if you want to make floating
4818: point constant folding work while cross compiling. If you don't
4819: define them, cross compilation is still possible, but constant folding
4820: will not happen for floating point values.
4821:
4822: @table @code
4823: @findex REAL_ARITHMETIC
4824: @item REAL_ARITHMETIC (@var{output}, @var{code}, @var{x}, @var{y})
4825: A macro for a C statement which calculates an arithmetic operation of
4826: the two floating point values @var{x} and @var{y}, both of type
4827: @code{REAL_VALUE_TYPE} in the target machine's representation, to
4828: produce a result of the same type and representation which is stored
4829: in @var{output} (which will be a variable).
4830:
4831: The operation to be performed is specified by @var{code}, a tree code
4832: which will always be one of the following: @code{PLUS_EXPR},
4833: @code{MINUS_EXPR}, @code{MULT_EXPR}, @code{RDIV_EXPR},
4834: @code{MAX_EXPR}, @code{MIN_EXPR}.@refill
4835:
4836: @cindex overflow while constant folding
4837: The expansion of this macro is responsible for checking for overflow.
4838: If overflow happens, the macro expansion should execute the statement
4839: @code{return 0;}, which indicates the inability to perform the
4840: arithmetic operation requested.
4841:
4842: @findex REAL_VALUE_NEGATE
4843: @item REAL_VALUE_NEGATE (@var{x})
4844: A macro for a C expression which returns the negative of the floating
4845: point value @var{x}. Both @var{x} and the value of the expression
4846: have type @code{REAL_VALUE_TYPE} and are in the target machine's
4847: floating point representation.
4848:
4849: There is no way for this macro to report overflow, since overflow
4850: can't happen in the negation operation.
4851:
4852: @findex REAL_VALUE_TRUNCATE
4853: @item REAL_VALUE_TRUNCATE (@var{x})
4854: A macro for a C expression which converts the double-precision floating
4855: point value @var{x} to single-precision.
4856:
4857: Both @var{x} and the value of the expression have type
4858: @code{REAL_VALUE_TYPE} and are in the target machine's floating point
4859: representation. However, the value should have an appropriate bit
4860: pattern to be output properly as a single-precision floating constant.
4861:
4862: There is no way for this macro to report overflow.
4863:
4864: @findex REAL_VALUE_TO_INT
4865: @item REAL_VALUE_TO_INT (@var{low}, @var{high}, @var{x})
4866: A macro for a C expression which converts a floating point value
4867: @var{x} into a double-precision integer which is then stored into
4868: @var{low} and @var{high}, two variables of type @var{int}.
4869:
4870: @item REAL_VALUE_FROM_INT (@var{x}, @var{low}, @var{high})
4871: @findex REAL_VALUE_FROM_INT
4872: A macro for a C expression which converts a double-precision integer
4873: found in @var{low} and @var{high}, two variables of type @var{int},
4874: into a floating point value which is then stored into @var{x}.
4875: @end table
4876:
4877: @node Misc,, Cross-compilation, Machine Macros
4878: @section Miscellaneous Parameters
4879: @cindex parameters, miscellaneous
4880:
4881: @table @code
4882: @item PREDICATE_CODES
4883: @findex PREDICATE_CODES
4884: Optionally define this if you have added predicates to
4885: @file{@var{machine}.c}. This macro is called within an initializer of an
4886: array of structures. The first field in the structure is the name of a
4887: predicate and the second field is an arrary of rtl codes. For each
4888: predicate, list all rtl codes that can be in expressions matched by the
4889: predicate. The list should have a trailing comma. Here is an example
4890: of two entries in the list for a typical RISC machine:
4891:
4892: @example
4893: #define PREDICATE_CODES \
4894: @{"gen_reg_rtx_operand", @{SUBREG, REG@}@}, \
4895: @{"reg_or_short_cint_operand", @{SUBREG, REG, CONST_INT@}@},
4896: @end example
4897:
4898: Defining this macro does not affect the generated code (however,
4899: incorrect definitions that omit an rtl code that may be matched by the
4900: predicate can cause the compiler to malfunction). Instead, it allows
4901: the table built by @file{genrecog} to be more compact and efficient,
4902: thus speeding up the compiler. The most important predicates to include
4903: in the list specified by this macro are thoses used in the most insn
4904: patterns.
4905:
4906: @findex CASE_VECTOR_MODE
4907: @item CASE_VECTOR_MODE
4908: An alias for a machine mode name. This is the machine mode that
4909: elements of a jump-table should have.
4910:
4911: @findex CASE_VECTOR_PC_RELATIVE
4912: @item CASE_VECTOR_PC_RELATIVE
4913: Define this macro if jump-tables should contain relative addresses.
4914:
4915: @findex CASE_DROPS_THROUGH
4916: @item CASE_DROPS_THROUGH
4917: Define this if control falls through a @code{case} insn when the index
4918: value is out of range. This means the specified default-label is
4919: actually ignored by the @code{case} insn proper.
4920:
4921: @findex BYTE_LOADS_ZERO_EXTEND
4922: @item BYTE_LOADS_ZERO_EXTEND
4923: Define this macro if an instruction to load a value narrower than a
4924: word from memory into a register also zero-extends the value to the whole
4925: register.
4926:
4927: @findex IMPLICIT_FIX_EXPR
4928: @item IMPLICIT_FIX_EXPR
4929: An alias for a tree code that should be used by default for conversion
4930: of floating point values to fixed point. Normally,
4931: @code{FIX_ROUND_EXPR} is used.@refill
4932:
4933: @findex FIXUNS_TRUNC_LIKE_FIX_TRUNC
4934: @item FIXUNS_TRUNC_LIKE_FIX_TRUNC
4935: Define this macro if the same instructions that convert a floating
4936: point number to a signed fixed point number also convert validly to an
4937: unsigned one.
4938:
4939: @findex EASY_DIV_EXPR
4940: @item EASY_DIV_EXPR
4941: An alias for a tree code that is the easiest kind of division to
4942: compile code for in the general case. It may be
4943: @code{TRUNC_DIV_EXPR}, @code{FLOOR_DIV_EXPR}, @code{CEIL_DIV_EXPR} or
4944: @code{ROUND_DIV_EXPR}. These four division operators differ in how
4945: they round the result to an integer. @code{EASY_DIV_EXPR} is used
4946: when it is permissible to use any of those kinds of division and the
4947: choice should be made on the basis of efficiency.@refill
4948:
4949: @findex MOVE_MAX
4950: @item MOVE_MAX
4951: The maximum number of bytes that a single instruction can move quickly
4952: from memory to memory.
4953:
4954: @findex SHIFT_COUNT_TRUNCATED
4955: @item SHIFT_COUNT_TRUNCATED
4956: Defining this macro causes the compiler to omit a sign-extend,
4957: zero-extend, or bitwise `and' instruction that truncates the count of a
4958: shift operation to a width equal to the number of bits needed to
4959: represent the size of the object being shifted. On machines that have
4960: instructions that act on bitfields at variable positions, including `bit
4961: test' instructions, defining @code{SHIFT_COUNT_TRUNCATED} also causes
4962: truncation not to be applied to these instructions.
4963:
4964: If both types of instructions truncate the count (for shifts) and
4965: position (for bitfield operations), or if no variable-position bitfield
4966: instructions exist, you should define this macro.
4967:
4968: However, on some machines, such as the 80386, truncation only applies to
4969: shift operations and not bitfield operations. Do not define
4970: @code{SHIFT_COUNT_TRUNCATED} on such machines. Instead, add patterns to
4971: the @file{md} file that include the implied truncation of the shift
4972: instructions.
4973:
4974: @findex TRULY_NOOP_TRUNCATION
4975: @item TRULY_NOOP_TRUNCATION (@var{outprec}, @var{inprec})
4976: A C expression which is nonzero if on this machine it is safe to
4977: ``convert'' an integer of @var{inprec} bits to one of @var{outprec}
4978: bits (where @var{outprec} is smaller than @var{inprec}) by merely
4979: operating on it as if it had only @var{outprec} bits.
4980:
4981: On many machines, this expression can be 1.
4982:
4983: It is reported that suboptimal code can result when
4984: @code{TRULY_NOOP_TRUNCATION} returns 1 for a pair of sizes for modes for
4985: which @code{MODES_TIEABLE_P} is 0. If this is the case, making
4986: @code{TRULY_NOOP_TRUNCATION} return 0 in such cases may improve things.
4987:
4988: @findex STORE_FLAG_VALUE
4989: @item STORE_FLAG_VALUE
4990: A C expression describing the value returned by a comparison operator
4991: and stored by a store-flag instruction (@samp{s@var{cond}}) when the
4992: condition is true. This description must apply to @emph{all} the
4993: @samp{s@var{cond}} patterns and all the comparison operators.
4994:
4995: A value of 1 or -1 means that the instruction implementing the
4996: comparison operator returns exactly 1 or -1 when the comparison is true
4997: and 0 when the comparison is false. Otherwise, the value indicates
4998: which bits of the result are guaranteed to be 1 when the comparison is
4999: true. This value is interpreted in the mode of the comparison
5000: operation, which is given by the mode of the first operand in the
5001: @samp{s@var{cond}} pattern. Either the low bit or the sign bit of
5002: @code{STORE_FLAG_VALUE} be on. Presently, only those bits are used by
5003: the compiler.
5004:
5005: If @code{STORE_FLAG_VALUE} is neither 1 or -1, the compiler will
5006: generate code that depends only on the specified bits. It can also
5007: replace comparison operators with equivalent operations if they cause
5008: the required bits to be set, even if the remaining bits are undefined.
5009: For example, on a machine whose comparison operators return an
5010: @code{SImode} value and where @code{STORE_FLAG_VALUE} is defined as
5011: @samp{0x80000000}, saying that just the sign bit is relevant, the
5012: expression
5013:
5014: @example
5015: (ne:SI (and:SI @var{x} (const_int @var{power-of-2})) (const_int 0))
5016: @end example
5017:
5018: @noindent
5019: can be converted to
5020:
5021: @example
5022: (ashift:SI @var{x} (const_int @var{n}))
5023: @end example
5024:
5025: @noindent
5026: where @var{n} is the appropriate shift count to move the bit being
5027: tested into the sign bit.
5028:
5029: There is no way to describe a machine that always sets the low-order bit
5030: for a true value, but does not guarantee the value of any other bits,
5031: but we do not know of any machine that has such an instruction. If you
5032: are trying to port GNU CC to such a machine, include an instruction to
5033: perform a logical-and of the result with 1 in the pattern for the
5034: comparison operators and let us know (@pxref{Bug Reporting}).
5035:
5036: Often, a machine will have multiple instructions that obtain a value
5037: from a comparison (or the condition codes). Here are rules to guide the
5038: choice of value for @code{STORE_FLAG_VALUE}, and hence the instructions
5039: to be used:
5040:
5041: @itemize @bullet
5042: @item
5043: Use the shortest sequence that yields a valid definition for
5044: @code{STORE_FLAG_VALUE}. It is more efficent for the compiler to
5045: ``normalize'' the value (convert it to, e.g., 1 or 0) than for the
5046: comparison operators to do so because there may be opportunities to
5047: combine the normalization with other operations.
5048:
5049: @item
5050: For equal-length sequences, use a value of 1 or -1, with -1 being
5051: slightly preferred on machines with expensive jumps and 1 preferred on
5052: other machines.
5053:
5054: @item
5055: As a second choice, choose a value of @samp{0x80000001} if instructions
5056: exist that set both the sign and low-order bits but do not define the
5057: others.
5058:
5059: @item
5060: Otherwise, use a value of @samp{0x80000000}.
5061: @end itemize
5062:
5063: You need not define @code{STORE_FLAG_VALUE} if the machine has no store-flag
5064: instructions.
5065:
5066: @findex Pmode
5067: @item Pmode
5068: An alias for the machine mode for pointers. Normally the definition
5069: can be
5070:
5071: @example
5072: #define Pmode SImode
5073: @end example
5074:
5075: @findex FUNCTION_MODE
5076: @item FUNCTION_MODE
5077: An alias for the machine mode used for memory references to functions
5078: being called, in @code{call} RTL expressions. On most machines this
5079: should be @code{QImode}.
5080:
5081: @findex INTEGRATE_THRESHOLD
5082: @item INTEGRATE_THRESHOLD (@var{decl})
5083: A C expression for the maximum number of instructions above which the
5084: function @var{decl} should not be inlined. @var{decl} is a
5085: @code{FUNCTION_DECL} node.
5086:
5087: The default definition of this macro is 64 plus 8 times the number of
5088: arguments that the function accepts. Some people think a larger
5089: threshold should be used on RISC machines.
5090:
5091: @findex SCCS_DIRECTIVE
5092: @item SCCS_DIRECTIVE
5093: Define this if the preprocessor should ignore @code{#sccs} directives
5094: and print no error message.
5095:
5096: @findex HANDLE_PRAGMA
5097: @findex #pragma
5098: @findex pragma
5099: @item HANDLE_PRAGMA (@var{stream})
5100: Define this macro if you want to implement any pragmas. If defined, it
5101: should be a C statement to be executed when @code{#pragma} is seen. The
5102: argument @var{stream} is the stdio input stream from which the source
5103: text can be read.
5104:
5105: It is generally a bad idea to implement new uses of @code{#pragma}. The
5106: only reason to define this macro is for compatibility with other
5107: compilers that do support @code{#pragma} for the sake of any user
5108: programs which already use it.
5109:
5110: @findex HAVE_VPRINTF
5111: @findex vprintf
5112: @item HAVE_VPRINTF
5113: Define this if the library function @code{vprintf} is available on your
5114: system.
5115:
5116: @findex DOLLARS_IN_IDENTIFIERS
5117: @item DOLLARS_IN_IDENTIFIERS
5118: Define this macro to control use of the character @samp{$} in identifier
5119: names. The value should be 0, 1, or 2. 0 means @samp{$} is not allowed
5120: by default; 1 means it is allowed by default if @samp{-traditional} is
5121: used; 2 means it is allowed by default provided @samp{-ansi} is not used.
5122: 1 is the default; there is no need to define this macro in that case.
5123:
5124: @findex DEFAULT_MAIN_RETURN
5125: @item DEFAULT_MAIN_RETURN
5126: Define this macro if the target system expects every program's @code{main}
5127: function to return a standard ``success'' value by default (if no other
5128: value is explicitly returned).
5129:
5130: The definition should be a C statement (sans semicolon) to generate the
5131: appropriate rtl instructions. It is used only when compiling the end of
5132: @code{main}.
5133:
5134: @item HAVE_ATEXIT
5135: @findex HAVE_ATEXIT
5136: Define this if the target system supports the function
5137: @code{atexit} from the ANSI C standard. If this is not defined,
5138: and @code{INIT_SECTION_ASM_OP} is not defined, a default
5139: @code{exit} function will be provided to support C++.
5140:
5141: @item EXIT_BODY
5142: @findex EXIT_BODY
5143: Define this if your @code{exit} function needs to do something
5144: besides calling an external function @code{_cleanup} before
5145: terminating with @code{_exit}. The @code{EXIT_BODY} macro is
5146: only needed if netiher @code{HAVE_ATEXIT} nor
5147: @code{INIT_SECTION_ASM_OP} are defined.
5148: @end table
5149: @end ifset
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.