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