|
|
1.1 root 1: \input texinfo @c -*-texinfo-*-
2:
3: @settitle Internals of GNU CC
4: @setfilename internals
5:
6: @ifinfo
7: This file documents the internals of the GNU compiler.
8:
1.1.1.2 root 9: Copyright (C) 1988 Free Software Foundation, Inc.
1.1 root 10:
11: Permission is granted to make and distribute verbatim copies of
12: this manual provided the copyright notice and this permission notice
13: are preserved on all copies.
14:
15: @ignore
16: Permission is granted to process this file through Tex and print the
17: results, provided the printed document carries copying permission
18: notice identical to this one except for the removal of this paragraph
19: (this paragraph not being relevant to the printed manual).
20:
21: @end ignore
22: Permission is granted to copy and distribute modified versions of this
23: manual under the conditions for verbatim copying, provided also that the
24: section entitled ``GNU CC General Public License'' is included exactly as
25: in the original, and provided that the entire resulting derived work is
26: distributed under the terms of a permission notice identical to this one.
27:
28: Permission is granted to copy and distribute translations of this manual
29: into another language, under the above conditions for modified versions,
1.1.1.2 root 30: except that the section entitled ``GNU CC General Public License'' and
31: this permission notice may be included in translations approved by the
32: Free Software Foundation instead of in the original English.
1.1 root 33: @end ifinfo
34:
35: @setchapternewpage odd
36:
37: @titlepage
38: @center @titlefont{Internals of GNU CC}
39: @sp 2
40: @center Richard M. Stallman
1.1.1.2 root 41: @sp 3
1.1.1.9 ! root 42: @center last updated 12 September 1988
1.1.1.2 root 43: @sp 1
1.1.1.9 ! root 44: @center for version 1.28
1.1 root 45: @page
46: @vskip 0pt plus 1filll
1.1.1.2 root 47: Copyright @copyright{} 1988 Free Software Foundation, Inc.
1.1 root 48:
49: Permission is granted to make and distribute verbatim copies of
50: this manual provided the copyright notice and this permission notice
51: are preserved on all copies.
52:
53: Permission is granted to copy and distribute modified versions of this
54: manual under the conditions for verbatim copying, provided also that the
55: section entitled ``GNU CC General Public License'' is included exactly as
56: in the original, and provided that the entire resulting derived work is
57: distributed under the terms of a permission notice identical to this one.
58:
59: Permission is granted to copy and distribute translations of this manual
60: into another language, under the above conditions for modified versions,
1.1.1.9 ! root 61: except that the section entitled ``GNU CC General Public License'' and
! 62: this permission notice may be included in translations approved by the
! 63: Free Software Foundation instead of in the original English.
1.1 root 64: @end titlepage
65: @page
66:
67: @ifinfo
1.1.1.2 root 68: @node Top, Copying,, (DIR)
69: @ichapter Introduction
1.1 root 70:
1.1.1.2 root 71: This manual documents how to run, install and port the GNU C compiler, as
72: well as its new features and incompatibilities, and how to report bugs.
1.1 root 73:
74: @end ifinfo
75: @menu
76: * Copying:: GNU CC General Public License says
77: how you can copy and share GNU CC.
1.1.1.2 root 78: * Contributors:: People who have contributed to GNU CC.
79: * Options:: Command options supported by @samp{gcc}.
1.1 root 80: * Installation:: How to configure, compile and install GNU CC.
1.1.1.3 root 81: * Trouble:: If you have trouble installing GNU CC.
1.1.1.2 root 82: * Incompatibilities:: Incompatibilities of GNU CC.
83: * Extensions:: GNU extensions to the C language.
84: * Bugs:: How to report bugs (if you want to get them fixed).
1.1 root 85: * Portability:: Goals of GNU CC's portability features.
1.1.1.2 root 86: * Interface:: Function-call interface of GNU CC output.
1.1 root 87: * Passes:: Order of passes, what they do, and what each file is for.
88: * RTL:: The intermediate representation that most passes work on.
89: * Machine Desc:: How to write machine description instruction patterns.
90: * Machine Macros:: How to write the machine description C macros.
91: @end menu
92:
1.1.1.2 root 93: @node Copying, Contributors, Top, Top
1.1 root 94: @unnumbered GNU CC GENERAL PUBLIC LICENSE
1.1.1.2 root 95: @center (Clarified 11 Feb 1988)
1.1 root 96:
97: The license agreements of most software companies keep you at the
98: mercy of those companies. By contrast, our general public license is
99: intended to give everyone the right to share GNU CC. To make sure that
100: you get the rights we want you to have, we need to make restrictions
101: that forbid anyone to deny you these rights or to ask you to surrender
102: the rights. Hence this license agreement.
103:
1.1.1.2 root 104: Specifically, we want to make sure that you have the right to give
105: away copies of GNU CC, that you receive source code or else can get it
106: if you want it, that you can change GNU CC or use pieces of it in new
107: free programs, and that you know you can do these things.
108:
109: To make sure that everyone has such rights, we have to forbid you to
110: deprive anyone else of these rights. For example, if you distribute
111: copies of GNU CC, you must give the recipients all the rights that you
112: have. You must make sure that they, too, receive or can get the
113: source code. And you must tell them their rights.
114:
115: Also, for our own protection, we must make certain that everyone
116: finds out that there is no warranty for GNU CC. If GNU CC is modified by
117: someone else and passed on, we want its recipients to know that what
118: they have is not what we distributed, so that any problems introduced
119: by others will not reflect on our reputation.
120:
121: Therefore we (Richard Stallman and the Free Software Foundation,
122: Inc.) make the following terms which say what you must do to be
123: allowed to distribute or change GNU CC.
124:
125: @unnumberedsec COPYING POLICIES
126:
127: @enumerate
128: @item
129: You may copy and distribute verbatim copies of GNU CC source code as
130: you receive it, in any medium, provided that you conspicuously and
131: appropriately publish on each copy a valid copyright notice
132: ``Copyright @copyright{} 1988 Free Software Foundation, Inc.'' (or
133: with whatever year is appropriate); keep intact the notices on all
134: files that refer to this License Agreement and to the absence of any
135: warranty; and give any other recipients of the GNU CC program a copy
136: of this License Agreement along with the program. You may charge a
137: distribution fee for the physical act of transferring a copy.
138:
139: @item
140: You may modify your copy or copies of GNU CC or any portion of it,
141: and copy and distribute such modifications under the terms of
142: Paragraph 1 above, provided that you also do the following:
143:
144: @itemize @bullet
145: @item
146: cause the modified files to carry prominent notices stating
147: that you changed the files and the date of any change; and
148:
149: @item
150: cause the whole of any work that you distribute or publish, that
151: in whole or in part contains or is a derivative of GNU CC or any
152: part thereof, to be licensed at no charge to all third parties on
153: terms identical to those contained in this License Agreement
154: (except that you may choose to grant more extensive warranty
155: protection to some or all third parties, at your option).
156:
157: @item
158: You may charge a distribution fee for the physical act of
159: transferring a copy, and you may at your option offer warranty
160: protection in exchange for a fee.
161: @end itemize
162:
163: Mere aggregation of another unrelated program with this program (or its
164: derivative) on a volume of a storage or distribution medium does not bring
165: the other program under the scope of these terms.
166:
167: @item
168: You may copy and distribute GNU CC (or a portion or derivative of it,
169: under Paragraph 2) in object code or executable form under the terms
170: of Paragraphs 1 and 2 above provided that you also do one of the
171: following:
172:
173: @itemize @bullet
174: @item
175: accompany it with the complete corresponding machine-readable
176: source code, which must be distributed under the terms of
177: Paragraphs 1 and 2 above; or,
178:
179: @item
180: accompany it with a written offer, valid for at least three
181: years, to give any third party free (except for a nominal
182: shipping charge) a complete machine-readable copy of the
183: corresponding source code, to be distributed under the terms of
184: Paragraphs 1 and 2 above; or,
185:
186: @item
187: accompany it with the information you received as to where the
188: corresponding source code may be obtained. (This alternative is
189: allowed only for noncommercial distribution and only if you
190: received the program in object code or executable form alone.)
191: @end itemize
192:
193: For an executable file, complete source code means all the source code
194: for all modules it contains; but, as a special exception, it need not
195: include source code for modules which are standard libraries that
196: accompany the operating system on which the executable file runs.
197:
198: @item
199: You may not copy, sublicense, distribute or transfer GNU CC except as
200: expressly provided under this License Agreement. Any attempt
201: otherwise to copy, sublicense, distribute or transfer GNU CC is void
202: and your rights to use the program under this License agreement shall
203: be automatically terminated. However, parties who have received
204: computer software programs from you with this License Agreement will
205: not have their licenses terminated so long as such parties remain in
206: full compliance.
207:
208: @item
209: If you wish to incorporate parts of GNU CC into other free programs
210: whose distribution conditions are different, write to the Free Software
211: Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet worked
212: out a simple rule that can be stated here, but we will often permit this.
213: We will be guided by the two goals of preserving the free status of all
214: derivatives of our free software and of promoting the sharing and reuse of
215: software.
216: @end enumerate
217:
218: Your comments and suggestions about our licensing policies and our
219: software are welcome! Please contact the Free Software Foundation, Inc.,
220: 675 Mass Ave, Cambridge, MA 02139, or call (617) 876-3296.
221:
222: @unnumberedsec NO WARRANTY
223:
224: BECAUSE GNU CC IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY NO
225: WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT
226: WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
227: RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE GNU CC "AS IS" WITHOUT
228: WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
229: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
230: A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
231: PERFORMANCE OF GNU CC IS WITH YOU. SHOULD GNU CC PROVE DEFECTIVE, YOU
232: ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
233:
234: IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
235: STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
236: WHO MAY MODIFY AND REDISTRIBUTE GNU CC AS PERMITTED ABOVE, BE LIABLE TO
237: YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER
238: SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
239: INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
240: BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A
241: FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) GNU CC, EVEN
242: IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR
243: ANY CLAIM BY ANY OTHER PARTY.
244:
245: @node Contributors, Options, Copying, Top
246: @unnumbered Contributors to GNU CC
247:
248: In addition to Richard Stallman, several people have written parts
249: of GNU CC.
250:
251: @itemize @bullet
252: @item
253: The idea of using RTL and some of the optimization ideas came from the
254: U. of Arizona Portable Optimizer, written by Jack Davidson and
255: Christopher Fraser. See ``Register Allocation and Exhaustive Peephole
256: Optimization'', Software Practice and Experience 14 (9), Sept. 1984,
257: 857-866.
258:
259: @item
260: Paul Rubin wrote most of the preprocessor.
261:
262: @item
263: Leonard Tower wrote parts of the parser, RTL generator, RTL
264: definitions, and of the Vax machine description.
265:
266: @item
267: Ted Lemon wrote parts of the RTL reader and printer.
268:
269: @item
270: Nobuyuki Hikichi of Software Research Associates, Tokyo, contributed
271: the support for the SONY NEWS machine.
272:
273: @item
274: Charles LaBrec contributed the support for the Integrated Solutions
275: 68020 system.
276:
277: @item
1.1.1.7 root 278: Michael Tiemann of MCC wrote most of the description of the National
279: Semiconductor 32000 series cpu. He also wrote the code for inline
280: function integration and for the SPARC cpu and Motorola 88000 cpu
281: and part of the Sun FPA support.
282:
283: @item
284: Jan Stein of the Chalmers Computer Society provided support for
285: Genix, as well as part of the 32000 machine description.
286:
287: @item
288: Randy Smith finished the Sun FPA support.
1.1.1.2 root 289:
290: @item
1.1.1.3 root 291: Robert Brown implemented the support for Encore 32000 systems.
292:
293: @item
1.1.1.4 root 294: David Kashtan of SRI adapted GNU CC to the Vomit-Making System.
1.1.1.2 root 295:
296: @item
297: Alex Crain provided changes for the 3b1.
298:
299: @item
1.1.1.4 root 300: Greg Satz and Chris Hanson assisted in making GNU CC work on HP-UX for
301: the 9000 series 300.
1.1.1.6 root 302:
303: @item
304: William Schelter did most of the work on the Intel 80386 support.
1.1.1.2 root 305: @end itemize
306:
307: @node Options, Installation, Contributors, Top
308: @chapter GNU CC Command Options
309:
310: The GNU C compiler uses a command syntax much like the Unix C compiler.
311: The @code{gcc} program accepts options and file names as operands.
312: Multiple single-letter options may @emph{not} be grouped: @samp{-dr} is
313: very different from @samp{-d -r}.
314:
315: When you invoke GNU CC, it normally does preprocessing, compilation,
316: assembly and linking. File names which end in @samp{.c} are taken as C
317: source to be preprocessed and compiled; compiler output files plus any
318: input files with names ending in @samp{.s} are assembled; then the
319: resulting object files, plus any other input files, are linked together to
320: produce an executable.
321:
322: Command options allow you to stop this process at an intermediate stage.
323: For example, the @samp{-c} option says not to run the linker. Then the
324: output consists of object files output by the assembler.
325:
326: Other command options are passed on to one stage. Some options control
327: the preprocessor and others the compiler itself. Yet other options
328: control the assembler and linker; these are not documented here because the
329: GNU assembler and linker are not yet released.
330:
331: Here are the options to control the overall compilation process, including
332: those that say whether to link, whether to assemble, and so on.
333:
334: @table @samp
335: @item -o @var{file}
336: Place output in file @var{file}. This applies regardless to whatever
337: sort of output is being produced, whether it be an executable file,
338: an object file, an assembler file or preprocessed C code.
339:
1.1.1.3 root 340: If @samp{-o} is not specified, the default is to put an executable file
1.1.1.2 root 341: in @file{a.out}, the object file @file{@var{source}.c} in
342: @file{@var{source}.o}, an assembler file in @file{@var{source}.s}, and
343: preprocessed C on standard output.@refill
344:
345: @item -c
346: Compile or assemble the source files, but do not link. Produce object
347: files with names made by replacing @samp{.c} or @samp{.s} with
348: @samp{.o} at the end of the input file names. Do nothing at all for
349: object files specified as input.
350:
351: @item -S
352: Compile into assembler code but do not assemble. The assembler output
353: file name is made by replacing @samp{.c} with @samp{.s} at the end of
354: the input file name. Do nothing at all for assembler source files or
355: object files specified as input.
356:
357: @item -E
358: Run only the C preprocessor. Preprocess all the C source files
359: specified and output the results to standard output.
360:
361: @item -v
362: Compiler driver program prints the commands it executes as it runs
363: the preprocessor, compiler proper, assembler and linker. Some of
364: these are directed to print their own version numbers.
365:
366: @item -B@var{prefix}
367: Compiler driver program tries @var{prefix} as a prefix for each
368: program it tries to run. These programs are @file{cpp}, @file{cc1},
369: @file{as} and @file{ld}.
370:
371: For each subprogram to be run, the compiler driver first tries the
372: @samp{-B} prefix, if any. If that name is not found, or if @samp{-B}
373: was not specified, the driver tries two standard prefixes, which are
374: @file{/usr/lib/gcc-} and @file{/usr/local/lib/gcc-}. If neither of
375: those results in a file name that is found, the unmodified program
376: name is searched for using the directories specified in your
377: @samp{PATH} environment variable.
378:
379: The run-time support file @file{gnulib} is also searched for using
380: the @samp{-B} prefix, if needed. If it is not found there, the two
381: standard prefixes above are tried, and that is all. The file is left
382: out of the link if it is not found by those means. Most of the time,
383: on most machines, you can do without it.
384: @end table
385:
386: These options control the details of C compilation itself.
387:
388: @table @samp
389: @item -ansi
390: Support all ANSI standard C programs.
391:
392: This turns off certain features of GNU C that are incompatible with
393: ANSI C, such as the @code{asm}, @code{inline} and @code{typeof}
394: keywords, and predefined macros such as @code{unix} and @code{vax}
395: that identify the type of system you are using. It also enables the
396: undesirable and rarely used ANSI trigraph feature.
397:
398: The @samp{-ansi} option does not cause non-ANSI programs to be
399: rejected gratuitously. For that, @samp{-pedantic} is required in
400: addition to @samp{-ansi}.
401:
402: The macro @code{__STRICT_ANSI__} is predefined when the @samp{-ansi}
403: option is used. Some header files may notice this macro and refrain
404: from declaring certain functions or defining certain macros that the
405: ANSI standard doesn't call for; this is to avoid interfering with
406: any programs that might use these names for other things.
407:
408: @item -traditional
409: Attempt to support some aspects of traditional C compilers.
410: Specifically:
411:
412: @itemize @bullet
413: @item
414: All @code{extern} declarations take effect globally even if they
415: are written inside of a function definition. This includes implicit
416: declarations of functions.
417:
418: @item
419: The keywords @code{typeof}, @code{inline}, @code{signed}, @code{const}
420: and @code{volatile} are not recognized.@refill
421:
422: @item
423: Comparisons between pointers and integers are always allowed.
424:
425: @item
426: Integer types @code{unsigned short} and @code{unsigned char} promote
427: to @code{unsigned int}.
428:
429: @item
1.1.1.5 root 430: Out-of-range floating point literals are not an error.
431:
432: @item
1.1.1.8 root 433: In the preprocessor, comments convert to nothing at all, rather than
434: to a space. This allows traditional token concatenation.
1.1.1.2 root 435:
436: @item
1.1.1.8 root 437: In the preprocessor, macro arguments are recognized within string
438: constants in a macro definition (and their values are stringified,
439: though without additional quote marks, when they appear in such a
440: context). The preprocessor always considers a string constant to end
441: at a newline.
1.1.1.9 ! root 442:
! 443: @item
! 444: The predefined macro @code{__STDC__} is not defined when you use
! 445: @samp{-traditional}, but @code{__GNUC__} is (since the GNU extensions
! 446: which @code{__GNUC__} indicates are not affected by
! 447: @samp{-traditional}). If you need to write header files that work
! 448: differently depending on whether @samp{-traditional} is in use, by
! 449: testing both of these predefined macros you can distinguish four
! 450: situations: GNU C, traditional GNU C, other ANSI C compilers, and
! 451: other old C compilers.
1.1.1.2 root 452: @end itemize
453:
454: @item -O
455: Optimize. Optimizing compilation takes somewhat more time, and a lot
456: more memory for a large function.
457:
458: Without @samp{-O}, the compiler's goal is to reduce the cost of
459: compilation and to make debugging produce the expected results.
460: Statements are independent: if you stop the program with a breakpoint
461: between statements, you can then assign a new value to any variable or
462: change the program counter to any other statement in the function and
463: get exactly the results you would expect from the source code.
464:
465: Without @samp{-O}, only variables declared @code{register} are
466: allocated in registers. The resulting compiled code is a little worse
467: than produced by PCC without @samp{-O}.
468:
469: With @samp{-O}, the compiler tries to reduce code size and execution
470: time.
471:
472: Some of the @samp{-f} options described below turn specific kinds of
473: optimization on or off.
474:
475: @item -g
1.1.1.4 root 476: Produce debugging information in the operating system's native
477: format (for DBX or SDB).
1.1.1.2 root 478:
479: Unlike most other C compilers, GNU CC allows you to use @samp{-g} with
480: @samp{-O}. The shortcuts taken by optimized code may occasionally
481: produce surprising results: some variables you declared may not exist
482: at all; flow of control may briefly move where you did not expect it;
483: some statements may not be executed because they compute constant
484: results or their values were already at hand; some statements may
485: execute in different places because they were moved out of loops.
486: Nevertheless it proves possible to debug optimized output. This makes
487: it reasonable to use the optimizer for programs that might have bugs.
488:
489: @item -gg
490: Produce debugging information in GDB's own format. This requires
491: the GNU assembler and linker in order to work.
492:
493: @item -w
494: Inhibit all warning messages.
495:
496: @item -W
497: Print extra warning messages for these events:
498:
499: @itemize @bullet
500: @item
501: An automatic variable is used without first being initialized.
502:
503: These warnings are possible only in optimizing compilation,
504: because they require data flow information that is computed only
505: when optimizing. They occur only for variables that are
506: candidates for register allocation. Therefore, they do not occur
507: for a variable that is declared @code{volatile}, or whose address
508: is taken, or whose size is other than 1, 2, 4 or 8 bytes. Also,
509: they do not occur for structures, unions or arrays, even when
510: they are in registers.
511:
512: Note that there may be no warning about a variable that is used
513: only to compute a value that itself is never used, because such
514: computations may be deleted by the flow analysis pass before the
515: warnings are printed.
516:
517: These warnings are made optional because GNU CC is not smart
518: enough to see all the reasons why the code might be correct
519: despite appearing to have an error. Here is one example of how
520: this can happen:
521:
522: @example
523: @{
524: int x;
525: switch (y)
526: @{
527: case 1: x = 1;
528: break;
529: case 2: x = 4;
530: break;
531: case 3: x = 5;
532: @}
533: foo (x);
534: @}
535: @end example
536:
537: @noindent
538: If the value of @code{y} is always 1, 2 or 3, then @code{x} is
539: always initialized, but GNU CC doesn't know this. Here is
540: another common case:
541:
542: @example
543: @{
544: int save_y;
545: if (change_y) save_y = y, y = new_y;
546: @dots{}
547: if (change_y) y = save_y;
548: @}
549: @end example
550:
551: @noindent
1.1.1.4 root 552: This has no bug because @code{save_y} is used only if it is set.
1.1.1.2 root 553:
554: @item
555: A nonvolatile automatic variable might be changed by a call to
556: @code{longjmp}. These warnings as well are possible only in
557: optimizing compilation.
558:
559: The compiler sees only the calls to @code{setjmp}. It cannot know
560: where @code{longjmp} will be called; in fact, a signal handler could
561: call it at any point in the code. As a result, you may get a warning
562: even when there is in fact no problem because @code{longjmp} cannot
563: in fact be called at the place which would cause a problem.
564:
565: @item
566: A function can return either with or without a value. (Falling
567: off the end of the function body is considered returning without
568: a value.) For example, this function would inspire such a
569: warning:
570:
571: @example
572: foo (a)
573: @{
574: if (a > 0)
575: return a;
576: @}
577: @end example
578:
579: Spurious warnings can occur because GNU CC does not realize that
580: certain functions (including @code{abort} and @code{longjmp})
581: will never return.
582: @end itemize
583:
584: In the future, other useful warnings may also be enabled by this
585: option.
586:
587: @item -Wimplicit
588: Warn whenever a function is implicitly declared.
589:
590: @item -Wreturn-type
591: Warn whenever a function is defined with a return-type that defaults
592: to @code{int}. Also warn about any @code{return} statement with no
593: return-value in a function whose return-type is not @code{void}.
594:
595: @item -Wcomment
596: Warn whenever a comment-start sequence @samp{/*} appears in a comment.
597:
1.1.1.3 root 598: @item -Wall
599: All of the above @samp{-W} options combined.
600:
1.1.1.8 root 601: @item -Wwrite-strings
602: Give string constants the type @code{const char[@var{length}]} so that
603: copying the address of one into a non-@code{const} @code{char *}
604: pointer will get a warning. These warnings will help you find at
605: compile time code that can try to write into a string constant, but
606: only if you have been very careful about using @code{const} in
607: declarations and prototypes. Otherwise, it will just be a nuisance;
608: this is why we did not make @samp{-Wall} request these warnings.
609:
1.1.1.2 root 610: @item -p
611: Generate extra code to write profile information suitable for the
612: analysis program @code{prof}.
613:
614: @item -pg
615: Generate extra code to write profile information suitable for the
616: analysis program @code{gprof}.
617:
1.1.1.3 root 618: @item -l@var{library}
619: Search a standard list of directories for a library named
620: @var{library}, which is actually a file named
621: @file{lib@var{library}.a}. The linker uses this file as if it
622: had been specified precisely by name.
623:
624: The directories searched include several standard system directories
625: plus any that you specify with @samp{-L}.
626:
627: Normally the files found this way are library files---archive files
628: whose members are object files. The linker handles an archive file by
1.1.1.4 root 629: scanning through it for members which define symbols that have so far
630: been referenced but not defined. But if the file that is found is an
1.1.1.3 root 631: ordinary object file, it is linked in the usual fashion. The only
1.1.1.4 root 632: difference between using an @samp{-l} option and specifying a file name
633: is that @samp{-l} searches several directories.
1.1.1.3 root 634:
635: @item -L@var{dir}
636: Add directory @var{dir} to the list of directories to be searched
637: for @samp{-l}.
1.1.1.2 root 638:
639: @item -nostdlib
640: Don't use the standard system libraries and startup files when
641: linking. Only the files you specify (plus @file{gnulib}) will be
642: passed to the linker.
643:
644: @item -m@var{machinespec}
645: Machine-dependent option specifying something about the type of target
646: machine. These options are defined by the macro
647: @code{TARGET_SWITCHES} in the machine description. The default for
648: the options is also defined by that macro, which enables you to change
649: the defaults.@refill
650:
651: These are the @samp{-m} options defined in the 68000 machine
652: description:
653:
654: @table @samp
655: @item -m68020
1.1.1.8 root 656: @itemx -mc68020
1.1.1.2 root 657: Generate output for a 68020 (rather than a 68000). This is the
658: default if you use the unmodified sources.
659:
660: @item -m68000
1.1.1.8 root 661: @item -mc68000
1.1.1.2 root 662: Generate output for a 68000 (rather than a 68020).
663:
664: @item -m68881
665: Generate output containing 68881 instructions for floating point.
666: This is the default if you use the unmodified sources.
667:
1.1.1.8 root 668: @item -mfpa
669: Generate output containing Sun FPA instructions for floating point.
670:
1.1.1.2 root 671: @item -msoft-float
672: Generate output containing library calls for floating point.
673:
674: @item -mshort
675: Consider type @code{int} to be 16 bits wide, like @code{short int}.
676:
677: @item -mnobitfield
678: Do not use the bit-field instructions. @samp{-m68000} implies
679: @samp{-mnobitfield}.
680:
681: @item -mbitfield
682: Do use the bit-field instructions. @samp{-m68020} implies
683: @samp{-mbitfield}. This is the default if you use the unmodified
684: sources.
685:
686: @item -mrtd
687: Use a different function-calling convention, in which functions
688: that take a fixed number of arguments return with the @code{rtd}
689: instruction, which pops their arguments while returning. This
690: saves one instruction in the caller since there is no need to pop
691: the arguments there.
692:
693: This calling convention is incompatible with the one normally
694: used on Unix, so you cannot use it if you need to call libraries
695: compiled with the Unix compiler.
696:
697: Also, you must provide function prototypes for all functions that
698: take variable numbers of arguments (including @code{printf});
699: otherwise incorrect code will be generated for calls to those
700: functions.
701:
702: In addition, seriously incorrect code will result if you call a
703: function with too many arguments. (Normally, extra arguments are
704: harmlessly ignored.)
705:
706: The @code{rtd} instruction is supported by the 68010 and 68020
707: processors, but not by the 68000.
708: @end table
709:
710: These @samp{-m} options are defined in the Vax machine description:
711:
712: @table @samp
713: @item -munix
714: Do not output certain jump instructions (@code{aobleq} and so on)
715: that the Unix assembler for the Vax cannot handle across long
716: ranges.
717:
718: @item -mgnu
719: Do output those jump instructions, on the assumption that you
720: will assemble with the GNU assembler.
1.1.1.3 root 721:
722: @item -mg
723: Output code for g-format floating point numbers instead of d-format.
1.1.1.2 root 724: @end table
725:
726: @item -f@var{flag}
727: Specify machine-independent flags. These are the flags:
728:
729: @table @samp
730: @item -ffloat-store
731: Do not store floating-point variables in registers. This
732: prevents undesirable excess precision on machines such as the
733: 68000 where the floating registers (of the 68881) keep more
734: precision than a @code{double} is supposed to have.
735:
736: For most programs, the excess precision does only good, but a few
737: programs rely on the precise definition of IEEE floating point.
738: Use @samp{-ffloat-store} for such programs.
739:
740: @item -fno-asm
741: Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
742: keyword. These words may then be used as identifiers.
743:
744: @item -fno-defer-pop
745: Always pop the arguments to each function call as soon as that
746: function returns. Normally the compiler (when optimizing) lets
747: arguments accumulate on the stack for several function calls and
748: pops them all at once.
749:
750: @item -fcombine-regs
751: Allow the combine pass to combine an instruction that copies one
752: register into another. This might or might not produce better
753: code when used in addition to @samp{-O}. I am interested in
754: hearing about the difference this makes.
755:
756: @item -fforce-mem
757: Force memory operands to be copied into registers before doing
758: arithmetic on them. This may produce better code by making all
759: memory references potential common subexpressions. When they are
760: not common subexpressions, instruction combination should
761: eliminate the separate register-load. I am interested in hearing
762: about the difference this makes.
763:
764: @item -fforce-addr
765: Force memory address constants to be copied into registers before
766: doing arithmetic on them. This may produce better code just as
767: @samp{-fforce-mem} may. I am interested in hearing about the
768: difference this makes.
769:
770: @item -fomit-frame-pointer
771: Don't keep the frame pointer in a register for functions that
772: don't need one. This avoids the instructions to save, set up and
773: restore frame pointers; it also makes an extra register available
774: in many functions. @strong{It also makes debugging impossible.}
775:
776: On some machines, such as the Vax, this flag has no effect,
777: because the standard calling sequence automatically handles the
778: frame pointer and nothing is saved by pretending it doesn't
779: exist. The machine-description macro
780: @code{FRAME_POINTER_REQUIRED} controls whether a target machine
781: supports this flag. @xref{Registers}.@refill
782:
783: @item -finline-functions
784: Integrate all simple functions into their callers. The compiler
785: heuristically decides which functions are simple enough to be
786: worth integrating in this way.
787:
788: If all calls to a given function are integrated, and the function
789: is declared @code{static}, then the function is normally not
790: output as assembler code in its own right.
791:
792: @item -fkeep-inline-functions
793: Even if all calls to a given function are integrated, and the
794: function is declared @code{static}, nevertheless output a
795: separate run-time callable version of the function.
796:
797: @item -fwritable-strings
798: Store string constants in the writable data segment and don't
799: uniquize them. This is for compatibility with old programs which
800: assume they can write into string constants. Writing into string
801: constants is a very bad idea; ``constants'' should be constant.
802:
803: @item -fno-function-cse
804: Do not put function addresses in registers; make each instruction
805: that calls a constant function contain the function's address
806: explicitly.
807:
808: This option results in less efficient code, but some strange
809: hacks that alter the assembler output may be confused by the
810: optimizations performed when this option is not used.
811:
812: @item -fvolatile
813: Consider all memory references through pointers to be volatile.
814:
815: @item -funsigned-char
816: Let the type @code{char} be the unsigned, like @code{unsigned
817: char}.
818:
819: Each kind of machine has a default for what @code{char} should
820: be. It is either like @code{unsigned char} by default or like
821: @code{signed char} by default. (Actually, at present, the
822: default is always signed.)
823:
824: The type @code{char} is always a distinct type from either
825: @code{signed char} or @code{unsigned char}, even though its
826: behavior is always just like one of those two.
827:
828: @item -fsigned-char
829: Let the type @code{char} be signed, like @code{signed char}.
830:
831: @item -ffixed-@var{reg}
832: Treat the register named @var{reg} as a fixed register; generated
833: code should never refer to it (except perhaps as a stack pointer,
834: frame pointer or in some other fixed role).
835:
836: @var{reg} must be the name of a register. The register names
837: accepted are machine-specific and are defined in the
838: @code{REGISTER_NAMES} macro in the machine description macro
839: file.
840:
841: @item -fcall-used-@var{reg}
842: Treat the register named @var{reg} as an allocatable register
843: that is clobbered by function calls. It may be allocated for
844: temporaries or variables that do not live across a call.
845: Functions compiled this way will not save and restore the
846: register @var{reg}.
847:
848: Use of this flag for a register that has a fixed pervasive role
849: in the machine's execution model, such as the stack pointer or
850: frame pointer, will produce disastrous results.
851:
852: @item -fcall-saved-@var{reg}
853: Treat the register named @var{reg} as an allocatable register
854: saved by functions. It may be allocated even for temporaries or
855: variables that live across a call. Functions compiled this way
856: will save and restore the register @var{reg} if they use it.
857:
858: Use of this flag for a register that has a fixed pervasive role
859: in the machine's execution model, such as the stack pointer or
860: frame pointer, will produce disastrous results.
861:
862: A different sort of disaster will result from the use of this
863: flag for a register in which function values are may be returned.
864: @end table
865:
866: @item -d@var{letters}
867: Says to make debugging dumps at times specified by @var{letters}.
868: Here are the possible letters:
869:
870: @table @samp
871: @item r
872: Dump after RTL generation.
873: @item j
874: Dump after first jump optimization.
875: @item J
876: Dump after last jump optimization.
877: @item s
878: Dump after CSE (including the jump optimization that sometimes
879: follows CSE).
880: @item L
881: Dump after loop optimization.
882: @item f
883: Dump after flow analysis.
884: @item c
885: Dump after instruction combination.
886: @item l
887: Dump after local register allocation.
888: @item g
889: Dump after global register allocation.
890: @item m
891: Print statistics on memory usage, at the end of the run.
892: @end table
893:
894: @item -pedantic
895: Issue all the warnings demanded by strict ANSI standard C; reject
896: all programs that use forbidden extensions.
897:
898: Valid ANSI standard C programs should compile properly with or without
899: this option (though a rare few will require @samp{-ansi}). However,
900: without this option, certain GNU extensions and traditional C features
901: are supported as well. With this option, they are rejected. There is
902: no reason to @i{use} this option; it exists only to satisfy pedants.
903: @end table
904:
905: These options control the C preprocessor, which is run on each C source
906: file before actual compilation. If you use the @samp{-E} option, nothing
907: is done except C preprocessing. Some of these options make sense only
908: together with @samp{-E} because they request preprocessor output that is
909: not suitable for actual compilation.
910:
911: @table @samp
912: @item -C
913: Tell the preprocessor not to discard comments. Used with the
914: @samp{-E} option.
915:
916: @item -I@var{dir}
917: Search directory @var{dir} for include files.
918:
1.1.1.3 root 919: @item -I-
920: Any directories specified with @samp{-I} options before the @samp{-I-}
921: option are searched only for the case of @samp{#include "@var{file}"};
922: they are not searched for @samp{#include <@var{file}>}.
923:
924: If additional directories are specified with @samp{-I} options after
925: the @samp{-I-}, these directories are searched for all @samp{#include}
926: directives. (Ordinarily @emph{all} @samp{-I} directories are used
927: this way.)
928:
929: In addition, the @samp{-I-} option inhibits the use of the current
930: directory as the first search directory for @samp{#include
931: "@var{file}"}. Therefore, the current directory is searched only if
932: it is requested explicitly with @samp{-I.}. Specifying both
933: @samp{-I-} and @samp{-I.} allows you to control precisely which
934: directories are searched before the current one and which are searched
935: after.
936:
937: @item -nostdinc
938: Do not search the standard system directories for header files. Only
939: the directories you have specified with @samp{-I} options (and the
940: current directory, if appropriate) are searched.
941:
942: Between @samp{-nostdinc} and @samp{-I-}, you can eliminate all
943: directories from the search path except those you specify.
944:
1.1.1.2 root 945: @item -M
946: Tell the preprocessor to output a rule suitable for @code{make}
947: describing the dependencies of each source file. For each source
948: file, the preprocessor outputs one @code{make}-rule whose target is
949: the object file name for that source file and whose dependencies are
950: all the files @samp{#include}d in it. This rule may be a single line
951: or may be continued with @samp{\}-newline if it is long.
952:
953: @samp{-M} implies @samp{-E}.
954:
955: @item -MM
956: Like @samp{-M} but the output mentions only the user-header files
957: included with @samp{#include "@var{file}"}. System header files
958: included with @samp{#include <@var{file}>} are omitted.
959:
960: @samp{-MM} implies @samp{-E}.
961:
962: @item -D@var{macro}
963: Define macro @var{macro} with the empty string as its definition.
964:
965: @item -D@var{macro}=@var{defn}
966: Define macro @var{macro} as @var{defn}.
967:
968: @item -U@var{macro}
969: Undefine macro @var{macro}.
970:
971: @item -T
972: Support ANSI C trigraphs. You don't want to know about this
973: brain-damage. The @samp{-ansi} option also has this effect.
974: @end table
975:
1.1.1.3 root 976: @node Installation, Trouble, Options, Top
1.1.1.2 root 977: @chapter Installing GNU CC
978:
979: Here is the procedure for installing GNU CC on a Unix system.
980: @menu
981: * VMS Install:: See below for installation on VMS.
982: @end menu
983: @iftex
984: (See below for VMS.)
985: @end iftex
986:
987: @enumerate
988: @item
1.1.1.4 root 989: Edit @file{Makefile}. If you are using HPUX, or any form of system V,
990: you must make a few changes described in comments at the beginning of
991: the file.
992:
993: @item
994: On a Sequent system, go to the Berkeley universe.
1.1.1.2 root 995:
996: @item
997: Choose configuration files.
998:
999: @itemize @bullet
1000: @item
1001: Make a symbolic link named @file{config.h} to the top-level
1002: config file for the machine you are using (@pxref{Config}). This
1003: file is responsible for defining information about the host
1004: machine. It includes @file{tm.h}.
1005:
1.1.1.7 root 1006: The file's name should be @file{config-@var{machine}.h}, with these
1007: exceptions:
1008:
1009: @table @file
1010: @item config-vms.h
1011: for vaxen running VMS.
1012: @item config-vaxv.h
1013: for vaxen running system V.
1014: @item config-i386v.h
1015: for Intel 80386's running system V.
1016: @item config-sun4.h
1.1.1.9 ! root 1017: for Suns (model 2, 3 or 4) running @emph{operating system} version 4.
1.1.1.7 root 1018: @item config-hp9k3.h
1019: for the HP 9000 series 300.
1020: @item config-gnx.h
1021: for the ns32000 running Genix
1022: @end table
1.1.1.2 root 1023:
1024: If your system does not support symbolic links, you might want to
1025: set up @file{config.h} to contain a @samp{#include} command which
1026: refers to the appropriate file.
1027:
1028: @item
1029: Make a symbolic link named @file{tm.h} to the machine-description
1030: macro file for your machine (its name should be
1031: @file{tm-@var{machine}.h}).
1032:
1.1.1.7 root 1033: If your system is a 68000, don't use the file @file{tm-m68k.h}
1034: directly. Instead, use one of these files:
1035:
1036: @table @file
1037: @item tm-sun3.h
1038: for Sun 3 machines.
1039: @item tm-sun2.h
1040: for Sun 2 machines.
1041: @item tm-3b1.h
1042: for AT&T 3b1 (aka 7300 Unix PC).
1043: @item tm-isi68.h
1044: for Integrated Solutions systems.
1045: @item tm-news800.h
1046: for SONY News systems.
1047: @item tm-hp9k320.h
1048: for HPUX systems, if you are using GNU CC with the system's
1049: assembler and linker.
1050: @item tm-hp9k320g.h
1051: for HPUX systems, if you are using the GNU assembler, linker and
1052: other utilities. Not all of the pieces of GNU software needed
1053: for this mode of operation are as yet in distribution; full
1054: instructions will appear here in the future.@refill
1055: @end table
1.1.1.2 root 1056:
1.1.1.6 root 1057: For the vax, use @file{tm-vax.h} on BSD Unix, @file{tm-vaxv.h} on
1058: system V, or @file{tm-vms.h} on VMS.@refill
1.1.1.4 root 1059:
1.1.1.7 root 1060: For the SPARC (Sun 4), use @file{tm-sparc.h}.
1.1.1.6 root 1061:
1062: For the Motorola 88000, use @file{tm-m88k.h}. The support for the
1063: 88000 has a few unfinished spots because there was no way to run the
1064: output. Bugs are suspected in handling of branch-tables and in
1065: the function prologue and epilogue.
1066:
1.1.1.7 root 1067: For the 80386, don't use @file{tm-i386.h} directly. Use
1068: @file{tm-i386v.h} if the target machine is running system V,
1069: @file{tm-seq386.h} for a Sequent 386 system, or @file{tm-compaq.h} for
1070: a Compaq.
1.1.1.4 root 1071:
1.1.1.2 root 1072: For the 32000, use @file{tm-sequent.h} if you are using a Sequent
1.1.1.7 root 1073: machine, or @file{tm-encore.h} for an Encore machine, or
1074: @file{tm-gnx.h} if you are using Genix version 3; otherwise, perhaps
1075: @file{tm-ns32k.h} will work for you.
1076:
1077: Note that Genix has bugs in @code{alloca} and @code{malloc}; you must
1078: get the compiled versions of these from GNU Emacs and edit GNU CC's
1079: @file{Makefile} to use them.
1.1.1.4 root 1080:
1081: Note that Encore systems are supported only under BSD.
1.1.1.2 root 1082:
1083: @item
1084: Make a symbolic link named @file{md} to the machine description
1085: pattern file (its name should be @file{@var{machine}.md}).
1086:
1087: @item
1088: Make a symbolic link named @file{aux-output.c} to the output
1089: subroutine file for your machine (its name should be
1090: @file{output-@var{machine}.c}).
1091: @end itemize
1092:
1093: @item
1094: Make sure the Bison parser generator is installed. (This is
1.1.1.7 root 1095: unnecessary if the Bison output files @file{c-parse.tab.c} and
1096: @file{cexp.c} are more recent than @file{c-parse.y} and @file{cexp.y}
1.1.1.4 root 1097: and you do not plan to change the @samp{.y} files.)
1.1.1.2 root 1098:
1.1.1.9 ! root 1099: Bison versions older that Sept 8, 1988 will produce incorrect output
! 1100: for @file{c-parse.tab.c}.
1.1.1.2 root 1101:
1102: @item
1103: If you are using a Sun, make sure the environment variable
1104: @code{FLOAT_OPTION} is not set. If this option were set to
1105: @code{f68881} when @file{gnulib} is compiled, the resulting code would
1106: demand to be linked with a special startup file and will not link
1107: properly without special pains.
1108:
1109: @item
1110: Build the compiler. Just type @samp{make} in the compiler directory.
1111:
1112: @item
1113: Move the first-stage object files and executables into a subdirectory
1114: with this command:
1115:
1116: @example
1117: make stage1
1118: @end example
1119:
1120: The files are moved into a subdirectory named @file{stage1}.
1121: Once installation is complete, you may wish to delete these files
1122: with @code{rm -r stage1}.
1123:
1124: @item
1125: Recompile the compiler with itself, with this command:
1126:
1127: @example
1128: make CC=stage1/gcc CFLAGS="-g -O -Bstage1/"
1129: @end example
1130:
1131: On a 68000 or 68020 system lacking floating point hardware,
1132: unless you have selected a @file{tm.h} file that expects by default
1133: that there is no such hardware, do this instead:
1134:
1135: @example
1136: make CC=stage1/gcc CFLAGS="-g -O -Bstage1/ -msoft-float"
1137: @end example
1138:
1139: @item
1140: If you wish to test the compiler by compiling it with itself one more
1141: time, do this:
1142:
1143: @example
1144: make stage2
1.1.1.6 root 1145: Make CC=stage2/gcc CFLAGS="-g -O -Bstage2/"
1.1.1.2 root 1146: foreach file (*.o)
1147: cmp $file stage2/$file
1148: end
1149: @end example
1150:
1151: This will notify you if any of these stage 3 object files differs from
1152: those of stage 2. Any difference, no matter how innocuous, indicates
1153: that the stage 2 compiler has compiled GNU CC incorrectly, and is
1154: therefore a potentially serious bug which you should investigate and
1155: report (@pxref{Bugs}).
1156:
1.1.1.6 root 1157: Aside from the @samp{-B} option, the options should be the same as
1158: when you made stage 2.
1159:
1.1.1.2 root 1160: @item
1161: Install the compiler driver, the compiler's passes and run-time support.
1162: You can use the following command:
1163:
1164: @example
1165: make install
1166: @end example
1167:
1168: @noindent
1169: This copies the files @file{cc1}, @file{cpp} and @file{gnulib} to
1170: files @file{gcc-cc1}, @file{gcc-cpp} and @file{gcc-gnulib} in
1171: directory @file{/usr/local/lib}, which is where the compiler driver
1172: program looks for them. It also copies the driver program @file{gcc}
1173: into the directory @file{/usr/local}, so that it appears in typical
1174: execution search paths.@refill
1175:
1.1.1.8 root 1176: @strong{Warning: there is a bug in @code{alloca} in the Sun library.
1177: To avoid this bug, install the binaries of GNU CC that were compiled
1178: by GNU CC. They use @code{alloca} as a built-in function and never
1179: the one in the library.}
1180:
1.1.1.2 root 1181: @strong{Warning: the GNU CPP may not work for @file{ioctl.h},
1182: @file{ttychars.h} and other system header files unless the
1183: @samp{-traditional} option is used.} The bug is in the header files:
1184: at least on some machines, they rely on behavior that is incompatible
1185: with ANSI C. This behavior consists of substituting for macro
1186: argument names when they appear inside of character constants. The
1187: @samp{-traditional} option tells GNU CC to behave the way these
1188: headers expect.
1189:
1190: Because of this problem, you might prefer to configure GNU CC to use
1191: the system's own C preprocessor. To do so, make the file
1192: @file{/usr/local/lib/gcc-cpp} a link to @file{/lib/cpp}.
1193:
1194: Alternatively, on Sun systems and 4.3BSD at least, you can correct the
1195: include files by running the shell script @file{fixincludes}. This
1.1.1.5 root 1196: installs modified, corrected copies of the files @file{ioctl.h},
1197: @file{ttychars.h} and many others, in a special directory where only
1198: GNU CC will normally look for them.
1.1.1.2 root 1199:
1.1.1.5 root 1200: See the file @file{fixincludes} for a list of all the files we know to
1201: require correction.
1.1.1.2 root 1202: @end enumerate
1203:
1204: If you cannot install the compiler's passes and run-time support in
1205: @file{/usr/local/lib}, you can alternatively use the @samp{-B} option to
1206: specify a prefix by which they may be found. The compiler concatenates
1207: the prefix with the names @file{cpp}, @file{cc1} and @file{gnulib}.
1208: Thus, you can put the files in a directory @file{/usr/foo/gcc} and
1209: specify @samp{-B/usr/foo/gcc/} when you run GNU CC.
1210:
1.1.1.4 root 1211: Also, you can specify an alternative default directory for these files
1212: by setting the Make variable @code{libdir} when you make GNU CC.
1213:
1.1.1.2 root 1214: @node VMS Install,, Installation, Installation
1215: @section Installing GNU CC on VMS
1216:
1.1.1.3 root 1217: The VMS version of GNU CC is distributed in an unusual tape format which
1218: consists of several tape files. The first is a command file; the second is
1219: an executable program which reads Unix tar format; the third is another
1220: command file which uses this program to read the remainder of the tape.
1221:
1222: To load the tape, it suffices to mount it @samp{/foreign} and then do
1223: @samp{@@mta0:} to execute the command file at the beginning of the tape.
1224:
1225: The tape contains executables and object files as well as sources, so no
1226: compilation is necessary unless you change the sources. (This is a good
1227: thing, since you probably don't have any other C compiler.) If you must
1228: recompile, here is how:
1.1.1.2 root 1229:
1230: @enumerate
1231: @item
1232: Copy the file @file{tm-vms.h} to @file{tm.h}, @file{config-vms.h} to
1233: @file{config.h}, @file{vax.md} to @file{md.} and @file{output-vax.c}
1234: to @file{aux-output.c}.@refill
1235:
1236: @item
1237: Type @samp{@@make} to do recompile everything.
1238: @end enumerate
1239:
1.1.1.3 root 1240: To install the @samp{GCC} command so you can use the compiler easily, in
1241: the same manner as you use the VMS C compiler, you must install the VMS CLD
1242: file for GNU CC as follows:
1243:
1244: @enumerate
1245: @item
1246: Define the VMS logical names @samp{GNU_CC} and @samp{GNU_CC_INCLUDE}
1247: to point to the directories where the GNU CC executables
1248: (@samp{gcc-cpp}, @samp{gcc-cc1}, etc.) and the C include files are
1249: kept. This should be done with the commands:@refill
1250:
1251: @example
1252: $ assign /super /system disk:[gcc] gnu_cc
1253: $ assign /super /system disk:[gcc.include] gnu_cc_include
1254: @end example
1255:
1256: @noindent
1257: with the appropriate disk and directory names. These commands can be
1258: placed in your system startup file so they will be executed whenever
1259: the machine is rebooted.
1260:
1261: @item
1262: Install the @samp{GCC} command with the command line:
1263:
1264: @example
1265: $ set command /table=sys$library:dcltables gnu_cc:gcc
1266: @end example
1267:
1268: @noindent
1269: Now you can invoke the compiler with a command like @samp{gcc /verbose
1270: file.c}, which is equivalent to the command @samp{gcc -v -c file.c} in
1271: Unix.
1272: @end enumerate
1273:
1274: @node Trouble, Incompatibilities, Installation, Top
1275: @chapter Trouble in Installation
1276:
1277: Here are some of the things that have caused trouble for people installing
1278: GNU CC.
1279:
1.1.1.4 root 1280: @itemize @bullet
1.1.1.3 root 1281: @item
1282: On certain systems, defining certain environment variables such as
1283: @samp{CC} can interfere with the functioning of @code{make}.
1.1.1.4 root 1284:
1285: @item
1286: Cross compilation can run into trouble for certain machines because
1287: some target machines' assemblers require floating point numbers to be
1288: written as @emph{integer} constants in certain contexts.
1289:
1290: The compiler writes these integer constants by examining the floating
1291: point value as an integer and printing that integer, because this is
1292: simple to write and independent of the details of the floating point
1293: representation. But this does not work if the compiler is running on
1294: a different machine with an incompatible floating point format, or
1295: even a different byte-ordering.
1296:
1297: It is possible to fix this by writing machine-independent code which
1298: understands the floating point representation of the target machine.
1299: I am not interested in doing that much work to compensate for bugs
1300: in assemblers.
1.1.1.3 root 1301: @end itemize
1302:
1303: @node Incompatibilities, Extensions, Trouble, Top
1.1.1.2 root 1304: @chapter Incompatibilities of GNU CC
1305:
1306: There are several noteworthy incompatibilities between GNU C and most
1307: existing (non-ANSI) versions of C.
1308:
1309: Ultimately our intention is that the @samp{-traditional} option will
1310: eliminate most of these incompatibilities by telling GNU C to behave
1311: like the other C compilers.
1312:
1313: @itemize @bullet
1314: @item
1315: GNU CC normally makes string constants read-only. If several
1316: identical-looking string constants are used, GNU CC stores only one
1317: copy of the string.
1318:
1319: One consequence is that you cannot call @code{mktemp} with a string
1320: constant argument. The function @code{mktemp} always alters the
1321: string its argument points to.
1322:
1323: Another consequence is that @code{sscanf} does not work on some
1324: systems when passed a string constant as its format control string.
1325: This is because @code{sscanf} incorrectly tries to write into the
1326: string constant.
1327:
1328: The best solution to these problems is to change the program to use
1329: @code{char}-array variables with initialization strings for these
1330: purposes instead of string constants. But if this is not possible,
1331: you can use the @samp{-fwritable-strings} flag, which directs GNU CC
1332: to handle string constants the same way most C compilers do.
1333:
1334: @item
1335: GNU CC does not substitute macro arguments when they appear inside of
1336: string constants. For example, the following macro in GNU CC
1337:
1338: @example
1339: #define foo(a) "a"
1340: @end example
1341:
1342: @noindent
1343: will produce output @samp{"a"} regardless of what the argument @var{a} is.
1344:
1345: The @samp{-traditional} option directs GNU CC to handle such cases
1346: (among others) in the old-fashioned (non-ANSI) fashion.
1347:
1348: @item
1349: When you use @code{setjmp} and @code{longjmp}, the only automatic
1350: variables guaranteed to remain valid are those declared
1351: @code{volatile}. This is a consequence of automatic register
1352: allocation. Consider this function:
1353:
1354: @example
1355: jmp_buf j;
1356:
1357: foo ()
1358: @{
1359: int a, b;
1360:
1361: a = fun1 ();
1362: if (setjmp (j))
1363: return a;
1364:
1365: a = fun2 ();
1366: /* @r{@code{longjmp (j)} may be occur in @code{fun3}.} */
1367: return a + fun3 ();
1368: @}
1369: @end example
1370:
1371: Here @code{a} may or may not be restored to its first value when the
1372: @code{longjmp} occurs. If @code{a} is allocated in a register, then
1373: its first value is restored; otherwise, it keeps the last value stored
1374: in it.
1375:
1376: If you use the @samp{-W} option with the @samp{-O} option, you will
1377: get a warning when GNU CC thinks such a problem might be possible.
1378:
1379: @item
1380: Declarations of external variables and functions within a block apply
1381: only to the block containing the declaration. In other words, they
1382: have the same scope as any other declaration in the same place.
1383:
1384: In some other C compilers, a @code{extern} declaration affects all the
1385: rest of the file even if it happens within a block.
1386:
1387: The @samp{-traditional} option directs GNU C to treat all @code{extern}
1388: declarations as global, like traditional compilers.
1389:
1390: @item
1391: In traditional C, you can combine @code{long}, etc., with a typedef name,
1392: as shown here:
1393:
1394: @example
1395: typedef int foo;
1396: typedef long foo bar;
1397: @end example
1398:
1399: In ANSI C, this is not allowed: @code{long} and other type modifiers
1400: require an explicit @code{int}. Because this criterion is expressed
1401: by Bison grammar rules rather than C code, the @samp{-traditional}
1402: flag cannot alter it.
1403:
1404: @item
1.1.1.7 root 1405: PCC allows typedef names to be used as function parameters. The
1406: difficulty described immediately above applies here too.
1407:
1408: @item
1.1.1.8 root 1409: PCC allows whitespace in the middle of compound assignment operators
1410: such as @samp{+=}. GNU CC, following the ANSI standard, does not
1411: allow this. The difficulty described immediately above applies here
1412: too.
1413:
1414: @item
1.1.1.6 root 1415: When compiling functions that return @code{float}, PCC converts it to
1416: a double. GNU CC actually returns a @code{float}. If you are concerned
1417: with PCC compatibility, you should declare your functions to return
1418: @code{double}; you might as well say what you mean.
1419:
1420: @item
1.1.1.2 root 1421: When compiling functions that return structures or unions, GNU CC
1422: output code uses a method different from that used on most versions of
1423: Unix. As a result, code compiled with GNU CC cannot call a
1424: structure-returning function compiled with PCC, and vice versa.
1425:
1426: The method used by GCC is as follows: a structure or union which is 1,
1427: 2, 4 or 8 bytes long is returned like a scalar. A structure or union
1428: with any other size is stored into an address supplied by the caller
1429: in a special, fixed register.
1430:
1431: PCC usually handles all sizes of structures and unions by returning
1432: the address of a block of static storage containing the value. This
1433: method is not used in GCC because it is slower and nonreentrant.
1434:
1435: On systems where PCC works this way, you may be able to make GCC-compiled
1436: code call such functions that were compiled with PCC by declaring them
1437: to return a pointer to the structure or union instead of the structure
1438: or union itself. For example, instead of this:
1439:
1440: @example
1441: struct foo nextfoo ();
1442: @end example
1443:
1444: @noindent
1445: write this:
1446:
1447: @example
1448: struct foo *nextfoo ();
1449: #define nextfoo *nextfoo
1450: @end example
1451:
1452: @noindent
1.1.1.4 root 1453: (Note that this assumes you are using the GNU preprocessor and not
1454: @samp{-traditional}, so that the ANSI antirecursion rules for macro
1455: expansions are effective.)
1.1.1.2 root 1456: @end itemize
1457:
1458: @node Extensions, Bugs, Incompatibilities, Top
1459: @chapter GNU Extensions to the C Language
1460:
1461: GNU C provides several language features not found in ANSI standard C.
1462: (The @samp{-pedantic} option directs GNU CC to print a warning message if
1463: any of these features is used.) To test for the availability of these
1464: features in conditional compilation, check for a predefined macro
1465: @code{__GNUC__}, which is always defined under GNU CC.
1466:
1467: @menu
1468: * Statement Exprs:: Putting statements and declarations inside expressions.
1469: * Naming Types:: Giving a name to the type of some expression.
1470: * Typeof:: @code{typeof}: referring to the type of an expression.
1471: * Lvalues:: Using @samp{?:}, @samp{,} and casts in lvalues.
1472: * Conditionals:: Omitting the middle operand of a @samp{?:} expression.
1473: * Zero-Length:: Zero-length arrays.
1474: * Variable-Length:: Arrays whose length is computed at run time.
1475: * Subscripting:: Any array can be subscripted, even if not an lvalue.
1476: * Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers.
1477: * Constructors:: Constructor expressions give structures, unions
1478: or arrays as values.
1479: * Dollar Signs:: Dollar sign is allowed in identifiers.
1480: * Alignment:: Inquiring about the alignment of a type or variable.
1481: * Inline:: Defining inline functions (as fast as macros).
1482: * Extended Asm:: Assembler instructions with C expressions as operands.
1483: (With them you can define ``built-in'' functions.)
1484: * Asm Labels:: Specifying the assembler name to use for a C symbol.
1485: @end menu
1486:
1487: @node Statement Exprs, Naming Types, Extensions, Extensions
1488: @section Statements and Declarations inside of Expressions
1489:
1490: A compound statement in parentheses may appear inside an expression in GNU
1491: C. This allows you to declare variables within an expression. For
1492: example:
1493:
1494: @example
1495: (@{ int y = foo (); int z;
1496: if (y > 0) z = y;
1497: else z = - y;
1498: z; @})
1499: @end example
1500:
1501: @noindent
1502: is a valid (though slightly more complex than necessary) expression
1503: for the absolute value of @code{foo ()}.
1504:
1505: This feature is especially useful in making macro definitions ``safe'' (so
1506: that they evaluate each operand exactly once). For example, the
1507: ``maximum'' function is commonly defined as a macro in standard C as
1508: follows:
1509:
1510: @example
1511: #define max(a,b) ((a) > (b) ? (a) : (b))
1512: @end example
1513:
1514: @noindent
1515: But this definition computes either @var{a} or @var{b} twice, with bad
1516: results if the operand has side effects. In GNU C, if you know the
1517: type of the operands (here let's assume @code{int}), you can define
1518: the macro safely as follows:
1519:
1520: @example
1521: #define maxint(a,b) \
1522: (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
1523: @end example
1524:
1525: Embedded statements are not allowed in constant expressions, such as
1526: the value of an enumeration constant, the width of a bit field, or
1527: the initial value of a static variable.
1528:
1529: If you don't know the type of the operand, you can still do this, but you
1530: must use @code{typeof} (@pxref{Typeof}) or type naming (@pxref{Naming
1531: Types}).
1532:
1533: @node Naming Types, Typeof, Statement Exprs, Extensions
1534: @section Naming an Expression's Type
1535:
1536: You can give a name to the type of an expression using a @code{typedef}
1537: declaration with an initializer. Here is how to define @var{name} as a
1538: type name for the type of @var{exp}:
1539:
1540: @example
1541: typedef @var{name} = @var{exp};
1542: @end example
1543:
1544: This is useful in conjunction with the statements-within-expressions
1545: feature. Here is how the two together can be used to define a safe
1546: ``maximum'' macro that operates on any arithmetic type:
1547:
1548: @example
1549: #define max(a,b) \
1550: (@{typedef _ta = (a), _tb = (b); \
1551: _ta _a = (a); _tb _b = (b); \
1552: _a > _b ? _a : _b; @})
1553: @end example
1554:
1555: The reason for using names that start with underscores for the local
1556: variables is to avoid conflicts with variable names that occur within the
1557: expressions that are substituted for @code{a} and @code{b}. Eventually we
1558: hope to design a new form of declaration syntax that allows you to declare
1559: variables whose scopes start only after their initializers; this will be a
1560: more reliable way to prevent such conflicts.
1561:
1562: @node Typeof, Lvalues, Naming Types, Extensions
1563: @section Referring to a Type with @code{typeof}
1564:
1565: Another way to refer to the type of an expression is with @code{typeof}.
1566: The syntax of using of this keyword looks like @code{sizeof}, but the
1567: construct acts semantically like a type name defined with @code{typedef}.
1568:
1569: There are two ways of writing the argument to @code{typeof}: with an
1570: expression or with a type. Here is an example with an expression:
1571:
1572: @example
1573: typeof (x[0](1))
1574: @end example
1575:
1576: @noindent
1577: This assumes that @code{x} is an array of functions; the type described
1578: is that of the values of the functions.
1579:
1580: Here is an example with a typename as the argument:
1581:
1582: @example
1583: typeof (int *)
1584: @end example
1585:
1586: @noindent
1587: Here the type described is that of pointers to @code{int}.
1588:
1589: A @code{typeof}-construct can be used anywhere a typedef name could be
1590: used. For example, you can use it in a declaration, in a cast, or inside
1591: of @code{sizeof} or @code{typeof}.
1592:
1593: @itemize @bullet
1594: @item
1595: This declares @code{y} with the type of what @code{x} points to.
1596:
1597: @example
1598: typeof (*x) y;
1599: @end example
1600:
1601: @item
1602: This declares @code{y} as an array of such values.
1603:
1604: @example
1605: typeof (*x) y[4];
1606: @end example
1607:
1608: @item
1609: This declares @code{y} as an array of pointers to characters:
1610:
1611: @example
1612: typeof (typeof (char *)[4]) y;
1613: @end example
1614:
1615: @noindent
1616: It is equivalent to the following traditional C declaration:
1617:
1618: @example
1619: char *y[4];
1620: @end example
1621:
1622: To see the meaning of the declaration using @code{typeof}, and why it
1623: might be a useful way to write, let's rewrite it with these macros:
1624:
1625: @example
1626: #define pointer(T) typeof(T *)
1627: #define array(T, N) typeof(T [N])
1628: @end example
1629:
1630: @noindent
1631: Now the declaration can be rewritten this way:
1632:
1633: @example
1634: array (pointer (char), 4) y;
1635: @end example
1636:
1637: @noindent
1638: Thus, @samp{array (pointer (char), 4)} is the type of arrays of 4
1639: pointers to @code{char}.
1640: @end itemize
1641:
1642: @node Lvalues, Conditionals, Typeof, Extensions
1643: @section Generalized Lvalues
1644:
1645: Compound expressions, conditional expressions and casts are allowed as
1646: lvalues provided their operands are lvalues. This means that you can take
1647: their addresses or store values into them.
1648:
1649: For example, a compound expression can be assigned, provided the last
1650: expression in the sequence is an lvalue. These two expressions are
1651: equivalent:
1652:
1653: @example
1654: (a, b) += 5
1655: a, (b += 5)
1656: @end example
1657:
1658: Similarly, the address of the compound expression can be taken. These two
1659: expressions are equivalent:
1660:
1661: @example
1662: &(a, b)
1663: a, &b
1664: @end example
1665:
1666: A conditional expression is a valid lvalue if its type is not void and the
1667: true and false branches are both valid lvalues. For example, these two
1668: expressions are equivalent:
1669:
1670: @example
1671: (a ? b : c) = 5
1672: (a ? b = 5 : (c = 5))
1673: @end example
1674:
1675: A cast is a valid lvalue if its operand is valid. Taking the address of
1676: the cast is the same as taking the address without a cast, except for the
1677: type of the result. For example, these two expressions are equivalent (but
1678: the second may be valid when the type of @samp{a} does not permit a cast to
1679: @samp{int *}).
1680:
1681: @example
1682: &(int *)a
1683: (int **)&a
1684: @end example
1685:
1686: A simple assignment whose left-hand side is a cast works by converting the
1687: right-hand side first to the specified type, then to the type of the inner
1688: left-hand side expression. After this is stored, the value is converter
1689: back to the specified type to become the value of the assignment. Thus, if
1690: @samp{a} has type @samp{char *}, the following two expressions are
1691: equivalent:
1692:
1693: @example
1694: (int)a = 5
1695: (int)(a = (char *)5)
1696: @end example
1697:
1698: An assignment-with-arithmetic operation such as @samp{+=} applied to a cast
1699: performs the arithmetic using the type resulting from the cast, and then
1700: continues as in the previous case. Therefore, these two expressions are
1701: equivalent:
1702:
1703: @example
1704: (int)a += 5
1705: (int)(a = (char *) ((int)a + 5))
1706: @end example
1707:
1708: @node Conditionals, Zero-Length, Lvalues, Extensions
1709: @section Conditional Expressions with Omitted Middle-Operands
1710:
1711: The middle operand in a conditional expression may be omitted. Then
1712: if the first operand is nonzero, its value is the value of the conditional
1713: expression.
1714:
1715: Therefore, the expression
1716:
1717: @example
1718: x ? : y
1719: @end example
1720:
1721: @noindent
1722: has the value of @code{x} if that is nonzero; otherwise, the value of
1723: @code{y}.
1724:
1725: This example is perfectly equivalent to
1726:
1727: @example
1728: x ? x : y
1729: @end example
1730:
1731: @noindent
1732: In this simple case, the ability to omit the middle operand is not
1733: especially useful. When it becomes useful is when the first operand does,
1734: or may (if it is a macro argument), contain a side effect. Then repeating
1735: the operand in the middle would perform the side effect twice. Omitting
1736: the middle operand uses the value already computed without the undesirable
1737: effects of recomputing it.
1738:
1739: @node Zero-Length, Variable-Length, Conditionals, Extensions
1740: @section Arrays of Length Zero
1741:
1742: Zero-length arrays are allowed in GNU C. They are very useful as the last
1743: element of a structure which is really a header for a variable-length
1744: object:
1745:
1746: @example
1747: struct line @{
1748: int length;
1749: char contents[0];
1750: @};
1751:
1752: @{
1753: struct line *thisline
1754: = (struct line *) malloc (sizeof (struct line) + this_length);
1.1.1.6 root 1755: thisline->length = this_length;
1.1.1.2 root 1756: @}
1757: @end example
1758:
1759: In standard C, you would have to give @code{contents} a length of 1, which
1760: means either you waste space or complicate the argument to @code{malloc}.
1761:
1762: @node Variable-Length, Subscripting, Zero-Length, Extensions
1763: @section Arrays of Variable Length
1764:
1765: Variable-length automatic arrays are allowed in GNU C. These arrays are
1766: declared like any other automatic arrays, but with a length that is not a
1767: constant expression. The storage is allocated at that time and
1768: deallocated when the brace-level is exited. For example:
1769:
1770: @example
1771: FILE *concat_fopen (char *s1, char *s2, char *mode)
1772: @{
1773: char str[strlen (s1) + strlen (s2) + 1];
1774: strcpy (str, s1);
1775: strcat (str, s2);
1776: return fopen (str, mode);
1777: @}
1778: @end example
1779:
1780: You can also define structure types containing variable-length arrays, and
1781: use them even for arguments or function values, as shown here:
1782:
1783: @example
1784: int foo;
1785:
1786: struct entry
1787: @{
1788: char data[foo];
1789: @};
1790:
1791: struct entry
1792: tester (struct entry arg)
1793: @{
1794: struct entry new;
1795: int i;
1796: for (i = 0; i < foo; i++)
1797: new.data[i] = arg.data[i] + 1;
1798: return new;
1799: @}
1800: @end example
1801:
1802: @noindent
1803: (Eventually there will be a way to say that the size of the array is
1804: another member of the same structure.)
1805:
1806: The length of an array is computed on entry to the brace-level where the
1807: array is declared and is remembered for the scope of the array in case you
1808: access it with @code{sizeof}.
1809:
1810: Jumping or breaking out of the scope of the array name will also deallocate
1811: the storage. Jumping into the scope is not allowed; you will get an error
1812: message for it.
1813:
1814: You can use the function @code{alloca} to get an effect much like
1815: variable-length arrays. The function @code{alloca} is available in
1816: many other C implementations (but not in all). On the other hand,
1817: variable-length arrays are more elegant.
1818:
1819: There are other differences between these two methods. Space allocated
1820: with @code{alloca} exists until the containing @emph{function} returns.
1821: The space for a variable-length array is deallocated as soon as the array
1822: name's scope ends. (If you use both variable-length arrays and
1823: @code{alloca} in the same function, deallocation of a variable-length array
1824: will also deallocate anything more recently allocated with @code{alloca}.)
1825:
1826: @node Subscripting, Pointer Arith, Variable-Length, Extensions
1827: @section Non-Lvalue Arrays May Have Subscripts
1828:
1829: Subscripting is allowed on arrays that are not lvalues, even though the
1830: unary @samp{&} operator is not. For example, this is valid in GNU C though
1831: not valid in other C dialects:
1832:
1833: @example
1834: struct foo @{int a[4];@};
1835:
1836: struct foo f();
1837:
1838: bar (int index)
1839: @{
1840: return f().a[index];
1841: @}
1842: @end example
1843:
1844: @node Pointer Arith, Initializers, Subscripting, Extensions
1845: @section Arithmetic on @code{void}-Pointers and Function Pointers
1846:
1847: In GNU C, addition and subtraction operations are supported on pointers to
1848: @code{void} and on pointers to functions. This is done by treating the
1849: size of a @code{void} or of a function as 1.
1850:
1851: A consequence of this is that @code{sizeof} is also allowed on @code{void}
1852: and on function types, and returns 1.
1853:
1854: @node Initializers, Constructors, Pointer Arith, Extensions
1855: @section Non-Constant Initializers
1856:
1857: The elements of an aggregate initializer are not required to be constant
1858: expressions in GNU C. Here is an example of an initializer with run-time
1859: varying elements:
1860:
1861: @example
1862: foo (float f, float g)
1863: @{
1864: float beat_freqs[2] = @{ f-g, f+g @};
1865: @dots{}
1866: @}
1867: @end example
1868:
1869: @node Constructors, Dollar Signs, Initializers, Extensions
1870: @section Constructor Expressions
1871:
1872: GNU C supports constructor expressions. A constructor looks like a cast
1873: containing an initializer. Its value is an object of the type specified in
1874: the cast, containing the elements specified in the initializer. The type
1875: must be a structure, union or array type.
1876:
1877: Assume that @code{struct foo} and @code{structure} are declared as shown:
1878:
1879: @example
1880: struct foo @{int a; char b[2];@} structure;
1881: @end example
1882:
1883: @noindent
1884: Here is an example of constructing a @samp{struct foo} with a constructor:
1885:
1886: @example
1887: structure = ((struct foo) @{x + y, 'a', 0@});
1888: @end example
1889:
1890: @noindent
1891: This is equivalent to writing the following:
1892:
1893: @example
1894: @{
1895: struct foo temp = @{x + y, 'a', 0@};
1896: structure = temp;
1897: @}
1898: @end example
1899:
1900: You can also construct an array. If all the elements of the constructor
1901: are (made up of) simple constant expressions, suitable for use in
1902: initializers, then the constructor is an lvalue and can be coerced to a
1903: pointer to its first element, as shown here:
1904:
1905: @example
1906: char **foo = (char *[]) @{ "x", "y", "z" @};
1907: @end example
1908:
1909: Array constructors whose elements are not simple constants are not very
1910: useful, because the constructor is not an lvalue. There are only two valid
1911: ways to use it: to subscript it, or initialize an array variable with it.
1912: The former is probably slower than a @code{switch} statement, while the
1913: latter does the same thing an ordinary C initializer would do.
1914:
1915: @example
1916: output = ((int[]) @{ 2, x, 28 @}) [input];
1917: @end example
1918:
1919: @node Dollar Signs, Alignment, Constructors, Extensions
1920: @section Dollar Signs in Identifier Names
1921:
1922: In GNU C, you may use dollar signs in identifier names. This is because
1923: many traditional C implementations allow such identifiers.
1924:
1925: @node Alignment, Inline, Dollar Signs, Extensions
1926: @section Inquiring about the Alignment of a Type or Variable
1927:
1928: The keyword @code{__alignof} allows you to inquire about how an object
1929: is aligned, or the minimum alignment usually required by a type. Its
1930: syntax is just like @code{sizeof}.
1931:
1932: For example, if the target machine requires a @code{double} value to be
1933: aligned on an 8-byte boundary, then @code{__alignof (double)} is 8. This
1934: is true on many RISC machines. On more traditional machine designs,
1935: @code{__alignof (double)} is 4 or even 2.
1936:
1937: Some machines never actually require alignment; they allow reference to any
1938: data type even at an odd addresses. For these machines, @code{__alignof}
1939: reports the @emph{recommended} alignment of a type.
1940:
1941: When the operand of @code{__alignof} is an lvalue rather than a type, the
1942: value is the largest alignment that the lvalue is known to have. It may
1943: have this alignment as a result of its data type, or because it is part of
1944: a structure and inherits alignment from that structure. For example, after
1945: this declaration:
1946:
1947: @example
1948: struct foo @{ int x; char y; @} foo1;
1949: @end example
1950:
1951: @noindent
1952: the value of @code{__alignof (foo1.y)} is probably 2 or 4, the same as
1953: @code{__alignof (int)}, even though the data type of @code{foo1.y} does not
1954: itself demand any alignment.@refill
1955:
1956: @node Inline, Extended Asm, Alignment, Extensions
1957: @section An Inline Function is As Fast As a Macro
1958:
1959: By declaring a function @code{inline}, you can direct GNU CC to integrate
1960: that function's code into the code for its callers. This makes execution
1961: faster by eliminating the function-call overhead; in addition, if any of
1962: the actual argument values are constant, their known values may permit
1963: simplifications at compile time so that not all of the inline function's
1964: code needs to be included.
1965:
1966: To declare a function inline, use the @code{inline} keyword in its
1967: declaration, like this:
1968:
1969: @example
1970: inline int
1971: inc (int *a)
1972: @{
1973: (*a)++;
1974: @}
1975: @end example
1976:
1977: You can also make all ``simple enough'' functions inline with the
1978: option @samp{-finline-functions}. Note that certain usages in a
1979: function definition can make it unsuitable for inline substitution.
1980:
1981: When a function is both inline and @code{static}, if all calls to the
1982: function are integrated into the caller, then the function's own assembler
1983: code is never referenced. In this case, GNU CC does not actually output
1984: assembler code for the function, unless you specify the option
1985: @samp{-fkeep-inline-functions}. Some calls cannot be integrated for
1986: various reasons (in particular, calls that precede the function's
1987: definition cannot be integrated, and neither can recursive calls within the
1988: definition). If there is a nonintegrated call, then the function is
1989: compiled to assembler code as usual.
1990:
1991: When an inline function is not @code{static}, then the compiler must assume
1992: that there may be calls from other source files; since a global symbol can
1993: be defined only once in any program, the function must not be defined in
1994: the other source files, so the calls therein cannot be integrated.
1995: Therefore, a non-@code{static} inline function is always compiled on its
1996: own in the usual fashion.
1997:
1998: @node Extended Asm, Asm Labels, Inline, Extensions
1999: @section Assembler Instructions with C Expression Operands
2000:
2001: In an assembler instruction using @code{asm}, you can now specify the
2002: operands of the instruction using C expressions. This means no more
2003: guessing which registers or memory locations will contain the data you want
2004: to use.
2005:
2006: You must specify an assembler instruction template much like what appears
2007: in a machine description, plus an operand constraint string for each
2008: operand.
2009:
2010: For example, here is how to use the 68881's @code{fsinx} instruction:
2011:
2012: @example
2013: asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
2014: @end example
2015:
2016: @noindent
2017: Here @code{angle} is the C expression for the input operand while
2018: @code{result} is that of the output operand. Each has @samp{"f"} as its
2019: operand constraint, saying that a floating-point register is required. The
2020: constraints use the same language used in the machine description
2021: (@pxref{Constraints}).
2022:
2023: Each operand is described by an operand-constraint string followed by the C
2024: expression in parentheses. A colon separates the assembler template from
2025: the first output operand, and another separates the last output operand
2026: from the first input, if any. Commas separate output operands and separate
2027: inputs. The number of operands is limited to the maximum number of
2028: operands in any instruction pattern in the machine description.
2029:
1.1.1.5 root 2030: Output operand expressions must be lvalues; the compiler can check this.
2031: The input operands need not be lvalues. The compiler cannot check whether
2032: the operands have data types that are reasonable for the instruction being
1.1.1.8 root 2033: executed. It does not parse the assembler instruction template and does
2034: not know what it means, or whether it is valid assembler input. The
2035: extended @code{asm} feature is most often used for machine instructions
2036: that the compiler itself does not know exist.
1.1.1.2 root 2037:
1.1.1.5 root 2038: If there are no output operands, and there are input operands, then you
2039: should write two colons in a row where the output operands would go.
2040:
1.1.1.2 root 2041: The output operands must be write-only; GNU CC will assume that the values
2042: in these operands before the instruction are dead and need not be
1.1.1.5 root 2043: generated. For an operand that is read-write, or in which not all bits are
2044: written and the other bits contain useful information, you must logically
2045: split its function into two separate operands, one input operand and one
2046: write-only output operand. The connection between them is expressed by
2047: constraints which say they need to be in the same location when the
2048: instruction executes. You can use the same C expression for both operands,
2049: or different expressions. For example, here we write the (fictitious)
1.1.1.2 root 2050: @samp{combine} instruction with @code{bar} as its read-only source operand
2051: and @code{foo} as its read-write destination:
2052:
2053: @example
2054: asm ("combine %2,%0" : "=r" (foo) : "0" (foo), "g" (bar));
2055: @end example
2056:
2057: @noindent
2058: The constraint @samp{"0"} for operand 1 says that it must occupy the same
1.1.1.5 root 2059: location as operand 0.
2060:
1.1.1.8 root 2061: Only a digit in the constraint can guarantee that one operand will be in
2062: the same place as another. The mere fact that @code{foo} is the value of
2063: both operands is not enough to guarantee that they will be in the same
2064: place in the generated assembler code. The following would not work:
2065:
2066: @example
2067: asm ("combine %2,%0" : "=r" (foo) : "r" (foo), "g" (bar));
2068: @end example
2069:
2070: Various optimizations or reloading could cause operands 0 and 1 to be in
2071: different registers; GNU CC knows no reason not to do so. For example, the
2072: compiler might find a copy of the value of @code{foo} in one register and
2073: use it for operand 1, but generate the output operand 0 in a different
2074: register (copying it afterward to @code{foo}'s own address). Of course,
2075: since the register for operand 1 is not even mentioned in the assembler
2076: code, the result will not work, but GNU CC can't tell that.
2077:
1.1.1.5 root 2078: Unless an output operand has the @samp{&} constraint modifier, GNU CC may
2079: allocate it in the same register as an unrelated input operand, on the
2080: assumption that the inputs are consumed before the outputs are produced.
2081: This assumption may be false if the assembler code actually consists of
2082: more than one instruction. In such a case, use @samp{&} for each output
2083: operand that may not overlap an input. @xref{Modifiers}.
1.1.1.2 root 2084:
1.1.1.8 root 2085: Some instructions clobber specific hard registers. To describe this,
2086: write a third colon after the input operands, followed by the names of
2087: the clobbered hard registers (given as strings). For example, on the vax,
2088:
2089: @example
2090: asm volatile ("movc3 %0,%1,%2"
2091: : /* no outputs */
2092: : "g" (from), "g" (to), "g" (count)
2093: : "r0", "r1", "r2", "r3", "r4", "r5");
2094: @end example
2095:
1.1.1.2 root 2096: Usually the most convenient way to use these @code{asm} instructions is to
2097: encapsulate them in macros that look like functions. For example,
2098:
2099: @example
2100: #define sin(x) \
2101: (@{ double __value, __arg = (x); \
2102: asm ("fsinx %1,%0": "=f" (__value): "f" (__arg)); \
2103: __value; @})
2104: @end example
2105:
2106: @noindent
2107: Here the variable @code{__arg} is used to make sure that the instruction
2108: operates on a proper @code{double} value, and to accept only those
2109: arguments @code{x} which can convert automatically to a @code{double}.
2110:
2111: Another way to make sure the instruction operates on the correct data type
2112: is to use a cast in the @code{asm}. This is different from using a
2113: variable @code{__arg} in that it converts more different types. For
2114: example, if the desired type were @code{int}, casting the argument to
2115: @code{int} would accept a pointer with no complaint, while assigning the
2116: argument to an @code{int} variable named @code{__arg} would warn about
2117: using a pointer unless the caller explicitly casts it.
2118:
2119: GNU CC assumes for optimization purposes that these instructions have no
2120: side effects except to change the output operands. This does not mean that
2121: instructions with a side effect cannot be used, but you must be careful,
2122: because the compiler may eliminate them if the output operands aren't used,
2123: or move them out of loops, or replace two with one if they constitute a
2124: common subexpression. Also, if your instruction does have a side effect on
2125: a variable that otherwise appears not to change, the old value of the
2126: variable may be reused later if it happens to be found in a register.
2127:
2128: You can prevent an @code{asm} instruction from being deleted, moved or
2129: combined by writing the keyword @code{volatile} after the @code{asm}. For
2130: example:
1.1 root 2131:
1.1.1.2 root 2132: @example
2133: #define set_priority(x) \
1.1.1.9 ! root 2134: asm volatile ("set_priority %0": /* no outputs */ : "g" (x))
1.1.1.2 root 2135: @end example
1.1 root 2136:
1.1.1.9 ! root 2137: It is a natural idea to look for a way to give access to the condition
! 2138: code left by the assembler instruction. However, when we attempted to
! 2139: implement this, we found no way to make it work reliably. The problem
! 2140: is that output operands might need reloading, which would result in
! 2141: additional following ``store'' instructions. On most machines, these
! 2142: instructions would alter the condition code before there was time to
! 2143: test it. This problem doesn't arise for ordinary ``test'' and
! 2144: ``compare'' instructions because they don't have any output operands.
1.1.1.2 root 2145:
2146: @node Asm Labels,,Extended Asm, Extensions
2147: @section Controlling Names Used in Assembler Code
2148:
2149: You can specify the name to be used in the assembler code for a C function
2150: or variable by writing the @code{asm} keyword after the declarator as
2151: follows:
1.1 root 2152:
1.1.1.2 root 2153: @example
2154: int foo asm ("myfoo") = 2;
2155: @end example
1.1 root 2156:
1.1.1.2 root 2157: @noindent
2158: This specifies that the name to be used for the variable @code{foo} in
2159: the assembler code should be @samp{myfoo} rather than the usual
2160: @samp{_foo}.
2161:
2162: On systems where an underscore is normally prepended to the name of a C
2163: function or variable, this feature allows you to define names for the
2164: linker that do not start with an underscore.
2165:
2166: You cannot use @code{asm} in this way in a function @emph{definition}; but
2167: you can get the same effect by writing a declaration for the function
2168: before its definition and putting @code{asm} there, like this:
1.1 root 2169:
1.1.1.2 root 2170: @example
2171: extern func () asm ("FUNC");
1.1 root 2172:
1.1.1.2 root 2173: func (x, y)
2174: int x, y;
2175: @dots{}
2176: @end example
1.1 root 2177:
1.1.1.2 root 2178: It is up to you to make sure that the assembler names you choose do not
2179: conflict with any other assembler symbols. Also, you must not use a
2180: register name; that would produce completely invalid assembler code. GNU
2181: CC does not as yet have the ability to store static variables in registers.
2182: Perhaps that will be added.
2183:
2184: @node Bugs, Portability, Extensions, Top
2185: @chapter Reporting Bugs
2186:
2187: Your bug reports play an essential role in making GNU CC reliable.
2188:
2189: Reporting a bug may help you by bringing a solution to your problem, or it
2190: may not. But in any case the important function of a bug report is to help
2191: the entire community by making the next version of GNU CC work better. Bug
2192: reports are your contribution to the maintenance of GNU CC.
1.1 root 2193:
1.1.1.2 root 2194: In order for a bug report to serve its purpose, you must include the
2195: information that makes for fixing the bug.
1.1 root 2196:
1.1.1.2 root 2197: @menu
2198: * Criteria: Bug Criteria. Have you really found a bug?
2199: * Reporting: Bug Reporting. How to report a bug effectively.
2200: @end menu
1.1 root 2201:
1.1.1.2 root 2202: @node Bug Criteria, Bug Reporting, Bugs, Bugs
2203: @section Have You Found a Bug?
2204:
2205: If you are not sure whether you have found a bug, here are some guidelines:
1.1 root 2206:
2207: @itemize @bullet
2208: @item
1.1.1.2 root 2209: If the compiler gets a fatal signal, for any input whatever, that is a
2210: compiler bug. Reliable compilers never crash.
1.1 root 2211:
2212: @item
1.1.1.2 root 2213: If the compiler produces invalid assembly code, for any input whatever
2214: (except an @code{asm} statement), that is a compiler bug, unless the
2215: compiler reports errors (not just warnings) which would ordinarily
2216: prevent the assembler from being run.
1.1 root 2217:
2218: @item
1.1.1.2 root 2219: If the compiler produces valid assembly code that does not correctly
2220: execute the input source code, that is a compiler bug.
1.1 root 2221:
1.1.1.2 root 2222: However, you must double-check to make sure, because you may have run
2223: into an incompatibility between GNU C and traditional C
2224: (@pxref{Incompatibilities}). These incompatibilities might be considered
1.1.1.3 root 2225: bugs, but they are inescapable consequences of valuable features.
1.1 root 2226:
1.1.1.2 root 2227: Or you may have a program whose behavior is undefined, which happened
2228: by chance to give the desired results with another C compiler.
1.1 root 2229:
1.1.1.2 root 2230: For example, in many nonoptimizing compilers, you can write @samp{x;}
2231: at the end of a function instead of @samp{return x;}, with the same
2232: results. But the value of the function is undefined if @samp{return}
2233: is omitted; it is not a bug when GNU CC produces different results.
1.1 root 2234:
1.1.1.2 root 2235: Problems often result from expressions with two increment operators,
2236: as in @samp{f (*p++, *p++)}. Your previous compiler might have
2237: interpreted that expression the way you intended; GNU CC might
2238: interpret it another way; neither compiler is wrong.
1.1 root 2239:
1.1.1.2 root 2240: After you have localized the error to a single source line, it should
2241: be easy to check for these things. If your program is correct and
2242: well defined, you have found a compiler bug.
1.1 root 2243:
1.1.1.2 root 2244: @item
2245: If the compiler produces an error message for valid input, that is a
2246: compiler bug.
1.1 root 2247:
1.1.1.2 root 2248: Note that the following is not valid input, and the error message for
2249: it is not a bug:
1.1 root 2250:
1.1.1.2 root 2251: @example
2252: int foo (char);
1.1 root 2253:
1.1.1.2 root 2254: int
2255: foo (x)
2256: char x;
2257: @{ @dots{} @}
2258: @end example
1.1 root 2259:
1.1.1.2 root 2260: @noindent
2261: The prototype says to pass a @code{char}, while the definition says to
2262: pass an @code{int} and treat the value as a @code{char}. This is what
2263: the ANSI standard says, and it makes sense.
1.1 root 2264:
1.1.1.2 root 2265: @item
2266: If the compiler does not produce an error message for invalid input,
2267: that is a compiler bug. However, you should note that your idea of
2268: ``invalid input'' might be my idea of ``an extension'' or ``support
2269: for traditional practice''.
1.1 root 2270:
1.1.1.2 root 2271: @item
2272: If you are an experienced user of C compilers, your suggestions
2273: for improvement of GNU CC are welcome in any case.
2274: @end itemize
1.1 root 2275:
1.1.1.2 root 2276: @node Bug Reporting,, Bug Criteria, Bugs
2277: @section How to Report Bugs
1.1 root 2278:
1.1.1.2 root 2279: Send bug reports for GNU C to one of these addresses:
1.1 root 2280:
1.1.1.2 root 2281: @example
2282: bug-gcc@@prep.ai.mit.edu
2283: @{ucbvax|mit-eddie|uunet@}!prep.ai.mit.edu!bug-gcc
2284: @end example
1.1 root 2285:
1.1.1.2 root 2286: As a last resort, snail them to:
1.1 root 2287:
1.1.1.2 root 2288: @example
2289: GNU Compiler Bugs
2290: 545 Tech Sq
2291: Cambridge, MA 02139
2292: @end example
1.1 root 2293:
1.1.1.2 root 2294: The fundamental principle of reporting bugs usefully is this:
2295: @strong{report all the facts}. If you are not sure whether to mention a
2296: fact or leave it out, mention it!
2297:
2298: Often people omit facts because they think they know what causes the
2299: problem and they conclude that some details don't matter. Thus, you might
2300: assume that the name of the variable you use in an example does not matter.
2301: Well, probably it doesn't, but one cannot be sure. Perhaps the bug is a
2302: stray memory reference which happens to fetch from the location where that
2303: name is stored in memory; perhaps, if the name were different, the contents
2304: of that location would fool the compiler into doing the right thing despite
2305: the bug. Play it safe and give an exact example.
1.1 root 2306:
1.1.1.2 root 2307: If you want to enable me to fix the bug, you should include all these
2308: things:
1.1 root 2309:
1.1.1.2 root 2310: @itemize @bullet
2311: @item
2312: The version of GNU CC. You can get this by running it with the
2313: @samp{-v} option.
1.1 root 2314:
1.1.1.2 root 2315: Without this, I won't know whether there is any point in looking for
2316: the bug in the current version of GNU CC.
1.1 root 2317:
1.1.1.2 root 2318: @item
2319: A complete input file that will reproduce the bug. If the bug is in
2320: the C preprocessor, send me a source file and any header files that it
2321: requires. If the bug is in the compiler proper (@file{cc1}), run your
2322: source file through the C preprocessor by doing @samp{gcc -E
2323: @var{sourcefile} > @var{outfile}}, then include the contents of
2324: @var{outfile} in the bug report. (Any @samp{-I}, @samp{-D} or
2325: @samp{-U} options that you used in actual compilation should also be
2326: used when doing this.)
1.1 root 2327:
1.1.1.2 root 2328: A single statement is not enough of an example. In order to compile
2329: it, it must be embedded in a function definition; and the bug might
2330: depend on the details of how this is done.
2331:
2332: Without a real example I can compile, all I can do about your bug
2333: report is wish you luck. It would be futile to try to guess how to
2334: provoke the bug. For example, bugs in register allocation and
2335: reloading frequently depend on every little detail of the function
2336: they happen in.
1.1 root 2337:
2338: @item
1.1.1.2 root 2339: The command arguments you gave GNU CC to compile that example and
2340: observe the bug. For example, did you use @samp{-O}? To guarantee
2341: you won't omit something important, list them all.
2342:
2343: If I were to try to guess the arguments, I would probably guess wrong
2344: and then I would not encounter the bug.
1.1 root 2345:
2346: @item
1.1.1.2 root 2347: The names of the files that you used for @file{tm.h} and @file{md}
2348: when you installed the compiler.
1.1 root 2349:
2350: @item
1.1.1.2 root 2351: The type of machine you are using, and the operating system name and
2352: version number.
1.1 root 2353:
2354: @item
1.1.1.2 root 2355: A description of what behavior you observe that you believe is
2356: incorrect. For example, ``It gets a fatal signal,'' or, ``There is an
2357: incorrect assembler instruction in the output.''
2358:
2359: Of course, if the bug is that the compiler gets a fatal signal, then I
2360: will certainly notice it. But if the bug is incorrect output, I might
2361: not notice unless it is glaringly wrong. I won't study all the
2362: assembler code from a 50-line C program just on the off chance that it
2363: might be wrong.
2364:
2365: Even if the problem you experience is a fatal signal, you should still
2366: say so explicitly. Suppose something strange is going on, such as,
2367: your copy of the compiler is out of synch, or you have encountered a
2368: bug in the C library on your system. (This has happened!) Your copy
2369: might crash and mine would not. If you @i{told} me to expect a crash,
2370: then when mine fails to crash, I would know that the bug was not
2371: happening for me. If you had not told me to expect a crash, then I
2372: would not be able to draw any conclusion from my observations.
2373:
2374: In cases where GNU CC generates incorrect code, if you send me a small
2375: complete sample program I will find the error myself by running the
2376: program under a debugger. If you send me a large example or a part of
2377: a larger program, I cannot do this; you must debug the compiled
2378: program and narrow the problem down to one source line. Tell me which
2379: source line it is, and what you believe is incorrect about the code
2380: generated for that line.
1.1 root 2381:
2382: @item
1.1.1.2 root 2383: If you send me examples of output from GNU CC, please use @samp{-g}
2384: when you make them. The debugging information includes source line
2385: numbers which are essential for correlating the output with the input.
1.1.1.4 root 2386:
2387: @item
2388: If you wish to suggest changes to the GNU CC source, send me context
2389: diffs. If you even discuss something in the GNU CC source, refer to
2390: it by context, not by line number.
2391:
2392: The line numbers in my development sources don't match those in your
2393: sources. They won't tell me anything.
1.1 root 2394: @end itemize
2395:
1.1.1.2 root 2396: Here are some things that are not necessary:
1.1 root 2397:
1.1.1.2 root 2398: @itemize @bullet
1.1 root 2399: @item
1.1.1.2 root 2400: A description of the envelope of the bug.
1.1 root 2401:
1.1.1.2 root 2402: Often people who encounter a bug spend a lot of time investigating
2403: which changes to the input file will make the bug go away and which
2404: changes will not affect it.
1.1 root 2405:
1.1.1.2 root 2406: This is often time consuming and not very useful, because the way I
2407: will find the bug is by running a single example under the debugger
2408: with breakpoints, not by pure deduction from a series of examples.
1.1 root 2409:
1.1.1.2 root 2410: Of course, it can't hurt if you can find a simpler example that
2411: triggers the same bug. Errors in the output will be easier to spot,
2412: running under the debugger will take less time, etc. An easy way
2413: to simplify an example is to delete all the function definitions
2414: except the one where the bug occurs. Those earlier in the file
2415: may be replaced by external declarations.
2416:
2417: However, simplification is not necessary; if you don't want to do
2418: this, report the bug anyway.
1.1 root 2419:
2420: @item
1.1.1.2 root 2421: A patch for the bug.
1.1 root 2422:
1.1.1.2 root 2423: A patch for the bug does help me if it is a good one. But don't omit
2424: the necessary information, such as the test case, because I might see
2425: problems with your patch and decide to fix the problem another way.
1.1 root 2426:
1.1.1.2 root 2427: Sometimes with a program as complicated as GNU CC it is very hard to
2428: construct an example that will make the program go through a certain
2429: point in the code. If you don't send me the example, I won't be able
2430: to verify that the bug is fixed.
1.1 root 2431:
2432: @item
1.1.1.2 root 2433: A guess about what the bug is or what it depends on.
2434:
2435: Such guesses are usually wrong. Even I can't guess right about such
2436: things without using the debugger to find the facts. They also don't
2437: serve a useful purpose.
2438: @end itemize
1.1 root 2439:
1.1.1.2 root 2440: @node Portability, Interface, Bugs, Top
1.1 root 2441: @chapter GNU CC and Portability
2442:
2443: The main goal of GNU CC was to make a good, fast compiler for machines in
2444: the class that the GNU system aims to run on: 32-bit machines that address
2445: 8-bit bytes and have several general registers. Elegance, theoretical
2446: power and simplicity are only secondary.
2447:
2448: GNU CC gets most of the information about the target machine from a machine
2449: description which gives an algebraic formula for each of the machine's
2450: instructions. This is a very clean way to describe the target. But when
2451: the compiler needs information that is difficult to express in this
2452: fashion, I have not hesitated to define an ad-hoc parameter to the machine
2453: description. The purpose of portability is to reduce the total work needed
2454: on the compiler; it was not of interest for its own sake.
2455:
2456: GNU CC does not contain machine dependent code, but it does contain code
2457: that depends on machine parameters such as endianness (whether the most
2458: significant byte has the highest or lowest address of the bytes in a word)
2459: and the availability of autoincrement addressing. In the RTL-generation
2460: pass, it is often necessary to have multiple strategies for generating code
2461: for a particular kind of syntax tree, strategies that are usable for different
2462: combinations of parameters. Often I have not tried to address all possible
2463: cases, but only the common ones or only the ones that I have encountered.
2464: As a result, a new target may require additional strategies. You will know
2465: if this happens because the compiler will call @code{abort}. Fortunately,
1.1.1.2 root 2466: the new strategies can be added in a machine-independent fashion, and will
2467: affect only the target machines that need them.
2468:
2469: @node Interface, Passes, Portability, Top
2470: @chapter Interfacing to GNU CC Output
2471:
2472: GNU CC is normally configured to use the same function calling convention
2473: normally in use on the target system. This is done with the
2474: machine-description macros described (@pxref{Machine Macros}).
2475:
1.1.1.9 ! root 2476: However, returning of structure and union values is done differently on
! 2477: some target machines. As a result, functions compiled with PCC
! 2478: returning such types cannot be called from code compiled with GNU CC,
! 2479: and vice versa. This does not cause trouble often because few Unix
! 2480: library routines return structures or unions.
! 2481:
! 2482: GNU CC code returns structures and unions that are 1, 2, 4 or 8 bytes
! 2483: long in the same registers used for @code{int} or @code{double} return
! 2484: values. (GNU CC typically allocates variables of such types in
! 2485: registers also.) Structures and unions of other sizes are returned by
! 2486: storing them into an address passed by the caller (usually in a
! 2487: register). The machine-description macros @code{STRUCT_VALUE} and
! 2488: @code{STRUCT_INCOMING_VALUE} tell GNU CC where to pass this address.
! 2489:
! 2490: By contrast, PCC on most target machines returns structures and unions
! 2491: of any size by copying the data into an area of static storage, and then
! 2492: returning the address of that storage as if it were a pointer value.
! 2493: The caller must copy the data from that memory area to the place where
! 2494: the value is wanted. This is slower than the method used by GNU CC, and
! 2495: fails to be reentrant.
! 2496:
! 2497: On some target machines, such as RISC machines and the 80386, the
! 2498: standard system convention is to pass to the subroutine the address of
! 2499: where to return the value. On these machines, GNU CC has been
! 2500: configured to be compatible with the standard compiler, when this method
! 2501: is used. It may not be compatible for structures of 1, 2, 4 or 8 bytes.
! 2502:
! 2503: GNU CC uses the system's standard convention for passing arguments. On
! 2504: some machines, the first few arguments are passed in registers; in
! 2505: others, all are passed on the stack. It would be possible to use
! 2506: registers for argument passing on any machine, and this would probably
! 2507: result in a significant speedup. But the result would be complete
! 2508: incompatibility with code that follows the standard convention. So this
! 2509: change is practical only if you are switching to GNU CC as the sole C
! 2510: compiler for the system. We may implement register argument passing on
! 2511: certain machines once we have a complete GNU system so that we can
! 2512: compile the libraries with GNU CC.
1.1.1.2 root 2513:
2514: If you use @code{longjmp}, beware of automatic variables. ANSI C says that
2515: automatic variables that are not declared @code{volatile} have undefined
2516: values after a @code{longjmp}. And this is all GNU CC promises to do,
2517: because it is very difficult to restore register variables correctly, and
2518: one of GNU CC's features is that it can put variables in registers without
2519: your asking it to.
2520:
2521: If you want a variable to be unaltered by @code{longjmp}, and you don't
2522: want to write @code{volatile} because old C compilers don't accept it,
2523: just take the address of the variable. If a variable's address is ever
2524: taken, even if just to compute it and ignore it, then the variable cannot
2525: go in a register:
2526:
2527: @example
2528: @{
2529: int careful;
2530: &careful;
2531: @dots{}
2532: @}
2533: @end example
1.1 root 2534:
1.1.1.9 ! root 2535: Code compiled with GNU CC may call certain library routines. Most of
! 2536: them handle arithmetic for which there are no instructions. This
! 2537: includes multiply and divide on some machines, and floating point
! 2538: operations on any machine for which floating point support is disabled
! 2539: with @samp{-msoft-float}. Some standard parts of the C library, such as
! 2540: @code{bcopy} or @code{memcpy}, are also called automatically. The usual
! 2541: function call interface is used for calling the library routines.
! 2542:
! 2543: These library routines should be defined in the library @file{gnulib},
! 2544: which GNU CC automatically searches whenever it links a program. On
! 2545: machines that have multiply and divide instructions, if hardware
! 2546: floating point is in use, normally @file{gnulib} is not needed, but it
! 2547: is searched just in case.
! 2548:
! 2549: Each arithmetic function is defined in @file{gnulib.c} to use the
! 2550: corresponding C arithmetic operator. As long as the file is compiled
! 2551: with another C compiler, which supports all the C arithmetic operators,
! 2552: this file will work portably. However, @file{gnulib.c} does not work if
! 2553: compiled with GNU CC, because each arithmetic function would compile
! 2554: into a call to itself!
1.1.1.2 root 2555:
2556: @node Passes, RTL, Interface, Top
1.1 root 2557: @chapter Passes and Files of the Compiler
2558:
2559: The overall control structure of the compiler is in @file{toplev.c}. This
2560: file is responsible for initialization, decoding arguments, opening and
2561: closing files, and sequencing the passes.
2562:
1.1.1.2 root 2563: The parsing pass is invoked only once, to parse the entire input. The RTL
2564: intermediate code for a function is generated as the function is parsed, a
2565: statement at a time. Each statement is read in as a syntax tree and then
2566: converted to RTL; then the storage for the tree for the statement is
2567: reclaimed. Storage for types (and the expressions for their sizes),
2568: declarations, and a representation of the binding contours and how they nest,
2569: remains until the function is finished being compiled; these are all needed
2570: to output the debugging information.
2571:
2572: Each time the parsing pass reads a complete function definition or
2573: top-level declaration, it calls the function
2574: @code{rest_of_compilation} or @code{rest_of_decl_compilation} in
2575: @file{toplev.c}, which are responsible for all further processing
2576: necessary, ending with output of the assembler language. All other
2577: compiler passes run, in sequence, within @code{rest_of_compilation}.
2578: When that function returns from compiling a function definition, the
2579: storage used for that function definition's compilation is entirely
2580: freed, unless it is an inline function (@pxref{Inline}).
1.1 root 2581:
2582: Here is a list of all the passes of the compiler and their source files.
2583: Also included is a description of where debugging dumps can be requested
1.1.1.2 root 2584: with @samp{-d} options.
1.1 root 2585:
2586: @itemize @bullet
2587: @item
2588: Parsing. This pass reads the entire text of a function definition,
1.1.1.2 root 2589: constructing partial syntax trees. This and RTL generation are no longer
2590: truly separate passes (formerly they were), but it is easier to think
2591: of them as separate.
2592:
2593: The tree representation does not entirely follow C syntax, because it is
2594: intended to support other languages as well.
1.1 root 2595:
1.1.1.2 root 2596: C data type analysis is also done in this pass, and every tree node
2597: that represents an expression has a data type attached. Variables are
2598: represented as declaration nodes.
1.1 root 2599:
1.1.1.2 root 2600: Constant folding and associative-law simplifications are also done
2601: during this pass.
1.1 root 2602:
1.1.1.7 root 2603: The source files for parsing are @file{c-parse.y}, @file{c-decl.c},
2604: @file{c-typeck.c}, @file{c-convert.c}, @file{stor-layout.c},
2605: @file{fold-const.c}, and @file{tree.c}. The last three files are
2606: intended to be language-independent. There are also header files
2607: @file{c-parse.h}, @file{c-tree.h}, @file{tree.h} and @file{tree.def}.
2608: The last two define the format of the tree representation.@refill
1.1 root 2609:
2610: @item
1.1.1.2 root 2611: RTL generation. This is the conversion of syntax tree into RTL code.
2612: It is actually done statement-by-statement during parsing, but for
2613: most purposes it can be thought of as a separate pass.
1.1 root 2614:
2615: This is where the bulk of target-parameter-dependent code is found,
2616: since often it is necessary for strategies to apply only when certain
2617: standard kinds of instructions are available. The purpose of named
2618: instruction patterns is to provide this information to the RTL
2619: generation pass.
2620:
2621: Optimization is done in this pass for @code{if}-conditions that are
2622: comparisons, boolean operations or conditional expressions. Tail
2623: recursion is detected at this time also. Decisions are made about how
2624: best to arrange loops and how to output @code{switch} statements.
2625:
1.1.1.2 root 2626: The source files for RTL generation are @file{stmt.c}, @file{expr.c},
1.1 root 2627: @file{explow.c}, @file{expmed.c}, @file{optabs.c} and @file{emit-rtl.c}.
2628: Also, the file @file{insn-emit.c}, generated from the machine description
2629: by the program @code{genemit}, is used in this pass. The header files
1.1.1.2 root 2630: @file{expr.h} is used for communication within this pass.@refill
1.1 root 2631:
1.1.1.2 root 2632: The header files @file{insn-flags.h} and @file{insn-codes.h},
2633: generated from the machine description by the programs @code{genflags}
2634: and @code{gencodes}, tell this pass which standard names are available
2635: for use and which patterns correspond to them.@refill
1.1 root 2636:
2637: Aside from debugging information output, none of the following passes
1.1.1.2 root 2638: refers to the tree structure representation of the function (only
2639: part of which is saved).
1.1 root 2640:
1.1.1.2 root 2641: The decision of whether the function can and should be expanded inline
2642: in its subsequent callers is made at the end of rtl generation. The
2643: function must meet certain criteria, currently related to the size of
2644: the function and the types and number of parameters it has. Note that
2645: this function may contain loops, recursive calls to itself
2646: (tail-recursive functions can be inlined!), gotos, in short, all
2647: constructs supported by GNU CC.
2648:
2649: The option @samp{-dr} causes a debugging dump of the RTL code after
2650: this pass. This dump file's name is made by appending @samp{.rtl} to
2651: the input file name.
1.1 root 2652:
2653: @item
1.1.1.2 root 2654: Jump optimization. This pass simplifies jumps to the following
2655: instruction, jumps across jumps, and jumps to jumps. It deletes
2656: unreferenced labels and unreachable code, except that unreachable code
2657: that contains a loop is not recognized as unreachable in this pass.
2658: (Such loops are deleted later in the basic block analysis.)
1.1 root 2659:
2660: Jump optimization is performed two or three times. The first time is
1.1.1.2 root 2661: immediately following RTL generation. The second time is after CSE,
2662: but only if CSE says repeated jump optimization is needed. The
2663: last time is right before the final pass. That time, cross-jumping
2664: and deletion of no-op move instructions are done together with the
2665: optimizations described above.
1.1 root 2666:
2667: The source file of this pass is @file{jump.c}.
2668:
1.1.1.2 root 2669: The option @samp{-dj} causes a debugging dump of the RTL code after
2670: this pass is run for the first time. This dump file's name is made by
2671: appending @samp{.jump} to the input file name.
1.1 root 2672:
2673: @item
2674: Register scan. This pass finds the first and last use of each
2675: register, as a guide for common subexpression elimination. Its source
2676: is in @file{regclass.c}.
2677:
2678: @item
2679: Common subexpression elimination. This pass also does constant
2680: propagation. Its source file is @file{cse.c}. If constant
2681: propagation causes conditional jumps to become unconditional or to
1.1.1.2 root 2682: become no-ops, jump optimization is run again when CSE is finished.
1.1 root 2683:
1.1.1.2 root 2684: The option @samp{-ds} causes a debugging dump of the RTL code after
1.1 root 2685: this pass. This dump file's name is made by appending @samp{.cse} to
2686: the input file name.
2687:
2688: @item
2689: Loop optimization. This pass moves constant expressions out of loops.
2690: Its source file is @file{loop.c}.
2691:
1.1.1.2 root 2692: The option @samp{-dL} causes a debugging dump of the RTL code after
1.1 root 2693: this pass. This dump file's name is made by appending @samp{.loop} to
2694: the input file name.
2695:
2696: @item
2697: Stupid register allocation is performed at this point in a
2698: nonoptimizing compilation. It does a little data flow analysis as
2699: well. When stupid register allocation is in use, the next pass
2700: executed is the reloading pass; the others in between are skipped.
1.1.1.2 root 2701: The source file is @file{stupid.c}.
1.1 root 2702:
2703: @item
2704: Data flow analysis (@file{flow.c}). This pass divides the program
2705: into basic blocks (and in the process deletes unreachable loops); then
2706: it computes which pseudo-registers are live at each point in the
2707: program, and makes the first instruction that uses a value point at
2708: the instruction that computed the value.
2709:
2710: This pass also deletes computations whose results are never used, and
2711: combines memory references with add or subtract instructions to make
2712: autoincrement or autodecrement addressing.
2713:
1.1.1.2 root 2714: The option @samp{-df} causes a debugging dump of the RTL code after
1.1 root 2715: this pass. This dump file's name is made by appending @samp{.flow} to
2716: the input file name. If stupid register allocation is in use, this
2717: dump file reflects the full results of such allocation.
2718:
2719: @item
2720: Instruction combination (@file{combine.c}). This pass attempts to
2721: combine groups of two or three instructions that are related by data
2722: flow into single instructions. It combines the RTL expressions for
2723: the instructions by substitution, simplifies the result using algebra,
2724: and then attempts to match the result against the machine description.
2725:
1.1.1.2 root 2726: The option @samp{-dc} causes a debugging dump of the RTL code after
1.1 root 2727: this pass. This dump file's name is made by appending @samp{.combine}
2728: to the input file name.
2729:
2730: @item
2731: Register class preferencing. The RTL code is scanned to find out
1.1.1.2 root 2732: which register class is best for each pseudo register. The source
2733: file is @file{regclass.c}.
1.1 root 2734:
2735: @item
2736: Local register allocation (@file{local-alloc.c}). This pass allocates
2737: hard registers to pseudo registers that are used only within one basic
1.1.1.2 root 2738: block. Because the basic block is linear, it can use fast and
2739: powerful techniques to do a very good job.
1.1 root 2740:
1.1.1.2 root 2741: The option @samp{-dl} causes a debugging dump of the RTL code after
1.1 root 2742: this pass. This dump file's name is made by appending @samp{.lreg} to
2743: the input file name.
2744:
2745: @item
2746: Global register allocation (@file{global-alloc.c}). This pass
2747: allocates hard registers for the remaining pseudo registers (those
2748: whose life spans are not contained in one basic block).
2749:
2750: @item
1.1.1.2 root 2751: Reloading. This pass renumbers pseudo registers with the hardware
2752: registers numbers they were allocated. Pseudo registers that did not
2753: get hard registers are replaced with stack slots. Then it finds
2754: instructions that are invalid because a value has failed to end up in
2755: a register, or has ended up in a register of the wrong kind. It fixes
2756: up these instructions by reloading the problematical values
2757: temporarily into registers. Additional instructions are generated to
2758: do the copying.
1.1 root 2759:
2760: Source files are @file{reload.c} and @file{reload1.c}, plus the header
2761: @file{reload.h} used for communication between them.
2762:
1.1.1.2 root 2763: The option @samp{-dg} causes a debugging dump of the RTL code after
1.1 root 2764: this pass. This dump file's name is made by appending @samp{.greg} to
2765: the input file name.
2766:
2767: @item
1.1.1.2 root 2768: Jump optimization is repeated, this time including cross-jumping
2769: and deletion of no-op move instructions. Machine-specific peephole
2770: optimizations are performed at the same time.
2771:
2772: The option @samp{-dJ} causes a debugging dump of the RTL code after
2773: this pass. This dump file's name is made by appending @samp{.jump2}
2774: to the input file name.
1.1 root 2775:
2776: @item
2777: Final. This pass outputs the assembler code for the function. It is
1.1.1.2 root 2778: also responsible for identifying spurious test and compare
2779: instructions. The function entry and exit sequences are generated
2780: directly as assembler code in this pass; they never exist as RTL.
1.1 root 2781:
2782: The source files are @file{final.c} plus @file{insn-output.c}; the
2783: latter is generated automatically from the machine description by the
2784: tool @file{genoutput}. The header file @file{conditions.h} is used
2785: for communication between these files.
2786:
2787: @item
2788: Debugging information output. This is run after final because it must
2789: output the stack slot offsets for pseudo registers that did not get
2790: hard registers. Source files are @file{dbxout.c} for DBX symbol table
2791: format and @file{symout.c} for GDB's own symbol table format.
2792: @end itemize
2793:
2794: Some additional files are used by all or many passes:
2795:
2796: @itemize @bullet
2797: @item
2798: Every pass uses @file{machmode.def}, which defines the machine modes.
2799:
2800: @item
2801: All the passes that work with RTL use the header files @file{rtl.h}
1.1.1.2 root 2802: and @file{rtl.def}, and subroutines in file @file{rtl.c}. The tools
2803: @code{gen*} also use these files to read and work with the machine
2804: description RTL.
1.1 root 2805:
2806: @item
2807: Several passes refer to the header file @file{insn-config.h} which
2808: contains a few parameters (C macro definitions) generated
2809: automatically from the machine description RTL by the tool
2810: @code{genconfig}.
2811:
2812: @item
2813: Several passes use the instruction recognizer, which consists of
2814: @file{recog.c} and @file{recog.h}, plus the files @file{insn-recog.c}
2815: and @file{insn-extract.c} that are generated automatically from the
1.1.1.2 root 2816: machine description by the tools @file{genrecog} and
2817: @file{genextract}.@refill
1.1 root 2818:
2819: @item
1.1.1.2 root 2820: Several passes use the header files @file{regs.h} which defines the
2821: information recorded about pseudo register usage, and @file{basic-block.h}
1.1 root 2822: which defines the information recorded about basic blocks.
2823:
2824: @item
2825: @file{hard-reg-set.h} defines the type @code{HARD_REG_SET}, a bit-vector
2826: with a bit for each hard register, and some macros to manipulate it.
2827: This type is just @code{int} if the machine has few enough hard registers;
2828: otherwise it is an array of @code{int} and some of the macros expand
2829: into loops.
2830: @end itemize
2831:
2832: @node RTL, Machine Desc, Passes, Top
2833: @chapter RTL Representation
2834:
2835: Most of the work of the compiler is done on an intermediate representation
1.1.1.2 root 2836: called register transfer language. In this language, the instructions to be
1.1 root 2837: output are described, pretty much one by one, in an algebraic form that
2838: describes what the instruction does.
2839:
2840: RTL is inspired by Lisp lists. It has both an internal form, made up of
2841: structures that point at other structures, and a textual form that is used
2842: in the machine description and in printed debugging dumps. The textual
2843: form uses nested parentheses to indicate the pointers in the internal form.
2844:
2845: @menu
2846: * RTL Objects:: Expressions vs vectors vs strings vs integers.
2847: * Accessors:: Macros to access expression operands or vector elts.
1.1.1.2 root 2848: * Flags:: Other flags in an RTL expression.
1.1 root 2849: * Machine Modes:: Describing the size and format of a datum.
2850: * Constants:: Expressions with constant values.
2851: * Regs and Memory:: Expressions representing register contents or memory.
2852: * Arithmetic:: Expressions representing arithmetic on other expressions.
2853: * Comparisons:: Expressions representing comparison of expressions.
2854: * Bit Fields:: Expressions representing bit-fields in memory or reg.
2855: * Conversions:: Extending, truncating, floating or fixing.
2856: * RTL Declarations:: Declaring volatility, constancy, etc.
2857: * Side Effects:: Expressions for storing in registers, etc.
2858: * Incdec:: Embedded side-effects for autoincrement addressing.
1.1.1.2 root 2859: * Assembler:: Representing @code{asm} with operands.
1.1 root 2860: * Insns:: Expression types for entire insns.
1.1.1.2 root 2861: * Calls:: RTL representation of function call insns.
1.1 root 2862: * Sharing:: Some expressions are unique; others *must* be copied.
2863: @end menu
2864:
2865: @node RTL Objects, Accessors, RTL, RTL
2866: @section RTL Object Types
2867:
2868: RTL uses four kinds of objects: expressions, integers, strings and vectors.
1.1.1.2 root 2869: Expressions are the most important ones. An RTL expression (``RTX'', for
2870: short) is a C structure, but it is usually referred to with a pointer; a
2871: type that is given the typedef name @code{rtx}.
1.1 root 2872:
2873: An integer is simply an @code{int}, and a string is a @code{char *}.
1.1.1.2 root 2874: Within RTL code, strings appear only inside @samp{symbol_ref} expressions,
2875: but they appear in other contexts in the RTL expressions that make up
1.1 root 2876: machine descriptions. Their written form uses decimal digits.
2877:
2878: A string is a sequence of characters. In core it is represented as a
1.1.1.2 root 2879: @code{char *} in usual C fashion, and it is written in C syntax as well.
1.1 root 2880: However, strings in RTL may never be null. If you write an empty string in
2881: a machine description, it is represented in core as a null pointer rather
2882: than as a pointer to a null character. In certain contexts, these null
2883: pointers instead of strings are valid.
2884:
2885: A vector contains an arbitrary, specified number of pointers to
2886: expressions. The number of elements in the vector is explicitly present in
2887: the vector. The written form of a vector consists of square brackets
2888: (@samp{[@dots{}]}) surrounding the elements, in sequence and with
2889: whitespace separating them. Vectors of length zero are not created; null
2890: pointers are used instead.
2891:
1.1.1.2 root 2892: Expressions are classified by @dfn{expression codes} (also called RTX
2893: codes). The expression code is a name defined in @file{rtl.def}, which is
2894: also (in upper case) a C enumeration constant. The possible expression
2895: codes and their meanings are machine-independent. The code of an RTX can
2896: be extracted with the macro @code{GET_CODE (@var{x})} and altered with
2897: @code{PUT_CODE (@var{x}, @var{newcode})}.
1.1 root 2898:
2899: The expression code determines how many operands the expression contains,
2900: and what kinds of objects they are. In RTL, unlike Lisp, you cannot tell
2901: by looking at an operand what kind of object it is. Instead, you must know
2902: from its context---from the expression code of the containing expression.
1.1.1.2 root 2903: For example, in an expression of code @samp{subreg}, the first operand is
1.1 root 2904: to be regarded as an expression and the second operand as an integer. In
1.1.1.2 root 2905: an expression of code @samp{plus}, there are two operands, both of which
2906: are to be regarded as expressions. In a @samp{symbol_ref} expression,
1.1 root 2907: there is one operand, which is to be regarded as a string.
2908:
2909: Expressions are written as parentheses containing the name of the
2910: expression type, its flags and machine mode if any, and then the operands
2911: of the expression (separated by spaces).
2912:
1.1.1.2 root 2913: Expression code names in the @samp{md} file are written in lower case,
2914: but when they appear in C code they are written in upper case. In this
2915: manual, they are shown as follows: @samp{const_int}.
2916:
1.1 root 2917: In a few contexts a null pointer is valid where an expression is normally
2918: wanted. The written form of this is @samp{(nil)}.
2919:
1.1.1.2 root 2920: @node Accessors, Flags, RTL Objects, RTL
1.1 root 2921: @section Access to Operands
2922:
2923: For each expression type @file{rtl.def} specifies the number of contained
2924: objects and their kinds, with four possibilities: @samp{e} for expression
2925: (actually a pointer to an expression), @samp{i} for integer, @samp{s} for
2926: string, and @samp{E} for vector of expressions. The sequence of letters
2927: for an expression code is called its @dfn{format}. Thus, the format of
1.1.1.2 root 2928: @samp{subreg} is @samp{ei}.@refill
1.1 root 2929:
2930: Two other format characters are used occasionally: @samp{u} and @samp{0}.
2931: @samp{u} is equivalent to @samp{e} except that it is printed differently in
2932: debugging dumps, and @samp{0} means a slot whose contents do not fit any
2933: normal category. @samp{0} slots are not printed at all in dumps, and are
1.1.1.2 root 2934: often used in special ways by small parts of the compiler.@refill
1.1 root 2935:
2936: There are macros to get the number of operands and the format of an
2937: expression code:
2938:
2939: @table @code
2940: @item GET_RTX_LENGTH (@var{code})
1.1.1.2 root 2941: Number of operands of an RTX of code @var{code}.
1.1 root 2942:
2943: @item GET_RTX_FORMAT (@var{code})
1.1.1.2 root 2944: The format of an RTX of code @var{code}, as a C string.
1.1 root 2945: @end table
2946:
2947: Operands of expressions are accessed using the macros @code{XEXP},
2948: @code{XINT} and @code{XSTR}. Each of these macros takes two arguments: an
1.1.1.2 root 2949: expression-pointer (RTX) and an operand number (counting from zero).
2950: Thus,@refill
1.1 root 2951:
2952: @example
1.1.1.2 root 2953: XEXP (@var{x}, 2)
1.1 root 2954: @end example
2955:
2956: @noindent
2957: accesses operand 2 of expression @var{x}, as an expression.
2958:
2959: @example
1.1.1.2 root 2960: XINT (@var{x}, 2)
1.1 root 2961: @end example
2962:
2963: @noindent
2964: accesses the same operand as an integer. @code{XSTR}, used in the same
2965: fashion, would access it as a string.
2966:
2967: Any operand can be accessed as an integer, as an expression or as a string.
2968: You must choose the correct method of access for the kind of value actually
2969: stored in the operand. You would do this based on the expression code of
2970: the containing expression. That is also how you would know how many
2971: operands there are.
2972:
2973: For example, if @var{x} is a @samp{subreg} expression, you know that it has
1.1.1.2 root 2974: two operands which can be correctly accessed as @code{XEXP (@var{x}, 0)}
2975: and @code{XINT (@var{x}, 1)}. If you did @code{XINT (@var{x}, 0)}, you
2976: would get the address of the expression operand but cast as an integer;
2977: that might occasionally be useful, but it would be cleaner to write
2978: @code{(int) XEXP (@var{x}, 0)}. @code{XEXP (@var{x}, 1)} would also
2979: compile without error, and would return the second, integer operand cast as
2980: an expression pointer, which would probably result in a crash when
2981: accessed. Nothing stops you from writing @code{XEXP (@var{x}, 28)} either,
2982: but this will access memory past the end of the expression with
2983: unpredictable results.@refill
1.1 root 2984:
2985: Access to operands which are vectors is more complicated. You can use the
2986: macro @code{XVEC} to get the vector-pointer itself, or the macros
2987: @code{XVECEXP} and @code{XVECLEN} to access the elements and length of a
2988: vector.
2989:
2990: @table @code
2991: @item XVEC (@var{exp}, @var{idx})
2992: Access the vector-pointer which is operand number @var{idx} in @var{exp}.
2993:
2994: @item XVECLEN (@var{exp}, @var{idx})
2995: Access the length (number of elements) in the vector which is
2996: in operand number @var{idx} in @var{exp}. This value is an @code{int}.
2997:
1.1.1.2 root 2998: @item XVECEXP (@var{exp}, @var{idx}, @var{eltnum})
1.1 root 2999: Access element number @var{eltnum} in the vector which is
1.1.1.2 root 3000: in operand number @var{idx} in @var{exp}. This value is an RTX.
1.1 root 3001:
3002: It is up to you to make sure that @var{eltnum} is not negative
3003: and is less than @code{XVECLEN (@var{exp}, @var{idx})}.
3004: @end table
3005:
3006: All the macros defined in this section expand into lvalues and therefore
3007: can be used to assign the operands, lengths and vector elements as well as
3008: to access them.
3009:
1.1.1.2 root 3010: @node Flags, Machine Modes, Accessors, RTL
3011: @section Flags in an RTL Expression
3012:
3013: RTL expressions contain several flags (one-bit bit-fields) that are used
3014: in certain types of expression.
3015:
3016: @table @code
3017: @item used
3018: This flag is used only momentarily, at the end of RTL generation for a
3019: function, to count the number of times an expression appears in insns.
3020: Expressions that appear more than once are copied, according to the
3021: rules for shared structure (@pxref{Sharing}).
3022:
3023: @item volatil
3024: This flag is used in @samp{mem} and @samp{reg} expressions and in insns.
3025: In RTL dump files, it is printed as @samp{/v}.
3026:
3027: In a @samp{mem} expression, it is 1 if the memory reference is volatile.
3028: Volatile memory references may not be deleted, reordered or combined.
3029:
3030: In a @samp{reg} expression, it is 1 if the value is a user-level variable.
3031: 0 indicates an internal compiler temporary.
3032:
3033: In an insn, 1 means the insn has been deleted.
3034:
3035: @item in_struct
3036: This flag is used in @samp{mem} expressions. It is 1 if the memory
3037: datum referred to is all or part of a structure or array; 0 if it is (or
3038: might be) a scalar variable. A reference through a C pointer has 0
3039: because the pointer might point to a scalar variable.
3040:
3041: This information allows the compiler to determine something about possible
3042: cases of aliasing.
3043:
3044: In an RTL dump, this flag is represented as @samp{/s}.
3045:
3046: @item unchanging
3047: This flag is used in @samp{reg} and @samp{mem} expressions. 1 means
3048: that the value of the expression never changes (at least within the
3049: current function).
3050:
3051: In an RTL dump, this flag is represented as @samp{/u}.
1.1.1.6 root 3052:
3053: @item integrated
3054: In some kinds of expressions, including insns, this flag means the
3055: rtl was produced by procedure integration.
3056:
3057: In a @samp{reg} expression, this flag indicates the register
3058: containing the value to be returned by the current function. On
3059: machines that pass parameters in registers, the same register number
3060: may be used for parameters as well, but this flag is not set on such
3061: uses.
1.1.1.2 root 3062: @end table
3063:
3064: @node Machine Modes, Constants, Flags, RTL
1.1 root 3065: @section Machine Modes
3066:
3067: A machine mode describes a size of data object and the representation used
3068: for it. In the C code, machine modes are represented by an enumeration
1.1.1.2 root 3069: type, @code{enum machine_mode}, defined in @file{machmode.def}. Each RTL
3070: expression has room for a machine mode and so do certain kinds of tree
3071: expressions (declarations and types, to be precise).
1.1 root 3072:
3073: In debugging dumps and machine descriptions, the machine mode of an RTL
3074: expression is written after the expression code with a colon to separate
3075: them. The letters @samp{mode} which appear at the end of each machine mode
3076: name are omitted. For example, @code{(reg:SI 38)} is a @samp{reg}
3077: expression with machine mode @code{SImode}. If the mode is
3078: @code{VOIDmode}, it is not written at all.
3079:
3080: Here is a table of machine modes.
3081:
3082: @table @code
3083: @item QImode
3084: ``Quarter-Integer'' mode represents a single byte treated as an integer.
3085:
3086: @item HImode
3087: ``Half-Integer'' mode represents a two-byte integer.
3088:
3089: @item SImode
3090: ``Single Integer'' mode represents a four-byte integer.
3091:
3092: @item DImode
3093: ``Double Integer'' mode represents an eight-byte integer.
3094:
3095: @item TImode
3096: ``Tetra Integer'' (?) mode represents a sixteen-byte integer.
3097:
3098: @item SFmode
3099: ``Single Floating'' mode represents a single-precision (four byte) floating
3100: point number.
3101:
3102: @item DFmode
3103: ``Double Floating'' mode represents a double-precision (eight byte) floating
3104: point number.
3105:
3106: @item TFmode
3107: ``Tetra Floating'' mode represents a quadruple-precision (sixteen byte)
3108: floating point number.
3109:
3110: @item BLKmode
3111: ``Block'' mode represents values that are aggregates to which none of
1.1.1.2 root 3112: the other modes apply. In RTL, only memory references can have this mode,
1.1 root 3113: and only if they appear in string-move or vector instructions. On machines
3114: which have no such instructions, @code{BLKmode} will not appear in RTL.
3115:
3116: @item VOIDmode
3117: Void mode means the absence of a mode or an unspecified mode.
1.1.1.2 root 3118: For example, RTL expressions of code @samp{const_int} have mode
1.1 root 3119: @code{VOIDmode} because they can be taken to have whatever mode the context
3120: requires. In debugging dumps of RTL, @code{VOIDmode} is expressed by
3121: the absence of any mode.
3122:
3123: @item EPmode
3124: ``Entry Pointer'' mode is intended to be used for function variables in
3125: Pascal and other block structured languages. Such values contain
3126: both a function address and a static chain pointer for access to
3127: automatic variables of outer levels. This mode is only partially
3128: implemented since C does not use it.
3129:
3130: @item CSImode@r{, @dots{}}
3131: ``Complex Single Integer'' mode stands for a complex number represented
3132: as a pair of @code{SImode} integers. Any of the integer and floating modes
3133: may have @samp{C} prefixed to its name to obtain a complex number mode.
3134: For example, there are @code{CQImode}, @code{CSFmode}, and @code{CDFmode}.
3135: Since C does not support complex numbers, these machine modes are only
3136: partially implemented.
3137:
3138: @item BImode
3139: This is the machine mode of a bit-field in a structure. It is used
3140: only in the syntax tree, never in RTL, and in the syntax tree it appears
3141: only in declaration nodes. In C, it appears only in @code{FIELD_DECL}
3142: nodes for structure fields defined with a bit size.
3143: @end table
3144:
3145: The machine description defines @code{Pmode} as a C macro which expands
3146: into the machine mode used for addresses. Normally this is @code{SImode}.
3147:
3148: The only modes which a machine description @i{must} support are
3149: @code{QImode}, @code{SImode}, @code{SFmode} and @code{DFmode}. The
3150: compiler will attempt to use @code{DImode} for two-word structures and
3151: unions, but it would not be hard to program it to avoid this. Likewise,
3152: you can arrange for the C type @code{short int} to avoid using
3153: @code{HImode}. In the long term it would be desirable to make the set of
3154: available machine modes machine-dependent and eliminate all assumptions
3155: about specific machine modes or their uses from the machine-independent
3156: code of the compiler.
3157:
3158: Here are some C macros that relate to machine modes:
3159:
3160: @table @code
3161: @item GET_MODE (@var{x})
1.1.1.2 root 3162: Returns the machine mode of the RTX @var{x}.
1.1 root 3163:
3164: @item PUT_MODE (@var{x}, @var{newmode})
1.1.1.2 root 3165: Alters the machine mode of the RTX @var{x} to be @var{newmode}.
1.1 root 3166:
3167: @item GET_MODE_SIZE (@var{m})
3168: Returns the size in bytes of a datum of mode @var{m}.
3169:
3170: @item GET_MODE_BITSIZE (@var{m})
3171: Returns the size in bits of a datum of mode @var{m}.
3172:
3173: @item GET_MODE_UNIT_SIZE (@var{m})
3174: Returns the size in bits of the subunits of a datum of mode @var{m}.
3175: This is the same as @code{GET_MODE_SIZE} except in the case of
1.1.1.2 root 3176: complex modes and @code{EPmode}. For them, the unit size is the
1.1 root 3177: size of the real or imaginary part, or the size of the function
3178: pointer or the context pointer.
3179: @end table
3180:
3181: @node Constants, Regs and Memory, Machine Modes, RTL
3182: @section Constant Expression Types
3183:
3184: The simplest RTL expressions are those that represent constant values.
3185:
3186: @table @code
3187: @item (const_int @var{i})
3188: This type of expression represents the integer value @var{i}. @var{i}
3189: is customarily accessed with the macro @code{INTVAL} as in
1.1.1.2 root 3190: @code{INTVAL (@var{exp})}, which is equivalent to @code{XINT (@var{exp}, 0)}.
1.1 root 3191:
3192: There is only one expression object for the integer value zero;
3193: it is the value of the variable @code{const0_rtx}. Likewise, the
3194: only expression for integer value one is found in @code{const1_rtx}.
1.1.1.2 root 3195: Any attempt to create an expression of code @samp{const_int} and
1.1 root 3196: value zero or one will return @code{const0_rtx} or @code{const1_rtx}
3197: as appropriate.
3198:
3199: @item (const_double:@var{m} @var{i0} @var{i1})
3200: Represents a floating point constant value of mode @var{m}. The two
3201: integers @var{i0} and @var{i1} together contain the bits of a
3202: @code{double} value. To convert them to a @code{double}, do
3203:
3204: @example
1.1.1.2 root 3205: union @{ double d; int i[2];@} u;
1.1 root 3206: u.i[0] = XINT (x, 0);
3207: u.i[1] = XINT (x, 1);
3208: @end example
3209:
3210: @noindent
3211: and then refer to @code{u.d}. The value of the constant is
3212: represented as a double in this fashion even if the value represented
3213: is single-precision.
3214:
1.1.1.2 root 3215: The global variables @code{dconst0_rtx} and @code{fconst0_rtx} hold
3216: @samp{const_double} expressions with value 0, in modes @code{DFmode} and
3217: @code{SFmode}, respectively.
1.1 root 3218:
3219: @item (symbol_ref @var{symbol})
3220: Represents the value of an assembler label for data. @var{symbol} is
3221: a string that describes the name of the assembler label. If it starts
3222: with a @samp{*}, the label is the rest of @var{symbol} not including
3223: the @samp{*}. Otherwise, the label is @var{symbol}, prefixed with
3224: @samp{_}.
3225:
3226: @item (label_ref @var{label})
3227: Represents the value of an assembler label for code. It contains one
1.1.1.2 root 3228: operand, an expression, which must be a @samp{code_label} that appears
1.1 root 3229: in the instruction sequence to identify the place where the label
3230: should go.
3231:
3232: The reason for using a distinct expression type for code label
3233: references is so that jump optimization can distinguish them.
3234:
3235: @item (const @var{exp})
3236: Represents a constant that is the result of an assembly-time
3237: arithmetic computation. The operand, @var{exp}, is an expression that
3238: contains only constants (@samp{const_int}, @samp{symbol_ref} and
3239: @samp{label_ref} expressions) combined with @samp{plus} and
3240: @samp{minus}. However, not all combinations are valid, since the
3241: assembler cannot do arbitrary arithmetic on relocatable symbols.
3242: @end table
3243:
3244: @node Regs and Memory, Arithmetic, Constants, RTL
3245: @section Registers and Memory
3246:
3247: Here are the RTL expression types for describing access to machine
3248: registers and to main memory.
3249:
3250: @table @code
3251: @item (reg:@var{m} @var{n})
3252: For small values of the integer @var{n} (less than
3253: @code{FIRST_PSEUDO_REGISTER}), this stands for a reference to machine
3254: register number @var{n}: a @dfn{hard register}. For larger values of
3255: @var{n}, it stands for a temporary value or @dfn{pseudo register}.
3256: The compiler's strategy is to generate code assuming an unlimited
3257: number of such pseudo registers, and later convert them into hard
3258: registers or into memory references.
3259:
3260: The symbol @code{FIRST_PSEUDO_REGISTER} is defined by the machine
3261: description, since the number of hard registers on the machine is an
3262: invariant characteristic of the machine. Note, however, that not
3263: all of the machine registers must be general registers. All the
3264: machine registers that can be used for storage of data are given
3265: hard register numbers, even those that can be used only in certain
3266: instructions or can hold only certain types of data.
3267:
1.1.1.2 root 3268: Each pseudo register number used in a function's RTL code is
1.1 root 3269: represented by a unique @samp{reg} expression.
3270:
3271: @var{m} is the machine mode of the reference. It is necessary because
3272: machines can generally refer to each register in more than one mode.
3273: For example, a register may contain a full word but there may be
3274: instructions to refer to it as a half word or as a single byte, as
3275: well as instructions to refer to it as a floating point number of
3276: various precisions.
3277:
3278: Even for a register that the machine can access in only one mode,
3279: the mode must always be specified.
3280:
3281: A hard register may be accessed in various modes throughout one
3282: function, but each pseudo register is given a natural mode
3283: and is accessed only in that mode. When it is necessary to describe
3284: an access to a pseudo register using a nonnatural mode, a @samp{subreg}
3285: expression is used.
3286:
3287: A @samp{reg} expression with a machine mode that specifies more than
3288: one word of data may actually stand for several consecutive registers.
3289: If in addition the register number specifies a hardware register, then
3290: it actually represents several consecutive hardware registers starting
3291: with the specified one.
3292:
3293: Such multi-word hardware register @samp{reg} expressions may not be live
3294: across the boundary of a basic block. The lifetime analysis pass does not
3295: know how to record properly that several consecutive registers are
3296: actually live there, and therefore register allocation would be confused.
3297: The CSE pass must go out of its way to make sure the situation does
3298: not arise.
3299:
3300: @item (subreg:@var{m} @var{reg} @var{wordnum})
3301: @samp{subreg} expressions are used to refer to a register in a machine
3302: mode other than its natural one, or to refer to one register of
3303: a multi-word @samp{reg} that actually refers to several registers.
3304:
3305: Each pseudo-register has a natural mode. If it is necessary to
3306: operate on it in a different mode---for example, to perform a fullword
3307: move instruction on a pseudo-register that contains a single byte---
3308: the pseudo-register must be enclosed in a @samp{subreg}. In such
3309: a case, @var{wordnum} is zero.
3310:
3311: The other use of @samp{subreg} is to extract the individual registers
3312: of a multi-register value. Machine modes such as @code{DImode} and
3313: @code{EPmode} indicate values longer than a word, values which usually
3314: require two consecutive registers. To access one of the registers,
3315: use a @samp{subreg} with mode @code{SImode} and a @var{wordnum} that
3316: says which register.
3317:
3318: The compilation parameter @code{WORDS_BIG_ENDIAN}, if defined, says
3319: that word number zero is the most significant part; otherwise, it is
3320: the least significant part.
3321:
1.1.1.7 root 3322: Between the combiner pass and the reload pass, it is possible to have
3323: a @samp{subreg} which contains a @samp{mem} instead of a @samp{reg} as
3324: its first operand. The reload pass eliminates these cases by
3325: reloading the @samp{mem} into a suitable register.
3326:
1.1 root 3327: Note that it is not valid to access a @code{DFmode} value in @code{SFmode}
3328: using a @samp{subreg}. On some machines the most significant part of a
3329: @code{DFmode} value does not have the same format as a single-precision
3330: floating value.
3331:
3332: @item (cc0)
3333: This refers to the machine's condition code register. It has no
3334: operands and may not have a machine mode. It may be validly used in
3335: only two contexts: as the destination of an assignment (in test and
3336: compare instructions) and in comparison operators comparing against
1.1.1.2 root 3337: zero (@samp{const_int} with value zero; that is to say,
3338: @code{const0_rtx}).
1.1 root 3339:
1.1.1.2 root 3340: There is only one expression object of code @samp{cc0}; it is the
1.1 root 3341: value of the variable @code{cc0_rtx}. Any attempt to create an
1.1.1.2 root 3342: expression of code @samp{cc0} will return @code{cc0_rtx}.
1.1 root 3343:
1.1.1.2 root 3344: One special thing about the condition code register is that
3345: instructions can set it implicitly. On many machines, nearly all
3346: instructions set the condition code based on the value that they
3347: compute or store. It is not necessary to record these actions
3348: explicitly in the RTL because the machine description includes a
3349: prescription for recognizing the instructions that do so (by means of
3350: the macro @code{NOTICE_UPDATE_CC}). Only instructions whose sole
3351: purpose is to set the condition code, and instructions that use the
3352: condition code, need mention @code{(cc0)}.
1.1 root 3353:
3354: @item (pc)
3355: This represents the machine's program counter. It has no operands and
3356: may not have a machine mode. @code{(pc)} may be validly used only in
3357: certain specific contexts in jump instructions.
3358:
1.1.1.2 root 3359: There is only one expression object of code @samp{pc}; it is the value
3360: of the variable @code{pc_rtx}. Any attempt to create an expression of
3361: code @samp{pc} will return @code{pc_rtx}.
1.1 root 3362:
1.1.1.2 root 3363: All instructions that do not jump alter the program counter implicitly
3364: by incrementing it, but there is no need to mention this in the RTL.
1.1 root 3365:
3366: @item (mem:@var{m} @var{addr})
1.1.1.2 root 3367: This RTX represents a reference to main memory at an address
3368: represented by the expression @var{addr}. @var{m} specifies how large
3369: a unit of memory is accessed.
1.1 root 3370: @end table
3371:
3372: @node Arithmetic, Comparisons, Regs and Memory, RTL
3373: @section RTL Expressions for Arithmetic
3374:
3375: @table @code
3376: @item (plus:@var{m} @var{x} @var{y})
3377: Represents the sum of the values represented by @var{x} and @var{y}
3378: carried out in machine mode @var{m}. This is valid only if
3379: @var{x} and @var{y} both are valid for mode @var{m}.
3380:
3381: @item (minus:@var{m} @var{x} @var{y})
3382: Like @samp{plus} but represents subtraction.
3383:
3384: @item (minus @var{x} @var{y})
3385: Represents the result of subtracting @var{y} from @var{x}
3386: for purposes of comparison. The absence of a machine mode
3387: in the @samp{minus} expression indicates that the result is
3388: computed without overflow, as if with infinite precision.
3389:
3390: Of course, machines can't really subtract with infinite precision.
3391: However, they can pretend to do so when only the sign of the
3392: result will be used, which is the case when the result is stored
1.1.1.2 root 3393: in @code{(cc0)}. And that is the only way this kind of expression
1.1 root 3394: may validly be used: as a value to be stored in the condition codes.
3395:
3396: @item (neg:@var{m} @var{x})
3397: Represents the negation (subtraction from zero) of the value
3398: represented by @var{x}, carried out in mode @var{m}. @var{x} must be
3399: valid for mode @var{m}.
3400:
3401: @item (mult:@var{m} @var{x} @var{y})
3402: Represents the signed product of the values represented by @var{x} and
3403: @var{y} carried out in machine mode @var{m}. If
3404: @var{x} and @var{y} are both valid for mode @var{m}, this is ordinary
1.1.1.2 root 3405: size-preserving multiplication. Alternatively, both @var{x} and @var{y}
1.1 root 3406: may be valid for a different, narrower mode. This represents the
3407: kind of multiplication that generates a product wider than the operands.
3408: Widening multiplication and same-size multiplication are completely
3409: distinct and supported by different machine instructions; machines may
1.1.1.2 root 3410: support one but not the other.@refill
1.1 root 3411:
3412: @samp{mult} may be used for floating point division as well.
3413: Then @var{m} is a floating point machine mode.
3414:
3415: @item (umult:@var{m} @var{x} @var{y})
3416: Like @samp{mult} but represents unsigned multiplication. It may be
3417: used in both same-size and widening forms, like @samp{mult}.
1.1.1.2 root 3418: @samp{umult} is used only for fixed-point multiplication.
1.1 root 3419:
3420: @item (div:@var{m} @var{x} @var{y})
3421: Represents the quotient in signed division of @var{x} by @var{y},
3422: carried out in machine mode @var{m}. If @var{m} is a floating-point
3423: mode, it represents the exact quotient; otherwise, the integerized
3424: quotient. If @var{x} and @var{y} are both valid for mode @var{m},
3425: this is ordinary size-preserving division. Some machines have
3426: division instructions in which the operands and quotient widths are
3427: not all the same; such instructions are represented by @samp{div}
3428: expressions in which the machine modes are not all the same.
3429:
3430: @item (udiv:@var{m} @var{x} @var{y})
3431: Like @samp{div} but represents unsigned division.
3432:
3433: @item (mod:@var{m} @var{x} @var{y})
3434: @itemx (umod:@var{m} @var{x} @var{y})
3435: Like @samp{div} and @samp{udiv} but represent the remainder instead of
3436: the quotient.
3437:
3438: @item (not:@var{m} @var{x})
3439: Represents the bitwise complement of the value represented by @var{x},
3440: carried out in mode @var{m}, which must be a fixed-point machine mode.
3441: @var{x} must be valid for mode @var{m}, which must be a fixed-point mode.
3442:
3443: @item (and:@var{m} @var{x} @var{y})
3444: Represents the bitwise logical-and of the values represented by
3445: @var{x} and @var{y}, carried out in machine mode @var{m}. This is
3446: valid only if @var{x} and @var{y} both are valid for mode @var{m},
3447: which must be a fixed-point mode.
3448:
3449: @item (ior:@var{m} @var{x} @var{y})
3450: Represents the bitwise inclusive-or of the values represented by
3451: @var{x} and @var{y}, carried out in machine mode @var{m}. This is
3452: valid only if @var{x} and @var{y} both are valid for mode @var{m},
3453: which must be a fixed-point mode.
3454:
3455: @item (xor:@var{m} @var{x} @var{y})
3456: Represents the bitwise exclusive-or of the values represented by
3457: @var{x} and @var{y}, carried out in machine mode @var{m}. This is
3458: valid only if @var{x} and @var{y} both are valid for mode @var{m},
3459: which must be a fixed-point mode.
3460:
3461: @item (lshift:@var{m} @var{x} @var{c})
3462: Represents the result of logically shifting @var{x} left by @var{c}
3463: places. @var{x} must be valid for the mode @var{m}, a fixed-point
3464: machine mode. @var{c} must be valid for a fixed-point mode;
3465: which mode is determined by the mode called for in the machine
3466: description entry for the left-shift instruction. For example,
3467: on the Vax, the mode of @var{c} is @code{QImode} regardless of @var{m}.
3468:
3469: On some machines, negative values of @var{c} may be meaningful; this
1.1.1.2 root 3470: is why logical left shift and arithmetic left shift are distinguished.
1.1 root 3471: For example, Vaxes have no right-shift instructions, and right shifts
3472: are represented as left-shift instructions whose counts happen
3473: to be negative constants or else computed (in a previous instruction)
3474: by negation.
3475:
3476: @item (ashift:@var{m} @var{x} @var{c})
3477: Like @samp{lshift} but for arithmetic left shift.
3478:
3479: @item (lshiftrt:@var{m} @var{x} @var{c})
3480: @itemx (ashiftrt:@var{m} @var{x} @var{c})
3481: Like @samp{lshift} and @samp{ashift} but for right shift.
3482:
3483: @item (rotate:@var{m} @var{x} @var{c})
3484: @itemx (rotatert:@var{m} @var{x} @var{c})
3485: Similar but represent left and right rotate.
3486:
3487: @item (abs:@var{m} @var{x})
3488: Represents the absolute value of @var{x}, computed in mode @var{m}.
3489: @var{x} must be valid for @var{m}.
3490:
3491: @item (sqrt:@var{m} @var{x})
3492: Represents the square root of @var{x}, computed in mode @var{m}.
3493: @var{x} must be valid for @var{m}. Most often @var{m} will be
3494: a floating point mode.
1.1.1.2 root 3495:
3496: @item (ffs:@var{m} @var{x})
3497: Represents the one plus the index of the least significant 1-bit in
3498: @var{x}, represented as an integer of mode @var{m}. (The value is
3499: zero if @var{x} is zero.) The mode of @var{x} need not be @var{m};
3500: depending on the target machine, various mode combinations may be
3501: valid.
1.1 root 3502: @end table
3503:
3504: @node Comparisons, Bit Fields, Arithmetic, RTL
3505: @section Comparison Operations
3506:
3507: Comparison operators test a relation on two operands and are considered to
3508: represent the value 1 if the relation holds, or zero if it does not. The
3509: mode of the comparison is determined by the operands; they must both be
3510: valid for a common machine mode. A comparison with both operands constant
3511: would be invalid as the machine mode could not be deduced from it, but such
1.1.1.2 root 3512: a comparison should never exist in RTL due to constant folding.
1.1 root 3513:
3514: Inequality comparisons come in two flavors, signed and unsigned. Thus,
1.1.1.2 root 3515: there are distinct expression codes @samp{gt} and @samp{gtu} for signed and
1.1 root 3516: unsigned greater-than. These can produce different results for the same
3517: pair of integer values: for example, 1 is signed greater-than -1 but not
3518: unsigned greater-than, because -1 when regarded as unsigned is actually
1.1.1.2 root 3519: @code{0xffffffff} which is greater than 1.
1.1 root 3520:
3521: The signed comparisons are also used for floating point values. Floating
3522: point comparisons are distinguished by the machine modes of the operands.
3523:
3524: The comparison operators may be used to compare the condition codes
1.1.1.2 root 3525: @code{(cc0)} against zero, as in @code{(eq (cc0) (const_int 0))}. Such a
3526: construct actually refers to the result of the preceding instruction in
3527: which the condition codes were set. The above example stands for 1 if the
3528: condition codes were set to say ``zero'' or ``equal'', 0 otherwise.
3529: Although the same comparison operators are used for this as may be used in
3530: other contexts on actual data, no confusion can result since the machine
3531: description would never allow both kinds of uses in the same context.
1.1 root 3532:
3533: @table @code
3534: @item (eq @var{x} @var{y})
3535: 1 if the values represented by @var{x} and @var{y} are equal,
3536: otherwise 0.
3537:
3538: @item (ne @var{x} @var{y})
3539: 1 if the values represented by @var{x} and @var{y} are not equal,
3540: otherwise 0.
3541:
3542: @item (gt @var{x} @var{y})
3543: 1 if the @var{x} is greater than @var{y}. If they are fixed-point,
3544: the comparison is done in a signed sense.
3545:
3546: @item (gtu @var{x} @var{y})
3547: Like @samp{gt} but does unsigned comparison, on fixed-point numbers only.
3548:
3549: @item (lt @var{x} @var{y})
3550: @item (ltu @var{x} @var{y})
3551: Like @samp{gt} and @samp{gtu} but test for ``less than''.
3552:
3553: @item (ge @var{x} @var{y})
3554: @item (geu @var{x} @var{y})
3555: Like @samp{gt} and @samp{gtu} but test for ``greater than or equal''.
3556:
3557: @item (le @var{x} @var{y})
3558: @item (leu @var{x} @var{y})
3559: Like @samp{gt} and @samp{gtu} but test for ``less than or equal''.
3560:
3561: @item (if_then_else @var{cond} @var{then} @var{else})
3562: This is not a comparison operation but is listed here because it is
3563: always used in conjunction with a comparison operation. To be
3564: precise, @var{cond} is a comparison expression. This expression
3565: represents a choice, according to @var{cond}, between the value
3566: represented by @var{then} and the one represented by @var{else}.
3567:
3568: On most machines, @samp{if_then_else} expressions are valid only
3569: to express conditional jumps.
3570: @end table
3571:
3572: @node Bit Fields, Conversions, Comparisons, RTL
3573: @section Bit-fields
3574:
3575: Special expression codes exist to represent bit-field instructions.
1.1.1.2 root 3576: These types of expressions are lvalues in RTL; they may appear
1.1 root 3577: on the left side of a assignment, indicating insertion of a value
3578: into the specified bit field.
3579:
3580: @table @code
3581: @item (sign_extract:SI @var{loc} @var{size} @var{pos})
3582: This represents a reference to a sign-extended bit-field contained or
3583: starting in @var{loc} (a memory or register reference). The bit field
3584: is @var{size} bits wide and starts at bit @var{pos}. The compilation
1.1.1.2 root 3585: option @code{BITS_BIG_ENDIAN} says which end of the memory unit
1.1 root 3586: @var{pos} counts from.
3587:
3588: Which machine modes are valid for @var{loc} depends on the machine,
3589: but typically @var{loc} should be a single byte when in memory
3590: or a full word in a register.
3591:
1.1.1.2 root 3592: @item (zero_extract:SI @var{loc} @var{size} @var{pos})
1.1 root 3593: Like @samp{sign_extract} but refers to an unsigned or zero-extended
3594: bit field. The same sequence of bits are extracted, but they
3595: are filled to an entire word with zeros instead of by sign-extension.
3596: @end table
3597:
3598: @node Conversions, RTL Declarations, Bit Fields, RTL
3599: @section Conversions
3600:
3601: All conversions between machine modes must be represented by
3602: explicit conversion operations. For example, an expression
1.1.1.2 root 3603: which is the sum of a byte and a full word cannot be written as
1.1 root 3604: @code{(plus:SI (reg:QI 34) (reg:SI 80))} because the @samp{plus}
3605: operation requires two operands of the same machine mode.
3606: Therefore, the byte-sized operand is enclosed in a conversion
3607: operation, as in
3608:
3609: @example
3610: (plus:SI (sign_extend:SI (reg:QI 34)) (reg:SI 80))
3611: @end example
3612:
3613: The conversion operation is not a mere placeholder, because there
3614: may be more than one way of converting from a given starting mode
3615: to the desired final mode. The conversion operation code says how
3616: to do it.
3617:
3618: @table @code
3619: @item (sign_extend:@var{m} @var{x})
3620: Represents the result of sign-extending the value @var{x}
3621: to machine mode @var{m}. @var{m} must be a fixed-point mode
3622: and @var{x} a fixed-point value of a mode narrower than @var{m}.
3623:
3624: @item (zero_extend:@var{m} @var{x})
3625: Represents the result of zero-extending the value @var{x}
3626: to machine mode @var{m}. @var{m} must be a fixed-point mode
3627: and @var{x} a fixed-point value of a mode narrower than @var{m}.
3628:
3629: @item (float_extend:@var{m} @var{x})
3630: Represents the result of extending the value @var{x}
3631: to machine mode @var{m}. @var{m} must be a floating point mode
3632: and @var{x} a floating point value of a mode narrower than @var{m}.
3633:
3634: @item (truncate:@var{m} @var{x})
3635: Represents the result of truncating the value @var{x}
3636: to machine mode @var{m}. @var{m} must be a fixed-point mode
3637: and @var{x} a fixed-point value of a mode wider than @var{m}.
3638:
3639: @item (float_truncate:@var{m} @var{x})
3640: Represents the result of truncating the value @var{x}
3641: to machine mode @var{m}. @var{m} must be a floating point mode
3642: and @var{x} a floating point value of a mode wider than @var{m}.
3643:
3644: @item (float:@var{m} @var{x})
1.1.1.2 root 3645: Represents the result of converting fixed point value @var{x},
3646: regarded as signed, to floating point mode @var{m}.
3647:
3648: @item (unsigned_float:@var{m} @var{x})
3649: Represents the result of converting fixed point value @var{x},
3650: regarded as unsigned, to floating point mode @var{m}.
1.1 root 3651:
3652: @item (fix:@var{m} @var{x})
1.1.1.2 root 3653: When @var{m} is a fixed point mode, represents the result of
3654: converting floating point value @var{x} to mode @var{m}, regarded as
3655: signed. How rounding is done is not specified, so this operation may
3656: be used validly in compiling C code only for integer-valued operands.
3657:
3658: @item (unsigned_fix:@var{m} @var{x})
3659: Represents the result of converting floating point value @var{x} to
3660: fixed point mode @var{m}, regarded as unsigned. How rounding is done
3661: is not specified.
1.1 root 3662:
1.1.1.2 root 3663: @item (fix:@var{m} @var{x})
3664: When @var{m} is a floating point mode, represents the result of
3665: converting floating point value @var{x} (valid for mode @var{m}) to an
3666: integer, still represented in floating point mode @var{m}, by rounding
3667: towards zero.
1.1 root 3668: @end table
3669:
3670: @node RTL Declarations, Side Effects, Conversions, RTL
3671: @section Declarations
3672:
3673: Declaration expression codes do not represent arithmetic operations
3674: but rather state assertions about their operands.
3675:
3676: @table @code
3677: @item (strict_low_part (subreg:@var{m} (reg:@var{n} @var{r}) 0))
3678: This expression code is used in only one context: operand 0 of a
3679: @samp{set} expression. In addition, the operand of this expression
3680: must be a @samp{subreg} expression.
3681:
3682: The presence of @samp{strict_low_part} says that the part of the
1.1.1.2 root 3683: register which is meaningful in mode @var{n}, but is not part of
3684: mode @var{m}, is not to be altered. Normally, an assignment to such
1.1 root 3685: a subreg is allowed to have undefined effects on the rest of the
3686: register when @var{m} is less than a word.
3687: @end table
3688:
3689: @node Side Effects, Incdec, RTL Declarations, RTL
3690: @section Side Effect Expressions
3691:
3692: The expression codes described so far represent values, not actions.
3693: But machine instructions never produce values; they are meaningful
3694: only for their side effects on the state of the machine. Special
3695: expression codes are used to represent side effects.
3696:
3697: The body of an instruction is always one of these side effect codes;
3698: the codes described above, which represent values, appear only as
3699: the operands of these.
3700:
3701: @table @code
3702: @item (set @var{lval} @var{x})
3703: Represents the action of storing the value of @var{x} into the place
3704: represented by @var{lval}. @var{lval} must be an expression
3705: representing a place that can be stored in: @samp{reg} (or
3706: @samp{subreg} or @samp{strict_low_part}), @samp{mem}, @samp{pc} or
1.1.1.2 root 3707: @samp{cc0}.@refill
1.1 root 3708:
3709: If @var{lval} is a @samp{reg}, @samp{subreg} or @samp{mem}, it has a
1.1.1.2 root 3710: machine mode; then @var{x} must be valid for that mode.@refill
1.1 root 3711:
3712: If @var{lval} is a @samp{reg} whose machine mode is less than the full
3713: width of the register, then it means that the part of the register
3714: specified by the machine mode is given the specified value and the
3715: rest of the register receives an undefined value. Likewise, if
3716: @var{lval} is a @samp{subreg} whose machine mode is narrower than
3717: @code{SImode}, the rest of the register can be changed in an undefined way.
3718:
3719: If @var{lval} is a @samp{strict_low_part} of a @samp{subreg}, then the
3720: part of the register specified by the machine mode of the
3721: @samp{subreg} is given the value @var{x} and the rest of the register
1.1.1.2 root 3722: is not changed.@refill
1.1 root 3723:
3724: If @var{lval} is @code{(cc0)}, it has no machine mode, and @var{x} may
1.1.1.2 root 3725: have any mode. This represents a ``test'' or ``compare'' instruction.@refill
1.1 root 3726:
3727: If @var{lval} is @code{(pc)}, we have a jump instruction, and the
3728: possibilities for @var{x} are very limited. It may be a
3729: @samp{label_ref} expression (unconditional jump). It may be an
3730: @samp{if_then_else} (conditional jump), in which case either the
3731: second or the third operand must be @code{(pc)} (for the case which
3732: does not jump) and the other of the two must be a @samp{label_ref}
3733: (for the case which does jump). @var{x} may also be a @samp{mem} or
3734: @code{(plus:SI (pc) @var{y})}, where @var{y} may be a @samp{reg} or a
3735: @samp{mem}; these unusual patterns are used to represent jumps through
1.1.1.2 root 3736: branch tables.@refill
1.1 root 3737:
3738: @item (return)
1.1.1.2 root 3739: Represents a return from the current function, on machines where this
3740: can be done with one instruction, such as Vaxes. On machines where a
3741: multi-instruction ``epilogue'' must be executed in order to return
3742: from the function, returning is done by jumping to a label which
3743: precedes the epilogue, and the @samp{return} expression code is never
3744: used.
1.1 root 3745:
3746: @item (call @var{function} @var{nargs})
3747: Represents a function call. @var{function} is a @samp{mem} expression
1.1.1.8 root 3748: whose address is the address of the function to be called.
3749: @var{nargs} is an expression which can be used for two purposes: on
3750: some machines it represents the number of bytes of stack argument; on
3751: others, it represents the number of argument registers.
1.1 root 3752:
3753: Each machine has a standard machine mode which @var{function} must
1.1.1.2 root 3754: have. The machine description defines macro @code{FUNCTION_MODE} to
1.1 root 3755: expand into the requisite mode name. The purpose of this mode is to
3756: specify what kind of addressing is allowed, on machines where the
3757: allowed kinds of addressing depend on the machine mode being
3758: addressed.
3759:
3760: @item (clobber @var{x})
3761: Represents the storing or possible storing of an unpredictable,
3762: undescribed value into @var{x}, which must be a @samp{reg} or
3763: @samp{mem} expression.
3764:
3765: One place this is used is in string instructions that store standard
3766: values into particular hard registers. It may not be worth the
1.1.1.2 root 3767: trouble to describe the values that are stored, but it is essential to
3768: inform the compiler that the registers will be altered, lest it
1.1 root 3769: attempt to keep data in them across the string instruction.
3770:
3771: @var{x} may also be null---a null C pointer, no expression at all.
3772: Such a @code{(clobber (null))} expression means that all memory
3773: locations must be presumed clobbered.
3774:
3775: Note that the machine description classifies certain hard registers as
3776: ``call-clobbered''. All function call instructions are assumed by
3777: default to clobber these registers, so there is no need to use
3778: @samp{clobber} expressions to indicate this fact. Also, each function
3779: call is assumed to have the potential to alter any memory location.
3780:
3781: @item (use @var{x})
1.1.1.2 root 3782: Represents the use of the value of @var{x}. It indicates that the
3783: value in @var{x} at this point in the program is needed, even though
3784: it may not be apparent why this is so. Therefore, the compiler will
3785: not attempt to delete instructions whose only effect is to store a
3786: value in @var{x}. @var{x} must be a @samp{reg} expression.
1.1 root 3787:
3788: @item (parallel [@var{x0} @var{x1} @dots{}])
3789: Represents several side effects performed in parallel. The square
3790: brackets stand for a vector; the operand of @samp{parallel} is a
3791: vector of expressions. @var{x0}, @var{x1} and so on are individual
3792: side effects---expressions of code @samp{set}, @samp{call},
1.1.1.2 root 3793: @samp{return}, @samp{clobber} or @samp{use}.@refill
1.1 root 3794:
1.1.1.2 root 3795: ``In parallel'' means that first all the values used in the individual
3796: side-effects are computed, and second all the actual side-effects are
3797: performed. For example,
1.1 root 3798:
3799: @example
3800: (parallel [(set (reg:SI 1) (mem:SI (reg:SI 1)))
3801: (set (mem:SI (reg:SI 1)) (reg:SI 1))])
3802: @end example
3803:
3804: @noindent
3805: says unambiguously that the values of hard register 1 and the memory
3806: location addressed by it are interchanged. In both places where
3807: @code{(reg:SI 1)} appears as a memory address it refers to the value
1.1.1.2 root 3808: in register 1 @emph{before} the execution of the instruction.
3809:
1.1.1.8 root 3810: Peephole optimization, which takes place in the last jump-optimization
3811: pass, can produce insns whose patterns consist of a @samp{parallel}
3812: whose elements are the operands needed to output the resulting
3813: assembler code--often @samp{reg}, @samp{mem} or constant expressions.
3814: This would not be well-formed RTL at any other stage in compilation,
3815: but it is ok then because no further optimization remains to be done.
3816: However, the definition of the macro @code{NOTICE_UPDATE_CC} may need
3817: to deal with such insns.
3818:
1.1.1.2 root 3819: @item (sequence [@var{insns} @dots{}])
3820: Represents a sequence of insns. Each of the @var{insns} that appears
3821: in the vector is suitable for appearing in the chain of insns, so it
3822: must be an @samp{insn}, @samp{jump_insn}, @samp{call_insn},
3823: @samp{code_label}, @samp{barrier} or @samp{note}.
3824:
3825: A @samp{sequence} RTX never appears in an actual insn. It represents
3826: the sequence of insns that result from a @samp{define_expand}
3827: @emph{before} those insns are passed to @code{emit_insn} to insert
3828: them in the chain of insns. When actually inserted, the individual
3829: sub-insns are separated out and the @samp{sequence} is forgotten.
1.1 root 3830: @end table
3831:
1.1.1.2 root 3832: Three expression codes appear in place of a side effect, as the body of an
3833: insn, though strictly speaking they do not describe side effects as such:
1.1 root 3834:
3835: @table @code
3836: @item (asm_input @var{s})
3837: Represents literal assembler code as described by the string @var{s}.
3838:
3839: @item (addr_vec:@var{m} [@var{lr0} @var{lr1} @dots{}])
1.1.1.2 root 3840: Represents a table of jump addresses. The vector elements @var{lr0},
3841: etc., are @samp{label_ref} expressions. The mode @var{m} specifies
3842: how much space is given to each address; normally @var{m} would be
1.1 root 3843: @code{Pmode}.
3844:
3845: @item (addr_diff_vec:@var{m} @var{base} [@var{lr0} @var{lr1} @dots{}])
3846: Represents a table of jump addresses expressed as offsets from
1.1.1.2 root 3847: @var{base}. The vector elements @var{lr0}, etc., are @samp{label_ref}
3848: expressions and so is @var{base}. The mode @var{m} specifies how much
3849: space is given to each address-difference.@refill
1.1 root 3850: @end table
3851:
1.1.1.2 root 3852: @node Incdec, Assembler, Side Effects, RTL
1.1 root 3853: @section Embedded Side-Effects on Addresses
3854:
3855: Four special side-effect expression codes appear as memory addresses.
3856:
3857: @table @code
3858: @item (pre_dec:@var{m} @var{x})
3859: Represents the side effect of decrementing @var{x} by a standard
3860: amount and represents also the value that @var{x} has after being
3861: decremented. @var{x} must be a @samp{reg} or @samp{mem}, but most
3862: machines allow only a @samp{reg}. @var{m} must be the machine mode
1.1.1.2 root 3863: for pointers on the machine in use. The amount @var{x} is decremented
1.1 root 3864: by is the length in bytes of the machine mode of the containing memory
3865: reference of which this expression serves as the address. Here is an
1.1.1.2 root 3866: example of its use:@refill
1.1 root 3867:
3868: @example
3869: (mem:DF (pre_dec:SI (reg:SI 39)))
3870: @end example
3871:
3872: @noindent
3873: This says to decrement pseudo register 39 by the length of a @code{DFmode}
3874: value and use the result to address a @code{DFmode} value.
3875:
3876: @item (pre_inc:@var{m} @var{x})
3877: Similar, but specifies incrementing @var{x} instead of decrementing it.
3878:
3879: @item (post_dec:@var{m} @var{x})
3880: Represents the same side effect as @samp{pre_decrement} but a different
3881: value. The value represented here is the value @var{x} has @i{before}
3882: being decremented.
3883:
3884: @item (post_inc:@var{m} @var{x})
3885: Similar, but specifies incrementing @var{x} instead of decrementing it.
3886: @end table
3887:
3888: These embedded side effect expressions must be used with care. Instruction
3889: patterns may not use them. Until the @samp{flow} pass of the compiler,
3890: they may occur only to represent pushes onto the stack. The @samp{flow}
3891: pass finds cases where registers are incremented or decremented in one
3892: instruction and used as an address shortly before or after; these cases are
3893: then transformed to use pre- or post-increment or -decrement.
3894:
3895: Explicit popping of the stack could be represented with these embedded
3896: side effect operators, but that would not be safe; the instruction
3897: combination pass could move the popping past pushes, thus changing
3898: the meaning of the code.
3899:
3900: An instruction that can be represented with an embedded side effect
3901: could also be represented using @samp{parallel} containing an additional
3902: @samp{set} to describe how the address register is altered. This is not
3903: done because machines that allow these operations at all typically
3904: allow them wherever a memory address is called for. Describing them as
3905: additional parallel stores would require doubling the number of entries
3906: in the machine description.
3907:
1.1.1.2 root 3908: @node Assembler, Insns, IncDec, RTL
3909: @section Assembler Instructions as Expressions
3910:
3911: The RTX code @samp{asm_operands} represents a value produced by a
3912: user-specified assembler instruction. It is used to represent
3913: an @code{asm} statement with arguments. An @code{asm} statement with
3914: a single output operand, like this:
3915:
3916: @example
3917: asm ("foo %1,%2,%0" : "a" (outputvar) : "g" (x + y), "di" (*z));
3918: @end example
3919:
3920: @noindent
3921: is represented using a single @samp{asm_operands} RTX which represents
3922: the value that is stored in @code{outputvar}:
3923:
3924: @example
3925: (set @var{rtx-for-outputvar}
3926: (asm_operands "foo %1,%2,%0" "a" 0
3927: [@var{rtx-for-addition-result} @var{rtx-for-*z}]
3928: [(asm_input:@var{m1} "g")
3929: (asm_input:@var{m2} "di")]))
3930: @end example
3931:
3932: @noindent
3933: Here the operands of the @samp{asm_operands} RTX are the assembler
3934: template string, the output-operand's constraint, the index-number of the
3935: output operand among the output operands specified, a vector of input
3936: operand RTX's, and a vector of input-operand modes and constraints. The
3937: mode @var{m1} is the mode of the sum @code{x+y}; @var{m2} is that of
3938: @code{*z}.
3939:
3940: When an @code{asm} statement has multiple output values, its insn has
3941: several such @samp{set} RTX's inside of a @samp{parallel}. Each @samp{set}
3942: contains a @samp{asm_operands}; all of these share the same assembler
3943: template and vectors, but each contains the constraint for the respective
3944: output operand. They are also distinguished by the output-operand index
3945: number, which is 0, 1, @dots{} for successive output operands.
3946:
3947: @node Insns, Calls, Assembler, RTL
1.1 root 3948: @section Insns
3949:
3950: The RTL representation of the code for a function is a doubly-linked
3951: chain of objects called @dfn{insns}. Insns are expressions with
3952: special codes that are used for no other purpose. Some insns are
3953: actual instructions; others represent dispatch tables for @code{switch}
3954: statements; others represent labels to jump to or various sorts of
1.1.1.2 root 3955: declarative information.
1.1 root 3956:
1.1.1.2 root 3957: In addition to its own specific data, each insn must have a unique id-number
1.1 root 3958: that distinguishes it from all other insns in the current function, and
3959: chain pointers to the preceding and following insns. These three fields
3960: occupy the same position in every insn, independent of the expression code
3961: of the insn. They could be accessed with @code{XEXP} and @code{XINT},
3962: but instead three special macros are always used:
3963:
3964: @table @code
3965: @item INSN_UID (@var{i})
3966: Accesses the unique id of insn @var{i}.
3967:
3968: @item PREV_INSN (@var{i})
3969: Accesses the chain pointer to the insn preceding @var{i}.
3970: If @var{i} is the first insn, this is a null pointer.
3971:
3972: @item NEXT_INSN (@var{i})
3973: Accesses the chain pointer to the insn following @var{i}.
3974: If @var{i} is the last insn, this is a null pointer.
3975: @end table
3976:
3977: The @code{NEXT_INSN} and @code{PREV_INSN} pointers must always
3978: correspond: if @var{i} is not the first insn,
3979:
3980: @example
3981: NEXT_INSN (PREV_INSN (@var{insn})) == @var{insn}
3982: @end example
3983:
3984: @noindent
3985: is always true.
3986:
3987: Every insn has one of the following six expression codes:
3988:
1.1.1.2 root 3989: @table @samp
1.1 root 3990: @item insn
3991: The expression code @samp{insn} is used for instructions that do not jump
3992: and do not do function calls. Insns with code @samp{insn} have four
3993: additional fields beyond the three mandatory ones listed above.
3994: These four are described in a table below.
3995:
3996: @item jump_insn
3997: The expression code @samp{jump_insn} is used for instructions that may jump
3998: (or, more generally, may contain @samp{label_ref} expressions).
3999: @samp{jump_insn} insns have the same extra fields as @samp{insn} insns,
4000: accessed in the same way.
4001:
4002: @item call_insn
4003: The expression code @samp{call_insn} is used for instructions that may do
4004: function calls. It is important to distinguish these instructions because
4005: they imply that certain registers and memory locations may be altered
4006: unpredictably.
4007:
4008: @samp{call_insn} insns have the same extra fields as @samp{insn} insns,
4009: accessed in the same way.
4010:
4011: @item code_label
4012: A @samp{code_label} insn represents a label that a jump insn can jump to.
4013: It contains one special field of data in addition to the three standard ones.
4014: It is used to hold the @dfn{label number}, a number that identifies this
4015: label uniquely among all the labels in the compilation (not just in the
4016: current function). Ultimately, the label is represented in the assembler
4017: output as an assembler label @samp{L@var{n}} where @var{n} is the label number.
4018:
4019: @item barrier
4020: Barriers are placed in the instruction stream after unconditional
4021: jump instructions to indicate that the jumps are unconditional.
4022: They contain no information beyond the three standard fields.
4023:
4024: @item note
4025: @samp{note} insns are used to represent additional debugging and
1.1.1.2 root 4026: declarative information. They contain two nonstandard fields, an
1.1 root 4027: integer which is accessed with the macro @code{NOTE_LINE_NUMBER} and a
4028: string accessed with @code{NOTE_SOURCE_FILE}.
4029:
4030: If @code{NOTE_LINE_NUMBER} is positive, the note represents the
4031: position of a source line and @code{NOTE_SOURCE_FILE} is the source file name
4032: that the line came from. These notes control generation of line
4033: number data in the assembler output.
4034:
4035: Otherwise, @code{NOTE_LINE_NUMBER} is not really a line number but a
4036: code with one of the following values (and @code{NOTE_SOURCE_FILE}
4037: must contain a null pointer):
4038:
4039: @table @code
4040: @item NOTE_INSN_DELETED
4041: Such a note is completely ignorable. Some passes of the compiler
4042: delete insns by altering them into notes of this kind.
4043:
4044: @item NOTE_INSN_BLOCK_BEG
4045: @itemx NOTE_INSN_BLOCK_END
4046: These types of notes indicate the position of the beginning and end
4047: of a level of scoping of variable names. They control the output
4048: of debugging information.
4049:
4050: @item NOTE_INSN_LOOP_BEG
4051: @itemx NOTE_INSN_LOOP_END
4052: These types of notes indicate the position of the beginning and end
4053: of a @code{while} or @code{for} loop. They enable the loop optimizer
4054: to find loops quickly.
4055: @end table
4056: @end table
4057:
4058: Here is a table of the extra fields of @samp{insn}, @samp{jump_insn}
4059: and @samp{call_insn} insns:
4060:
4061: @table @code
4062: @item PATTERN (@var{i})
4063: An expression for the side effect performed by this insn.
4064:
4065: @item REG_NOTES (@var{i})
4066: A list (chain of @samp{expr_list} expressions) giving information
4067: about the usage of registers in this insn. This list is set up by the
1.1.1.2 root 4068: flow analysis pass; it is a null pointer until then.
1.1 root 4069:
4070: @item LOG_LINKS (@var{i})
4071: A list (chain of @samp{insn_list} expressions) of previous ``related''
4072: insns: insns which store into registers values that are used for the
4073: first time in this insn. (An additional constraint is that neither a
4074: jump nor a label may come between the related insns). This list is
1.1.1.2 root 4075: set up by the flow analysis pass; it is a null pointer until then.
1.1 root 4076:
4077: @item INSN_CODE (@var{i})
4078: An integer that says which pattern in the machine description matches
4079: this insn, or -1 if the matching has not yet been attempted.
4080:
4081: Such matching is never attempted and this field is not used on an insn
4082: whose pattern consists of a single @samp{use}, @samp{clobber},
4083: @samp{asm}, @samp{addr_vec} or @samp{addr_diff_vec} expression.
4084: @end table
4085:
4086: The @code{LOG_LINKS} field of an insn is a chain of @samp{insn_list}
4087: expressions. Each of these has two operands: the first is an insn,
4088: and the second is another @samp{insn_list} expression (the next one in
4089: the chain). The last @samp{insn_list} in the chain has a null pointer
4090: as second operand. The significant thing about the chain is which
1.1.1.2 root 4091: insns appear in it (as first operands of @samp{insn_list}
1.1 root 4092: expressions). Their order is not significant.
4093:
4094: The @code{REG_NOTES} field of an insn is a similar chain but of
1.1.1.2 root 4095: @samp{expr_list} expressions instead of @samp{insn_list}. There are four
4096: kinds of register notes, which are distinguished by the machine mode of the
4097: @samp{expr_list}, which a register note is really understood as being an
4098: @code{enum reg_note}. The first operand @var{op} of the @samp{expr_list}
4099: is data whose meaning depends on the kind of note. Here are the four
4100: kinds:
1.1 root 4101:
4102: @table @code
4103: @item REG_DEAD
1.1.1.2 root 4104: The register @var{op} dies in this insn; that is to say, altering the
4105: value immediately after this insn would not affect the future behavior
4106: of the program.
1.1 root 4107:
4108: @item REG_INC
1.1.1.2 root 4109: The register @var{op} is incremented (or decremented; at this level
1.1 root 4110: there is no distinction) by an embedded side effect inside this insn.
1.1.1.2 root 4111: This means it appears in a @code{POST_INC}, @code{PRE_INC},
4112: @code{POST_DEC} or @code{PRE_DEC} RTX.
1.1 root 4113:
1.1.1.2 root 4114: @item REG_EQUIV
4115: The register that is set by this insn will be equal to @var{op} at run
4116: time, and could validly be replaced in all its occurrences by
4117: @var{op}. (``Validly'' here refers to the data flow of the program;
4118: simple replacement may make some insns invalid.)
4119:
4120: The value which the insn explicitly copies into the register may look
4121: different from @var{op}, but they will be equal at run time.
4122:
4123: For example, when a constant is loaded into a register that is never
4124: assigned any other value, this kind of note is used.
4125:
4126: When a parameter is copied into a pseudo-register at entry to a function,
4127: a note of this kind records that the register is equivalent to the stack
4128: slot where the parameter was passed. Although in this case the register
4129: may be set by other insns, it is still valid to replace the register
4130: by the stack slot throughout the function.
4131:
4132: @item REG_EQUAL
4133: The register that is set by this insn will be equal to @var{op} at run
4134: time at the end of this insn (but not necessarily elsewhere in the
4135: function).
4136:
4137: The RTX @var{op} is typically an arithmetic expression. For example,
4138: when a sequence of insns such as a library call is used to perform an
4139: arithmetic operation, this kind of note is attached to the insn that
4140: produces or copies the final value. It tells the CSE pass how to
4141: think of that value.
4142:
4143: @item REG_RETVAL
4144: This insn copies the value of a library call, and @var{op} is the
4145: first insn that was generated to set up the arguments for the library
4146: call.
4147:
4148: Flow analysis uses this note to delete all of a library call whose
4149: result is dead.
1.1 root 4150:
4151: @item REG_WAS_0
1.1.1.2 root 4152: The register @var{op} contained zero before this insn. You can rely
1.1 root 4153: on this note if it is present; its absence implies nothing.
4154: @end table
4155:
4156: (The only difference between the expression codes @samp{insn_list} and
4157: @samp{expr_list} is that the first operand of an @samp{insn_list} is
4158: assumed to be an insn and is printed in debugging dumps as the insn's
4159: unique id; the first operand of an @samp{expr_list} is printed in the
4160: ordinary way as an expression.)
4161:
1.1.1.2 root 4162: @node Calls, Sharing, Insns, RTL
4163: @section RTL Representation of Function-Call Insns
4164:
4165: Insns that call subroutines have the RTL expression code @samp{call_insn}.
4166: These insns must satisfy special rules, and their bodies must use a special
4167: RTL expression code, @samp{call}.
4168:
4169: A @samp{call} expression has two operands, as follows:
4170:
4171: @example
4172: (call @var{nbytes} (mem:@var{fm} @var{addr}))
4173: @end example
4174:
4175: @noindent
4176: Here @var{nbytes} is an operand that represents the number of bytes of
4177: argument data being passed to the subroutine, @var{fm} is a machine mode
4178: (which must equal as the definition of the @code{FUNCTION_MODE} macro in
4179: the machine description) and @var{addr} represents the address of the
4180: subroutine.
4181:
4182: For a subroutine that returns no value, the @samp{call} RTX as shown above
4183: is the entire body of the insn.
4184:
4185: For a subroutine that returns a value whose mode is not @code{BLKmode},
4186: the value is returned in a hard register. If this register's number is
4187: @var{r}, then the body of the call insn looks like this:
4188:
4189: @example
4190: (set (reg:@var{m} @var{r})
4191: (call @var{nbytes} (mem:@var{fm} @var{addr})))
4192: @end example
4193:
4194: @noindent
4195: This RTL expression makes it clear (to the optimizer passes) that the
4196: appropriate register receives a useful value in this insn.
4197:
4198: Immediately after RTL generation, if the value of the subroutine is
4199: actually used, this call insn is always followed closely by an insn which
1.1.1.3 root 4200: refers to the register @var{r}. This remains true through all the
4201: optimizer passes until cross jumping occurs.
4202:
4203: The following insn has one of two forms. Either it copies the value into a
4204: pseudo-register, like this:
1.1.1.2 root 4205:
4206: @example
4207: (set (reg:@var{m} @var{p}) (reg:@var{m} @var{r}))
4208: @end example
4209:
4210: @noindent
4211: or (in the case where the calling function will simply return whatever
4212: value the call produced, and no operation is needed to do this):
4213:
4214: @example
4215: (use (reg:@var{m} @var{r}))
4216: @end example
4217:
4218: @noindent
1.1.1.3 root 4219: Between the call insn and this following insn there may intervene only a
1.1.1.2 root 4220: stack-adjustment insn (and perhaps some @samp{note} insns).
4221:
4222: When a subroutine returns a @code{BLKmode} value, it is handled by
4223: passing to the subroutine the address of a place to store the value.
4224: So the call insn itself does not ``return'' any value, and it has the
4225: same RTL form as a call that returns nothing.
4226:
4227: @node Sharing,, Calls, RTL
1.1 root 4228: @section Structure Sharing Assumptions
4229:
4230: The compiler assumes that certain kinds of RTL expressions are unique;
4231: there do not exist two distinct objects representing the same value.
4232: In other cases, it makes an opposite assumption: that no RTL expression
4233: object of a certain kind appears in more than one place in the
4234: containing structure.
4235:
4236: These assumptions refer to a single function; except for the RTL
4237: objects that describe global variables and external functions,
4238: no RTL objects are common to two functions.
4239:
4240: @itemize @bullet
4241: @item
4242: Each pseudo-register has only a single @samp{reg} object to represent it,
4243: and therefore only a single machine mode.
4244:
4245: @item
4246: For any symbolic label, there is only one @samp{symbol_ref} object
4247: referring to it.
4248:
4249: @item
4250: There is only one @samp{const_int} expression with value zero,
4251: and only one with value one.
4252:
4253: @item
4254: There is only one @samp{pc} expression.
4255:
4256: @item
4257: There is only one @samp{cc0} expression.
4258:
4259: @item
4260: There is only one @samp{const_double} expression with mode
4261: @code{SFmode} and value zero, and only one with mode @code{DFmode} and
4262: value zero.
4263:
4264: @item
1.1.1.2 root 4265: No @samp{label_ref} appears in more than one place in the RTL
4266: structure; in other words, it is safe to do a tree-walk of all the
4267: insns in the function and assume that each time a @samp{label_ref} is
4268: seen it is distinct from all others that are seen.
1.1 root 4269:
4270: @item
1.1.1.2 root 4271: Only one @samp{mem} object is normally created for each static
4272: variable or stack slot, so these objects are frequently shared in all
4273: the places they appear. However, separate but equal objects for these
4274: variables are occasionally made.
4275:
4276: @item
4277: No RTL object appears in more than one place in the RTL structure
4278: except as described above. Many passes of the compiler rely on this
4279: by assuming that they can modify RTL objects in place without unwanted
4280: side-effects on other insns.
4281:
4282: @item
4283: During initial RTL generation, shared structure is freely introduced.
4284: After all the RTL for a function has been generated, all shared
4285: structure is copied by @code{unshare_all_rtl} in @file{emit-rtl.c},
4286: after which the above rules are guaranteed to be followed.
4287:
4288: @item
4289: During the combiner pass, shared structure with an insn can exist
4290: temporarily. However, the shared structure is copied before the
4291: combiner is finished with the insn. This is done by
4292: @code{copy_substitutions} in @samp{combine.c}.
1.1 root 4293: @end itemize
4294:
4295: @node Machine Desc, Machine Macros, RTL, Top
4296: @chapter Machine Descriptions
4297:
4298: A machine description has two parts: a file of instruction patterns
4299: (@file{.md} file) and a C header file of macro definitions.
4300:
4301: The @file{.md} file for a target machine contains a pattern for each
4302: instruction that the target machine supports (or at least each instruction
4303: that is worth telling the compiler about). It may also contain comments.
4304: A semicolon causes the rest of the line to be a comment, unless the semicolon
4305: is inside a quoted string.
4306:
4307: See the next chapter for information on the C header file.
4308:
4309: @menu
4310: * Patterns:: How to write instruction patterns.
1.1.1.2 root 4311: * Example:: An explained example of a @samp{define_insn} pattern.
4312: * RTL Template:: The RTL template defines what insns match a pattern.
4313: * Output Template:: The output template says how to make assembler code
4314: from such an insn.
4315: * Output Statement:: For more generality, write C code to output
4316: the assembler code.
1.1 root 4317: * Constraints:: When not all operands are general operands.
4318: * Standard Names:: Names mark patterns to use for code generation.
1.1.1.2 root 4319: * Pattern Ordering:: When the order of patterns makes a difference.
1.1 root 4320: * Dependent Patterns:: Having one pattern may make you need another.
1.1.1.2 root 4321: * Jump Patterns:: Special considerations for patterns for jump insns.
4322: * Peephole Definitions::Defining machine-specific peephole optimizations.
4323: * Expander Definitions::Generating a sequence of several RTL insns
4324: for a standard operation.
1.1 root 4325: @end menu
4326:
4327: @node Patterns, Example, Machine Desc, Machine Desc
1.1.1.2 root 4328: @section Everything about Instruction Patterns
1.1 root 4329:
4330: Each instruction pattern contains an incomplete RTL expression, with pieces
4331: to be filled in later, operand constraints that restrict how the pieces can
4332: be filled in, and an output pattern or C code to generate the assembler
4333: output, all wrapped up in a @samp{define_insn} expression.
4334:
1.1.1.2 root 4335: A @samp{define_insn} is an RTL expression containing four operands:
1.1 root 4336:
4337: @enumerate
4338: @item
4339: An optional name. The presence of a name indicate that this instruction
4340: pattern can perform a certain standard job for the RTL-generation
4341: pass of the compiler. This pass knows certain names and will use
4342: the instruction patterns with those names, if the names are defined
4343: in the machine description.
4344:
4345: The absence of a name is indicated by writing an empty string
4346: where the name should go. Nameless instruction patterns are never
4347: used for generating RTL code, but they may permit several simpler insns
4348: to be combined later on.
4349:
4350: Names that are not thus known and used in RTL-generation have no
4351: effect; they are equivalent to no name at all.
4352:
4353: @item
1.1.1.2 root 4354: The @dfn{RTL template} (@pxref{RTL Template}) is a vector of
4355: incomplete RTL expressions which show what the instruction should look
4356: like. It is incomplete because it may contain @samp{match_operand}
4357: and @samp{match_dup} expressions that stand for operands of the
1.1 root 4358: instruction.
4359:
4360: If the vector has only one element, that element is what the
4361: instruction should look like. If the vector has multiple elements,
4362: then the instruction looks like a @samp{parallel} expression
4363: containing that many elements as described.
4364:
4365: @item
4366: A condition. This is a string which contains a C expression that is
4367: the final test to decide whether an insn body matches this pattern.
4368:
4369: For a named pattern, the condition (if present) may not depend on
4370: the data in the insn being matched, but only the target-machine-type
4371: flags. The compiler needs to test these conditions during
4372: initialization in order to learn exactly which named instructions are
4373: available in a particular run.
4374:
4375: For nameless patterns, the condition is applied only when matching an
4376: individual insn, and only after the insn has matched the pattern's
4377: recognition template. The insn's operands may be found in the vector
4378: @code{operands}.
4379:
4380: @item
1.1.1.2 root 4381: The @dfn{output template}: a string that says how to output matching
4382: insns as assembler code. @samp{%} in this string specifies where
4383: to substitute the value of an operand. @xref{Output Template}.
4384:
4385: When simple substitution isn't general enough, you can specify a piece
4386: of C code to compute the output. @xref{Output Statement}.
4387: @end enumerate
4388:
4389: @node Example, RTL Template, Patterns, Machine Desc
4390: @section Example of @samp{define_insn}
4391:
4392: Here is an actual example of an instruction pattern, for the 68000/68020.
4393:
4394: @example
4395: (define_insn "tstsi"
4396: [(set (cc0)
4397: (match_operand:SI 0 "general_operand" "rm"))]
4398: ""
4399: "*
4400: @{ if (TARGET_68020 || ! ADDRESS_REG_P (operands[0]))
4401: return \"tstl %0\";
4402: return \"cmpl #0,%0\"; @}")
4403: @end example
1.1 root 4404:
1.1.1.2 root 4405: This is an instruction that sets the condition codes based on the value of
4406: a general operand. It has no condition, so any insn whose RTL description
4407: has the form shown may be handled according to this pattern. The name
4408: @samp{tstsi} means ``test a @code{SImode} value'' and tells the RTL generation
4409: pass that, when it is necessary to test such a value, an insn to do so
4410: can be constructed using this pattern.
1.1 root 4411:
1.1.1.2 root 4412: The output control string is a piece of C code which chooses which
4413: output template to return based on the kind of operand and the specific
4414: type of CPU for which code is being generated.
1.1 root 4415:
1.1.1.2 root 4416: @samp{"rm"} is an operand constraint. Its meaning is explained below.
1.1 root 4417:
1.1.1.2 root 4418: @node RTL Template, Output Template, Example, Machine Desc
4419: @section RTL Template for Generating and Recognizing Insns
1.1 root 4420:
1.1.1.2 root 4421: The RTL template is used to define which insns match the particular pattern
4422: and how to find their operands. For named patterns, the RTL template also
4423: says how to construct an insn from specified operands.
4424:
4425: Construction involves substituting specified operands into a copy of the
4426: template. Matching involves determining the values that serve as the
4427: operands in the insn being matched. Both of these activities are
4428: controlled by special expression types that direct matching and
4429: substitution of the operands.
1.1 root 4430:
4431: @table @code
4432: @item (match_operand:@var{m} @var{n} @var{testfn} @var{constraint})
4433: This expression is a placeholder for operand number @var{n} of
4434: the insn. When constructing an insn, operand number @var{n}
4435: will be substituted at this point. When matching an insn, whatever
4436: appears at this position in the insn will be taken as operand
4437: number @var{n}; but it must satisfy @var{testfn} or this instruction
4438: pattern will not match at all.
4439:
4440: Operand numbers must be chosen consecutively counting from zero in
4441: each instruction pattern. There may be only one @samp{match_operand}
1.1.1.7 root 4442: expression in the pattern for each operand number. Usually operands
4443: are numbered in the order of appearance in @samp{match_operand}
4444: expressions.
1.1 root 4445:
4446: @var{testfn} is a string that is the name of a C function that accepts
4447: two arguments, a machine mode and an expression. During matching,
4448: the function will be called with @var{m} as the mode argument
4449: and the putative operand as the other argument. If it returns zero,
4450: this instruction pattern fails to match. @var{testfn} may be
4451: an empty string; then it means no test is to be done on the operand.
4452:
4453: Most often, @var{testfn} is @code{"general_operand"}. It checks
4454: that the putative operand is either a constant, a register or a
4455: memory reference, and that it is valid for mode @var{m}.
4456:
1.1.1.2 root 4457: For an operand that must be a register, @var{testfn} should be
4458: @code{"register_operand"}. This prevents GNU CC from creating insns
4459: that have memory references in these operands, insns which would only
4460: have to be taken apart in the reload pass.
4461:
4462: For an operand that must be a constant, either @var{testfn} should be
4463: @code{"immediate_operand"}, or the instruction pattern's extra condition
4464: should check for constants, or both.
4465:
4466: @var{constraint} is explained later (@pxref{Constraints}).
1.1 root 4467:
4468: @item (match_dup @var{n})
4469: This expression is also a placeholder for operand number @var{n}.
4470: It is used when the operand needs to appear more than once in the
4471: insn.
4472:
4473: In construction, @samp{match_dup} behaves exactly like
1.1.1.2 root 4474: @samp{match_operand}: the operand is substituted into the insn being
1.1 root 4475: constructed. But in matching, @samp{match_dup} behaves differently.
4476: It assumes that operand number @var{n} has already been determined by
1.1.1.2 root 4477: a @samp{match_operand} appearing earlier in the recognition template,
1.1 root 4478: and it matches only an identical-looking expression.
4479:
4480: @item (address (match_operand:@var{m} @var{n} "address_operand" ""))
4481: This complex of expressions is a placeholder for an operand number
4482: @var{n} in a ``load address'' instruction: an operand which specifies
4483: a memory location in the usual way, but for which the actual operand
4484: value used is the address of the location, not the contents of the
4485: location.
4486:
4487: @samp{address} expressions never appear in RTL code, only in machine
4488: descriptions. And they are used only in machine descriptions that do
4489: not use the operand constraint feature. When operand constraints are
4490: in use, the letter @samp{p} in the constraint serves this purpose.
4491:
4492: @var{m} is the machine mode of the @emph{memory location being
4493: addressed}, not the machine mode of the address itself. That mode is
4494: always the same on a given target machine (it is @code{Pmode}, which
4495: normally is @code{SImode}), so there is no point in mentioning it;
4496: thus, no machine mode is written in the @samp{address} expression. If
4497: some day support is added for machines in which addresses of different
4498: kinds of objects appear differently or are used differently (such as
4499: the PDP-10), different formats would perhaps need different machine
4500: modes and these modes might be written in the @samp{address}
4501: expression.
4502: @end table
4503:
1.1.1.2 root 4504: @node Output Template, Output Statement, RTL Template, Machine Desc
4505: @section Output Templates and Operand Substitution
1.1 root 4506:
1.1.1.2 root 4507: The @dfn{output template} is a string which specifies how to output
4508: the assembler code for an instruction pattern. Most of the template
4509: is a fixed string which is output literally. The character @samp{%}
4510: is used to specify where to substitute an operand; it can also be
4511: used to identify places different variants of the assembler require
4512: different syntax.
4513:
4514: In the simplest case, a @samp{%} followed by a digit @var{n} says to output
4515: operand @var{n} at that point in the string.
4516:
4517: @samp{%} followed by a letter and a digit says to output an operand in an
4518: alternate fashion. Four letters have standard, built-in meanings described
4519: below. The machine description macro @code{PRINT_OPERAND} can define
4520: additional letters with nonstandard meanings.
4521:
4522: @samp{%c@var{digit}} can be used to substitute an operand that is a
4523: constant value without the syntax that normally indicates an immediate
4524: operand.
4525:
4526: @samp{%n@var{digit}} is like @samp{%c@var{digit}} except that the value of
4527: the constant is negated before printing.
4528:
4529: @samp{%a@var{digit}} can be used to substitute an operand as if it were a
4530: memory reference, with the actual operand treated as the address. This may
4531: be useful when outputting a ``load address'' instruction, because often the
4532: assembler syntax for such an instruction requires you to write the operand
4533: as if it were a memory reference.
4534:
4535: @samp{%l@var{digit}} is used to substitute a @code{label_ref} into a jump
4536: instruction.
4537:
4538: @samp{%} followed by a punctuation character specifies a substitution that
4539: does not use an operand. Only one case is standard: @samp{%%} outputs a
4540: @samp{%} into the assembler code. Other nonstandard cases can be
4541: defined in the @code{PRINT_OPERAND} macro.
4542:
4543: The template may generate multiple assembler instructions. Write the text
4544: for the instructions, with @samp{\;} between them.
4545:
4546: When the RTL contains two operand which are required by constraint to match
4547: each other, the output template must refer only to the lower-numbered operand.
4548: Matching operands are not always identical, and the rest of the compiler
4549: arranges to put the proper RTL expression for printing into the lower-numbered
4550: operand.
4551:
4552: One use of nonstandard letters or punctuation following @samp{%} is to
4553: distinguish between different assembler languages for the same machine; for
4554: example, Motorola syntax versus MIT syntax for the 68000. Motorola syntax
4555: requires periods in most opcode names, while MIT syntax does not. For
4556: example, the opcode @samp{movel} in MIT syntax is @samp{move.l} in Motorola
4557: syntax. The same file of patterns is used for both kinds of output syntax,
4558: but the character sequence @samp{%.} is used in each place where Motorola
4559: syntax wants a period. The @code{PRINT_OPERAND} macro for Motorola syntax
4560: defines the sequence to output a period; the macro for MIT syntax defines
4561: it to do nothing.
4562:
4563: @node Output Statement, Constraints, Output Template, Machine Desc
4564: @section C Statements for Generating Assembler Output
4565:
4566: Often a single fixed template string cannot produce correct and efficient
4567: assembler code for all the cases that are recognized by a single
4568: instruction pattern. For example, the opcodes may depend on the kinds of
4569: operands; or some unfortunate combinations of operands may require extra
4570: machine instructions.
4571:
4572: If the output control string starts with a @samp{*}, then it is not an
4573: output template but rather a piece of C program that should compute a
4574: template. It should execute a @code{return} statement to return the
4575: template-string you want. Most such templates use C string literals, which
4576: require doublequote characters to delimit them. To include these
4577: doublequote characters in the string, prefix each one with @samp{\}.
4578:
4579: The operands may be found in the array @code{operands}, whose C data type
4580: is @code{rtx []}.
4581:
4582: It is possible to output an assembler instruction and then go on to output
4583: or compute more of them, using the subroutine @code{output_asm_insn}. This
4584: receives two arguments: a template-string and a vector of operands. The
4585: vector may be @code{operands}, or it may be another array of @code{rtx}
4586: that you declare locally and initialize yourself.
4587:
4588: When an insn pattern has multiple alternatives in its constraints, often
4589: the appearance of the assembler code determined mostly by which alternative
4590: was matched. When this is so, the C code can test the variable
4591: @code{which_alternative}, which is the ordinal number of the alternative
4592: that was actually satisfied (0 for the first, 1 for the second alternative,
4593: etc.).
4594:
4595: For example, suppose there are two opcodes for storing zero, @samp{clrreg}
4596: for registers and @samp{clrmem} for memory locations. Here is how
4597: a pattern could use @code{which_alternative} to choose between them:
1.1 root 4598:
4599: @example
1.1.1.2 root 4600: (define_insn ""
4601: [(set (match_operand:SI 0 "general_operand" "r,m")
4602: (const_int 0))]
1.1 root 4603: ""
4604: "*
1.1.1.2 root 4605: return (which_alternative == 0
4606: ? \"clrreg %0\" : \"clrmem %0\");
4607: ")
1.1 root 4608: @end example
4609:
1.1.1.2 root 4610: @node Constraints, Standard Names, Output Statement, Machine Desc
1.1 root 4611: @section Operand Constraints
4612:
4613: Each @samp{match_operand} in an instruction pattern can specify a
4614: constraint for the type of operands allowed. Constraints can say whether
4615: an operand may be in a register, and which kinds of register; whether the
4616: operand can be a memory reference, and which kinds of address; whether the
4617: operand may be an immediate constant, and which possible values it may
4618: have. Constraints can also require two operands to match.
4619:
4620: @menu
4621: * Simple Constraints:: Basic use of constraints.
1.1.1.2 root 4622: * Multi-Alternative:: When an insn has two alternative constraint-patterns.
1.1 root 4623: * Class Preferences:: Constraints guide which hard register to put things in.
4624: * Modifiers:: More precise control over effects of constraints.
4625: * No Constraints:: Describing a clean machine without constraints.
4626: @end menu
4627:
4628: @node Simple Constraints, Multi-Alternative, Constraints, Constraints
4629: @subsection Simple Constraints
4630:
4631: The simplest kind of constraint is a string full of letters, each of
4632: which describes one kind of operand that is permitted. Here are
4633: the letters that are allowed:
4634:
1.1.1.2 root 4635: @table @asis
4636: @item @samp{m}
1.1 root 4637: A memory operand is allowed, with any kind of address that the machine
4638: supports in general.
4639:
1.1.1.2 root 4640: @item @samp{o}
4641: A memory operand is allowed, but only if the address is
4642: @dfn{offsetable}. This means that adding a small integer (actually,
4643: the width in bytes of the operand, as determined by its machine mode)
4644: may be added to the address and the result is also a valid memory
4645: address.
4646:
4647: For example, an address which is constant is offsetable; so is an
4648: address that is the sum of a register and a constant (as long as a
4649: slightly larger constant is also within the range of address-offsets
4650: supported by the machine); but an autoincrement or autodecrement
4651: address is not offsetable. More complicated indirect/indexed
4652: addresses may or may not be offsetable depending on the other
4653: addressing modes that the machine supports.
4654:
4655: Note that in an output operand which can be matched by another
4656: operand, the constraint letter @samp{o} is valid only when accompanied
4657: by both @samp{<} (if the target machine has predecrement addressing)
4658: and @samp{>} (if the target machine has preincrement addressing).
1.1 root 4659:
1.1.1.9 ! root 4660: When the constraint letter @samp{o} is used, the reload pass may
! 4661: generate instructions which copy a nonoffsetable address into an index
! 4662: register. The idea is that the register can be used as a replacement
! 4663: offsetable address. But this method requires that there be patterns
! 4664: to copy any kind of address into a register. Auto-increment
! 4665: and auto-decrement addresses are an exception; there need not be an
! 4666: instruction that can copy such an address into a register, because
! 4667: reload handles these cases specially.
! 4668:
! 4669: Most older machine designs have ``load address'' instructions which do
! 4670: just what is needed here. Some RISC machines do not advertise such
! 4671: instructions, but the possible addresses on these machines are very
! 4672: limited, so it is easy to fake them.
! 4673:
1.1.1.2 root 4674: @item @samp{<}
1.1 root 4675: A memory operand with autodecrement addressing (either predecrement or
4676: postdecrement) is allowed.
4677:
1.1.1.2 root 4678: @item @samp{>}
1.1 root 4679: A memory operand with autoincrement addressing (either preincrement or
4680: postincrement) is allowed.
4681:
1.1.1.2 root 4682: @item @samp{r}
4683: A register operand is allowed provided that it is in a general
4684: register.
1.1 root 4685:
1.1.1.2 root 4686: @item @samp{d}, @samp{a}, @samp{f}, @dots{}
1.1 root 4687: Other letters can be defined in machine-dependent fashion to stand for
4688: particular classes of registers. @samp{d}, @samp{a} and @samp{f} are
1.1.1.2 root 4689: defined on the 68000/68020 to stand for data, address and floating
4690: point registers.
1.1 root 4691:
1.1.1.2 root 4692: @item @samp{i}
1.1 root 4693: An immediate integer operand (one with constant value) is allowed.
1.1.1.2 root 4694: This includes symbolic constants whose values will be known only at
4695: assembly time.
1.1 root 4696:
1.1.1.2 root 4697: @item @samp{n}
4698: An immediate integer operand with a known numeric value is allowed.
4699: Many systems cannot support assembly-time constants for operands less
4700: than a word wide. Constraints for these operands should use @samp{n}
4701: rather than @samp{i}.
4702:
4703: @item @samp{I}, @samp{J}, @samp{K}, @dots{}
4704: Other letters in the range @samp{I} through @samp{M} may be defined in
4705: a machine-dependent fashion to permit immediate integer operands with
4706: explicit integer values in specified ranges. For example, on the
4707: 68000, @samp{I} is defined to stand for the range of values 1 to 8.
4708: This is the range permitted as a shift count in the shift
4709: instructions.
1.1 root 4710:
1.1.1.2 root 4711: @item @samp{F}
1.1 root 4712: An immediate floating operand (expression code @samp{const_double}) is
4713: allowed.
4714:
1.1.1.2 root 4715: @item @samp{G}, @samp{H}
1.1 root 4716: @samp{G} and @samp{H} may be defined in a machine-dependent fashion to
4717: permit immediate floating operands in particular ranges of values.
4718:
1.1.1.2 root 4719: @item @samp{s}
1.1 root 4720: An immediate integer operand whose value is not an explicit integer is
1.1.1.2 root 4721: allowed.
4722:
4723: This might appear strange; if an insn allows a constant operand with a
4724: value not known at compile time, it certainly must allow any known
1.1 root 4725: value. So why use @samp{s} instead of @samp{i}? Sometimes it allows
1.1.1.2 root 4726: better code to be generated.
4727:
4728: For example, on the 68000 in a fullword instruction it is possible to
4729: use an immediate operand; but if the immediate value is between -32
4730: and 31, better code results from loading the value into a register and
4731: using the register. This is because the load into the register can be
4732: done with a @samp{moveq} instruction. We arrange for this to happen
4733: by defining the letter @samp{K} to mean ``any integer outside the
4734: range -32 to 31'', and then specifying @samp{Ks} in the operand
1.1 root 4735: constraints.
4736:
1.1.1.2 root 4737: @item @samp{g}
1.1 root 4738: Any register, memory or immediate integer operand is allowed, except for
4739: registers that are not general registers.
4740:
1.1.1.2 root 4741: @item @samp{@var{n}} (a digit)
4742: An operand that matches operand number @var{n} is allowed.
1.1 root 4743: If a digit is used together with letters, the digit should come last.
4744:
1.1.1.2 root 4745: This is called a @dfn{matching constraint} and what it really means is
4746: that the assembler has only a single operand that fills two roles
4747: considered separate in the RTL insn. For example, an add insn has two
4748: input operands and one output operand in the RTL, but on most machines
4749: an add instruction really has only two operands, one of them an
4750: input-output operand.
4751:
4752: Matching constraints work only in circumstances like that add insn.
4753: More precisely, the matching constraint must appear in an input-only
4754: operand and the operand that it matches must be an output-only operand
4755: with a lower number.
4756:
4757: For operands to match in a particular case usually means that they
4758: are identical-looking RTL expressions. But in a few special cases
4759: specific kinds of dissimilarity are allowed. For example, @code{*x}
4760: as an input operand will match @code{*x++} as an output operand.
4761: For proper results in such cases, the output template should always
4762: use the output-operand's number when printing the operand.
4763:
4764: @item @samp{p}
1.1 root 4765: An operand that is a valid memory address is allowed. This is
4766: for ``load address'' and ``push address'' instructions.
4767:
4768: If @samp{p} is used in the constraint, the test-function in the
4769: @samp{match_operand} must be @code{address_operand}.
4770: @end table
4771:
4772: In order to have valid assembler code, each operand must satisfy
4773: its constraint. But a failure to do so does not prevent the pattern
4774: from applying to an insn. Instead, it directs the compiler to modify
1.1.1.2 root 4775: the code so that the constraint will be satisfied. Usually this is
1.1 root 4776: done by copying an operand into a register.
4777:
4778: Contrast, therefore, the two instruction patterns that follow:
4779:
4780: @example
4781: (define_insn ""
4782: [(set (match_operand:SI 0 "general_operand" "r")
4783: (plus:SI (match_dup 0)
4784: (match_operand:SI 1 "general_operand" "r")))]
4785: ""
4786: "@dots{}")
4787: @end example
4788:
4789: @noindent
4790: which has two operands, one of which must appear in two places, and
4791:
4792: @example
4793: (define_insn ""
4794: [(set (match_operand:SI 0 "general_operand" "r")
4795: (plus:SI (match_operand:SI 1 "general_operand" "0")
4796: (match_operand:SI 2 "general_operand" "r")))]
4797: ""
4798: "@dots{}")
4799: @end example
4800:
4801: @noindent
4802: which has three operands, two of which are required by a constraint to be
4803: identical. If we are considering an insn of the form
4804:
4805: @example
4806: (insn @var{n} @var{prev} @var{next}
4807: (set (reg:SI 3)
4808: (plus:SI (reg:SI 6) (reg:SI 109)))
4809: @dots{})
4810: @end example
4811:
4812: @noindent
4813: the first pattern would not apply at all, because this insn does not
4814: contain two identical subexpressions in the right place. The pattern would
4815: say, ``That does not look like an add instruction; try other patterns.''
4816: The second pattern would say, ``Yes, that's an add instruction, but there
4817: is something wrong with it.'' It would direct the reload pass of the
4818: compiler to generate additional insns to make the constraint true. The
4819: results might look like this:
4820:
4821: @example
4822: (insn @var{n2} @var{prev} @var{n}
4823: (set (reg:SI 3) (reg:SI 6))
4824: @dots{})
4825:
4826: (insn @var{n} @var{n2} @var{next}
4827: (set (reg:SI 3)
4828: (plus:SI (reg:SI 3) (reg:SI 109)))
4829: @dots{})
4830: @end example
4831:
1.1.1.9 ! root 4832: It is up to you to make sure that each operand, in each pattern, has
! 4833: constraints that can handle any RTL expression that could be present for
! 4834: that operand. (When multiple alternatives are in use, each pattern must,
! 4835: for each possible combination of operand expressions, have at least one
! 4836: alternative which can handle that combination of operands.) The
! 4837: constraints don't need to @emph{allow} any possible operand---when this is
! 4838: the case, they do not constrain---but they must at least point the way to
! 4839: reloading any possible operand so that it will fit.
! 4840:
! 4841: @itemize @bullet
! 4842: @item
! 4843: If the constraint accepts whatever operands the predicate permits,
! 4844: there is no problem: reloading is never necessary for this operand.
! 4845:
! 4846: For example, an operand whose constraints permit everything except
! 4847: registers is safe provided its predicate rejects registers.
! 4848:
! 4849: An operand whose predicate accepts only constant values is safe
! 4850: provided its constraints include the letter @samp{i}. If any possible
! 4851: constant value is accepted, then nothing less than @samp{i} will do;
! 4852: if the predicate is more selective, than the constraints may also be
! 4853: more selective.
! 4854:
! 4855: @item
! 4856: Any operand expression can be reloaded by copying it into a register.
! 4857: So if an operand's constraints allow some kind of register, it is
! 4858: certain to be safe. It need not permit all classes of registers; the
! 4859: compiler knows how to copy a register into another register of the
! 4860: proper class in order to make an instruction valid.
! 4861:
! 4862: @item
! 4863: A nonoffsetable memory reference can be reloaded by copying the
! 4864: address into a register. So if the constraint uses the letter
! 4865: @samp{o}, all memory references are taken care of.
! 4866:
! 4867: @item
! 4868: A constant operand can be reloaded by storing it in memory; it then
! 4869: becomes an offsetable memory reference. So if the constraint uses the
! 4870: letters @samp{o} or @samp{m}, constant operands are not a problem.
! 4871: @end itemize
! 4872:
! 4873: If the operand's predicate can recognize registers, but the constraint does
! 4874: not permit them, it can make the compiler crash. When this operand happens
! 4875: to be a register, the reload pass will be stymied, because it does not know
! 4876: how to copy a register temporarily into memory.
1.1 root 4877:
4878: @node Multi-Alternative, Class Preferences, Simple Constraints, Constraints
4879: @subsection Multiple Alternative Constraints
4880:
4881: Sometimes a single instruction has multiple alternative sets of possible
4882: operands. For example, on the 68000, a logical-or instruction can combine
4883: register or an immediate value into memory, or it can combine any kind of
4884: operand into a register; but it cannot combine one memory location into
4885: another.
4886:
4887: These constraints are represented as multiple alternatives. An alternative
4888: can be described by a series of letters for each operand. The overall
4889: constraint for an operand is made from the letters for this operand
4890: from the first alternative, a comma, the letters for this operand from
4891: the second alternative, a comma, and so on until the last alternative.
4892: Here is how it is done for fullword logical-or on the 68000:
4893:
4894: @example
4895: (define_insn "iorsi3"
4896: [(set (match_operand:SI 0 "general_operand" "=%m,d")
1.1.1.2 root 4897: (ior:SI (match_operand:SI 1 "general_operand" "0,0")
4898: (match_operand:SI 2 "general_operand" "dKs,dmKs")))]
1.1 root 4899: @dots{})
4900: @end example
4901:
4902: The first alternative has @samp{m} (memory) for operand 0, @samp{0} for
4903: operand 1 (meaning it must match operand 0), and @samp{dKs} for operand 2.
4904: The second alternative has @samp{d} (data register) for operand 0, @samp{0}
4905: for operand 1, and @samp{dmKs} for operand 2. The @samp{=} and @samp{%} in
4906: the constraint for operand 0 are not part of any alternative; their meaning
4907: is explained in the next section.
4908:
4909: If all the operands fit any one alternative, the instruction is valid.
4910: Otherwise, for each alternative, the compiler counts how many instructions
4911: must be added to copy the operands so that that alternative applies.
4912: The alternative requiring the least copying is chosen. If two alternatives
4913: need the same amount of copying, the one that comes first is chosen.
4914: These choices can be altered with the @samp{?} and @samp{!} characters:
4915:
4916: @table @samp
4917: @item ?
4918: Disparage slightly the alternative that the @samp{?} appears in,
4919: as a choice when no alternative applies exactly. The compiler regards
4920: this alternative as one unit more costly for each @samp{?} that appears
4921: in it.
4922:
4923: @item !
4924: Disparage severely the alternative that the @samp{!} appears in.
4925: When operands must be copied into registers, the compiler will
4926: never choose this alternative as the one to strive for.
4927: @end table
4928:
1.1.1.2 root 4929: When an insn pattern has multiple alternatives in its constraints,
4930: often the appearance of the assembler code determined mostly by which
4931: alternative was matched. When this is so, the C code for writing the
4932: assembler code can use the variable @code{which_alternative}, which is
4933: the ordinal number of the alternative that was actually satisfied
4934: (0 for the first, 1 for the second alternative, etc.). For example:
4935:
4936: @example
4937: (define_insn ""
4938: [(set (match_operand:SI 0 "general_operand" "r,m")
4939: (const_int 0))]
4940: ""
4941: "*
4942: return (which_alternative == 0
4943: ? \"clrreg %0\" : \"clrmem %0\");
4944: ")
4945: @end example
4946:
1.1 root 4947: @node Class Preferences, Modifiers, Multi-Alternative, Constraints
4948: @subsection Register Class Preferences
4949:
4950: The operand constraints have another function: they enable the compiler
4951: to decide which kind of hardware register a pseudo register is best
4952: allocated to. The compiler examines the constraints that apply to the
4953: insns that use the pseudo register, looking for the machine-dependent
4954: letters such as @samp{d} and @samp{a} that specify classes of registers.
4955: The pseudo register is put in whichever class gets the most ``votes''.
4956: The constraint letters @samp{g} and @samp{r} also vote: they vote in
4957: favor of a general register. The machine description says which registers
4958: are considered general.
4959:
4960: Of course, on some machines all registers are equivalent, and no register
4961: classes are defined. Then none of this complexity is relevant.
4962:
4963: @node Modifiers, No Constraints, Class Preferences, Constraints
4964: @subsection Constraint Modifier Characters
4965:
4966: @table @samp
4967: @item =
1.1.1.2 root 4968: Means that this operand is write-only for this instruction: the previous
4969: value is discarded and replaced by output data.
1.1 root 4970:
4971: @item +
4972: Means that this operand is both read and written by the instruction.
4973:
4974: When the compiler fixes up the operands to satisfy the constraints,
4975: it needs to know which operands are inputs to the instruction and
4976: which are outputs from it. @samp{=} identifies an output; @samp{+}
4977: identifies an operand that is both input and output; all other operands
4978: are assumed to be input only.
4979:
1.1.1.2 root 4980: @item &
4981: Means (in a particular alternative) that this operand is written
4982: before the instruction is finished using the input operands.
4983: Therefore, this operand may not lie in a register that is used as an
4984: input operand or as part of any memory address.
4985:
4986: @samp{&} applies only to the alternative in which it is written. In
4987: constraints with multiple alternatives, sometimes one alternative
4988: requires @samp{&} while others do not. See, for example, the
4989: @samp{movdf} insn of the 68000.
4990:
4991: @samp{&} does not obviate the need to write @samp{=}.
4992:
1.1 root 4993: @item %
1.1.1.2 root 4994: Declares the instruction to be commutative for this operand and the
4995: following operand. This means that the compiler may interchange the
4996: two operands if that is the cheapest way to make all operands fit the
4997: constraints. This is often used in patterns for addition instructions
4998: that really have only two operands: the result must go in one of the
4999: arguments. Here for example, is how the 68000 halfword-add
5000: instruction is defined:
5001:
5002: @example
5003: (define_insn "addhi3"
5004: [(set (match_operand:HI 0 "general_operand" "=m,r")
5005: (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
5006: (match_operand:HI 2 "general_operand" "di,g")))]
5007: @dots{})
5008: @end example
5009:
5010: Note that in previous versions of GNU CC the @samp{%} constraint
5011: modifier always applied to operands 1 and 2 regardless of which
5012: operand it was written in. The usual custom was to write it in
5013: operand 0. Now it must be in operand 1 if the operands to be
5014: exchanged are 1 and 2.
1.1 root 5015:
5016: @item #
1.1.1.2 root 5017: Says that all following characters, up to the next comma, are to be
5018: ignored as a constraint. They are significant only for choosing
5019: register preferences.
1.1 root 5020:
5021: @item *
5022: Says that the following character should be ignored when choosing
1.1.1.2 root 5023: register preferences. @samp{*} has no effect on the meaning of the
5024: constraint as a constraint.
5025:
5026: Here is an example: the 68000 has an instruction to sign-extend a
5027: halfword in a data register, and can also sign-extend a value by
5028: copying it into an address register. While either kind of register is
5029: acceptable, the constraints on an address-register destination are
5030: less strict, so it is best if register allocation makes an address
5031: register its goal. Therefore, @samp{*} is used so that the @samp{d}
5032: constraint letter (for data register) is ignored when computing
5033: register preferences.
5034:
5035: @example
5036: (define_insn "extendhisi2"
5037: [(set (match_operand:SI 0 "general_operand" "=*d,a")
5038: (sign_extend:SI
5039: (match_operand:HI 1 "general_operand" "0,g")))]
5040: @dots{})
5041: @end example
1.1 root 5042: @end table
5043:
5044: @node No Constraints,, Modifiers, Constraints
5045: @subsection Not Using Constraints
5046:
5047: Some machines are so clean that operand constraints are not required. For
5048: example, on the Vax, an operand valid in one context is valid in any other
1.1.1.2 root 5049: context. On such a machine, every operand constraint would be @samp{g},
1.1 root 5050: excepting only operands of ``load address'' instructions which are
5051: written as if they referred to a memory location's contents but actual
1.1.1.2 root 5052: refer to its address. They would have constraint @samp{p}.
1.1 root 5053:
1.1.1.2 root 5054: For such machines, instead of writing @samp{g} and @samp{p} for all
1.1 root 5055: the constraints, you can choose to write a description with empty constraints.
5056: Then you write @samp{""} for the constraint in every @samp{match_operand}.
5057: Address operands are identified by writing an @samp{address} expression
5058: around the @samp{match_operand}, not by their constraints.
5059:
5060: When the machine description has just empty constraints, certain parts
5061: of compilation are skipped, making the compiler faster.
5062:
1.1.1.2 root 5063: @node Standard Names, Pattern Ordering, Constraints, Machine Desc
5064: @section Standard Names for Patterns Used in Generation
1.1 root 5065:
5066: Here is a table of the instruction names that are meaningful in the RTL
5067: generation pass of the compiler. Giving one of these names to an
5068: instruction pattern tells the RTL generation pass that it can use the
5069: pattern in to accomplish a certain task.
5070:
1.1.1.2 root 5071: @table @asis
5072: @item @samp{mov@var{m}}
1.1 root 5073: Here @var{m} is a two-letter machine mode name, in lower case. This
5074: instruction pattern moves data with that machine mode from operand 1 to
5075: operand 0. For example, @samp{movsi} moves full-word data.
5076:
5077: If operand 0 is a @samp{subreg} with mode @var{m} of a register whose
5078: natural mode is wider than @var{m}, the effect of this instruction is
5079: to store the specified value in the part of the register that corresponds
5080: to mode @var{m}. The effect on the rest of the register is undefined.
5081:
1.1.1.3 root 5082: This class of patterns is special in several ways. First of all, each
5083: of these names @emph{must} be defined, because there is no other way
5084: to copy a datum from one place to another.
5085:
5086: Second, these patterns are not used solely in the RTL generation pass.
5087: Even the reload pass can generate move insns to copy values from stack
5088: slots into temporary registers. When it does so, one of the operands
5089: is a hard register and the other is an operand that can have a reload.
5090:
5091: Therefore, when given such a pair of operands, the pattern must
5092: generate RTL which needs no temporary registers---no registers other
5093: than the operands. For example, if you support the pattern with a
5094: @code{define_expand}, then in such a case you mustn't call
5095: @code{force_reg} or any other such function which might generate new
5096: pseudo registers.
5097:
5098: This requirement exists even for subword modes on a RISC machine where
5099: fetching those modes from memory normally requires several insns and
5100: some temporary registers. Look in @file{spur.md} to see how the
5101: requirement is satisfied.
5102:
5103: The variety of operands that have reloads depends on the rest of the
5104: machine description, but typically on a RISC machine these can only be
5105: pseudo registers that did not get hard registers, while on other
5106: machines explicit memory references will get optional reloads.
5107:
1.1.1.7 root 5108: In addition, the constraints must allow any hard register to be moved
5109: to any other hard register (provided that @code{HARD_REGNO_MODE_OK}
5110: permits mode @var{m} in each of the registers).
5111:
1.1.1.2 root 5112: @item @samp{movstrict@var{m}}
1.1 root 5113: Like @samp{mov@var{m}} except that if operand 0 is a @samp{subreg}
5114: with mode @var{m} of a register whose natural mode is wider,
5115: the @samp{movstrict@var{m}} instruction is guaranteed not to alter
5116: any of the register except the part which belongs to mode @var{m}.
5117:
1.1.1.2 root 5118: @item @samp{add@var{m}3}
1.1 root 5119: Add operand 2 and operand 1, storing the result in operand 0. All operands
5120: must have mode @var{m}. This can be used even on two-address machines, by
5121: means of constraints requiring operands 1 and 0 to be the same location.
5122:
1.1.1.2 root 5123: @item @samp{sub@var{m}3}, @samp{mul@var{m}3}, @samp{umul@var{m}3}, @samp{div@var{m}3}, @samp{udiv@var{m}3}, @samp{mod@var{m}3}, @samp{umod@var{m}3}, @samp{and@var{m}3}, @samp{ior@var{m}3}, @samp{xor@var{m}3}
1.1 root 5124: Similar, for other arithmetic operations.
5125:
1.1.1.8 root 5126: There are special considerations for register classes for logical-and
5127: instructions, affecting also the macro @code{PREFERRED_RELOAD_CLASS}.
5128: They apply not only to the patterns with these standard names, but to
5129: any patterns that will match such an instruction. @xref{Register
5130: Classes}.
5131:
1.1.1.2 root 5132: @item @samp{andcb@var{m}3}
1.1 root 5133: Bitwise logical-and operand 1 with the complement of operand 2
5134: and store the result in operand 0.
5135:
1.1.1.2 root 5136: @item @samp{mulhisi3}
1.1 root 5137: Multiply operands 1 and 2, which have mode @code{HImode}, and store
5138: a @code{SImode} product in operand 0.
5139:
1.1.1.2 root 5140: @item @samp{mulqihi3}, @samp{mulsidi3}
1.1 root 5141: Similar widening-multiplication instructions of other widths.
5142:
1.1.1.2 root 5143: @item @samp{umulqihi3}, @samp{umulhisi3}, @samp{umulsidi3}
1.1 root 5144: Similar widening-multiplication instructions that do unsigned
5145: multiplication.
5146:
1.1.1.2 root 5147: @item @samp{divmod@var{m}4}
1.1 root 5148: Signed division that produces both a quotient and a remainder.
5149: Operand 1 is divided by operand 2 to produce a quotient stored
5150: in operand 0 and a remainder stored in operand 3.
5151:
1.1.1.2 root 5152: @item @samp{udivmod@var{m}4}
1.1 root 5153: Similar, but does unsigned division.
5154:
1.1.1.2 root 5155: @item @samp{divmod@var{m}@var{n}4}
1.1 root 5156: Like @samp{divmod@var{m}4} except that only the dividend has mode
5157: @var{m}; the divisor, quotient and remainder have mode @var{n}.
5158: For example, the Vax has a @samp{divmoddisi4} instruction
5159: (but it is omitted from the machine description, because it
5160: is so slow that it is faster to compute remainders by the
5161: circumlocution that the compiler will use if this instruction is
5162: not available).
5163:
1.1.1.2 root 5164: @item @samp{ashl@var{m}3}
1.1 root 5165: Arithmetic-shift operand 1 left by a number of bits specified by
5166: operand 2, and store the result in operand 0. Operand 2 has
5167: mode @code{SImode}, not mode @var{m}.
5168:
1.1.1.2 root 5169: @item @samp{ashr@var{m}3}, @samp{lshl@var{m}3}, @samp{lshr@var{m}3}, @samp{rotl@var{m}3}, @samp{rotr@var{m}3}
1.1 root 5170: Other shift and rotate instructions.
5171:
1.1.1.2 root 5172: Logical and arithmetic left shift are the same. Machines that do not
5173: allow negative shift counts often have only one instruction for
5174: shifting left. On such machines, you should define a pattern named
5175: @samp{ashl@var{m}3} and leave @samp{lshl@var{m}3} undefined.
5176:
1.1.1.8 root 5177: There are special considerations for register classes for shift
5178: instructions, affecting also the macro @code{PREFERRED_RELOAD_CLASS}.
5179: They apply not only to the patterns with these standard names, but to
5180: any patterns that will match such an instruction. @xref{Register
5181: Classes}.
5182:
1.1.1.2 root 5183: @item @samp{neg@var{m}2}
1.1 root 5184: Negate operand 1 and store the result in operand 0.
5185:
1.1.1.2 root 5186: @item @samp{abs@var{m}2}
1.1 root 5187: Store the absolute value of operand 1 into operand 0.
5188:
1.1.1.2 root 5189: @item @samp{sqrt@var{m}2}
1.1 root 5190: Store the square root of operand 1 into operand 0.
5191:
1.1.1.2 root 5192: @item @samp{ffs@var{m}2}
5193: Store into operand 0 one plus the index of the least significant 1-bit
5194: of operand 1. If operand 1 is zero, store zero. @var{m} is the mode
5195: of operand 0; operand 1's mode is specified by the instruction
5196: pattern, and the compiler will convert the operand to that mode before
5197: generating the instruction.
5198:
5199: @item @samp{one_cmpl@var{m}2}
1.1 root 5200: Store the bitwise-complement of operand 1 into operand 0.
5201:
1.1.1.2 root 5202: @item @samp{cmp@var{m}}
1.1 root 5203: Compare operand 0 and operand 1, and set the condition codes.
1.1.1.2 root 5204: The RTL pattern should look like this:
1.1 root 5205:
1.1.1.2 root 5206: @example
5207: (set (cc0) (minus (match_operand:@var{m} 0 @dots{})
5208: (match_operand:@var{m} 1 @dots{})))
5209: @end example
5210:
5211: Each such definition in the machine description, for integer mode
5212: @var{m}, must have a corresponding @samp{tst@var{m}} pattern, because
5213: optimization can simplify the compare into a test when operand 1 is
5214: zero.
5215:
5216: @item @samp{tst@var{m}}
1.1 root 5217: Compare operand 0 against zero, and set the condition codes.
1.1.1.2 root 5218: The RTL pattern should look like this:
1.1 root 5219:
1.1.1.2 root 5220: @example
5221: (set (cc0) (match_operand:@var{m} 0 @dots{}))
5222: @end example
5223:
5224: @item @samp{movstr@var{m}}
1.1 root 5225: Block move instruction. The addresses of the destination and source
5226: strings are the first two operands, and both are in mode @code{Pmode}.
5227: The number of bytes to move is the third operand, in mode @var{m}.
5228:
1.1.1.2 root 5229: @item @samp{cmpstr@var{m}}
1.1 root 5230: Block compare instruction, with operands like @samp{movstr@var{m}}
5231: except that the two memory blocks are compared byte by byte
5232: in lexicographic order. The effect of the instruction is to set
5233: the condition codes.
5234:
1.1.1.2 root 5235: @item @samp{float@var{m}@var{n}2}
1.1 root 5236: Convert operand 1 (valid for fixed point mode @var{m}) to floating
5237: point mode @var{n} and store in operand 0 (which has mode @var{n}).
5238:
1.1.1.2 root 5239: @item @samp{fix@var{m}@var{n}2}
5240: Convert operand 1 (valid for floating point mode @var{m}) to fixed
5241: point mode @var{n} as a signed number and store in operand 0 (which
5242: has mode @var{n}). This instruction's result is defined only when
5243: the value of operand 1 is an integer.
5244:
5245: @item @samp{fixuns@var{m}@var{n}2}
5246: Convert operand 1 (valid for floating point mode @var{m}) to fixed
5247: point mode @var{n} as an unsigned number and store in operand 0 (which
5248: has mode @var{n}). This instruction's result is defined only when the
5249: value of operand 1 is an integer.
5250:
5251: @item @samp{ftrunc@var{m}2}
5252: Convert operand 1 (valid for floating point mode @var{m}) to an
5253: integer value, still represented in floating point mode @var{m}, and
5254: store it in operand 0 (valid for floating point mode @var{m}).
5255:
5256: @item @samp{fix_trunc@var{m}@var{n}2}
5257: Like @samp{fix@var{m}@var{n}2} but works for any floating point value
5258: of mode @var{m} by converting the value to an integer.
5259:
5260: @item @samp{fixuns_trunc@var{m}@var{n}2}
5261: Like @samp{fixuns@var{m}@var{n}2} but works for any floating point
5262: value of mode @var{m} by converting the value to an integer.
5263:
5264: @item @samp{trunc@var{m}@var{n}}
1.1 root 5265: Truncate operand 1 (valid for mode @var{m}) to mode @var{n} and
5266: store in operand 0 (which has mode @var{n}). Both modes must be fixed
5267: point or both floating point.
5268:
1.1.1.2 root 5269: @item @samp{extend@var{m}@var{n}}
1.1 root 5270: Sign-extend operand 1 (valid for mode @var{m}) to mode @var{n} and
5271: store in operand 0 (which has mode @var{n}). Both modes must be fixed
5272: point or both floating point.
5273:
1.1.1.2 root 5274: @item @samp{zero_extend@var{m}@var{n}}
1.1 root 5275: Zero-extend operand 1 (valid for mode @var{m}) to mode @var{n} and
5276: store in operand 0 (which has mode @var{n}). Both modes must be fixed
5277: point.
5278:
1.1.1.2 root 5279: @item @samp{extv}
1.1 root 5280: Extract a bit-field from operand 1 (a register or memory operand),
5281: where operand 2 specifies the width in bits and operand 3 the starting
5282: bit, and store it in operand 0. Operand 0 must have @code{Simode}.
5283: Operand 1 may have mode @code{QImode} or @code{SImode}; often
5284: @code{SImode} is allowed only for registers. Operands 2 and 3 must be
5285: valid for @code{SImode}.
5286:
5287: The RTL generation pass generates this instruction only with constants
5288: for operands 2 and 3.
5289:
5290: The bit-field value is sign-extended to a full word integer
5291: before it is stored in operand 0.
5292:
1.1.1.2 root 5293: @item @samp{extzv}
1.1 root 5294: Like @samp{extv} except that the bit-field value is zero-extended.
5295:
1.1.1.2 root 5296: @item @samp{insv}
1.1 root 5297: Store operand 3 (which must be valid for @code{SImode}) into a
5298: bit-field in operand 0, where operand 1 specifies the width in bits
5299: and operand 2 the starting bit. Operand 0 may have mode @code{QImode}
5300: or @code{SImode}; often @code{SImode} is allowed only for registers.
5301: Operands 1 and 2 must be valid for @code{SImode}.
5302:
5303: The RTL generation pass generates this instruction only with constants
5304: for operands 1 and 2.
5305:
1.1.1.2 root 5306: @item @samp{s@var{cond}}
5307: Store zero or nonzero in the operand according to the condition codes.
5308: Value stored is nonzero iff the condition @var{cond} is true.
5309: @var{cond} is the name of a comparison operation expression code, such
1.1 root 5310: as @samp{eq}, @samp{lt} or @samp{leu}.
5311:
1.1.1.2 root 5312: You specify the mode that the operand must have when you write the
5313: @code{match_operand} expression. The compiler automatically sees
5314: which mode you have used and supplies an operand of that mode.
5315:
5316: The value stored for a true condition must have 1 as its low bit.
5317: Otherwise the instruction is not suitable and must be omitted from the
5318: machine description. You must tell the compiler exactly which value
5319: is stored by defining the macro @code{STORE_FLAG_VALUE}.
5320:
5321: @item @samp{b@var{cond}}
1.1 root 5322: Conditional branch instruction. Operand 0 is a @samp{label_ref}
5323: that refers to the label to jump to. Jump if the condition codes
5324: meet condition @var{cond}.
5325:
1.1.1.2 root 5326: @item @samp{call}
1.1.1.7 root 5327: Subroutine call instruction returning no value. Operand 0 is the
5328: function to call; operand 1 is the number of bytes of arguments pushed
5329: (in mode @code{SImode}, except it is normally a @samp{const_int});
5330: operand 2 is the number of registers used as operands.
5331:
1.1.1.8 root 5332: On most machines, operand 2 is not actually stored into the RTL
5333: pattern. It is supplied for the sake of some RISC machines which need
5334: to put this information into the assembler code; they can put it in
5335: the RTL instead of operand 1.
1.1.1.7 root 5336:
5337: Operand 0 should be a @samp{mem} RTX whose address is the address of
5338: the function.
5339:
5340: @item @samp{call_value}
5341: Subroutine call instruction returning a value. Operand 0 is the hard
5342: register in which the value is returned. There are three more
5343: operands, the same as the three operands of the @samp{call}
5344: instruction (but with numbers increased by one).
5345:
5346: Subroutines that return @code{BLKmode} objects use the @samp{call}
5347: insn.
1.1 root 5348:
1.1.1.2 root 5349: @item @samp{return}
1.1 root 5350: Subroutine return instruction. This instruction pattern name should be
5351: defined only if a single instruction can do all the work of returning
5352: from a function.
5353:
1.1.1.3 root 5354: @item @samp{casesi}
5355: Instruction to jump through a dispatch table, including bounds checking.
5356: This instruction takes five operands:
5357:
5358: @enumerate
5359: @item
5360: The index to dispatch on, which has mode @code{SImode}.
5361:
5362: @item
5363: The lower bound for indices in the table, an integer constant.
5364:
5365: @item
5366: The upper bound for indices in the table, an integer constant.
5367:
5368: @item
5369: A label to jump to if the index has a value outside the bounds.
5370: (If the machine-description macro @code{CASE_DROPS_THROUGH} is defined,
5371: then an out-of-bounds index drops through to the code following
5372: the jump table instead of jumping to this label. In that case,
5373: this label is not actually used by the @samp{casesi} instruction,
5374: but it is always provided as an operand.)
5375:
5376: @item
5377: A label that precedes the table itself.
5378: @end enumerate
5379:
5380: The table is a @samp{addr_vec} or @samp{addr_diff_vec} inside of a
5381: @samp{jump_insn}. The number of elements in the table is one plus the
5382: difference between the upper bound and the lower bound.
5383:
1.1.1.2 root 5384: @item @samp{tablejump}
1.1.1.3 root 5385: Instruction to jump to a variable address. This is a low-level
5386: capability which can be used to implement a dispatch table when there
5387: is no @samp{casesi} pattern.
5388:
5389: This pattern requires two operands: the address or offset, and a label
5390: which should immediately precede the jump table. If the macro
5391: @code{CASE_VECTOR_PC_RELATIVE} is defined then the first operand is an
5392: absolute address to jump to; otherwise, it is an offset which counts
5393: from the address of the table.
5394:
5395: The @samp{tablejump} insn is always the last insn before the jump
5396: table it uses. Its assembler code normally has no need to use the
5397: second operand, but you should incorporate it in the RTL pattern so
5398: that the jump optimizer will not delete the table as unreachable code.
1.1 root 5399: @end table
5400:
1.1.1.2 root 5401: @node Pattern Ordering, Dependent Patterns, Standard Names, Machine Desc
5402: @section When the Order of Patterns Matters
5403:
5404: Sometimes an insn can match more than one instruction pattern. Then the
5405: pattern that appears first in the machine description is the one used.
5406: Therefore, more specific patterns (patterns that will match fewer things)
5407: and faster instructions (those that will produce better code when they
5408: do match) should usually go first in the description.
5409:
5410: In some cases the effect of ordering the patterns can be used to hide
5411: a pattern when it is not valid. For example, the 68000 has an
5412: instruction for converting a fullword to floating point and another
5413: for converting a byte to floating point. An instruction converting
5414: an integer to floating point could match either one. We put the
5415: pattern to convert the fullword first to make sure that one will
5416: be used rather than the other. (Otherwise a large integer might
5417: be generated as a single-byte immediate quantity, which would not work.)
5418: Instead of using this pattern ordering it would be possible to make the
5419: pattern for convert-a-byte smart enough to deal properly with any
5420: constant value.
5421:
5422: @node Dependent Patterns, Jump Patterns, Pattern Ordering, Machine Desc
5423: @section Interdependence of Patterns
1.1 root 5424:
5425: Every machine description must have a named pattern for each of the
5426: conditional branch names @samp{b@var{cond}}. The recognition template
5427: must always have the form
5428:
5429: @example
5430: (set (pc)
5431: (if_then_else (@var{cond} (cc0) (const_int 0))
5432: (label_ref (match_operand 0 "" ""))
5433: (pc)))
5434: @end example
5435:
5436: @noindent
5437: In addition, every machine description must have an anonymous pattern
5438: for each of the possible reverse-conditional branches. These patterns
5439: look like
5440:
5441: @example
5442: (set (pc)
5443: (if_then_else (@var{cond} (cc0) (const_int 0))
5444: (pc)
5445: (label_ref (match_operand 0 "" ""))))
5446: @end example
5447:
5448: @noindent
5449: They are necessary because jump optimization can turn direct-conditional
5450: branches into reverse-conditional branches.
5451:
5452: The compiler does more with RTL than just create it from patterns
5453: and recognize the patterns: it can perform arithmetic expression codes
5454: when constant values for their operands can be determined. As a result,
5455: sometimes having one pattern can require other patterns. For example, the
5456: Vax has no `and' instruction, but it has `and not' instructions. Here
5457: is the definition of one of them:
5458:
5459: @example
5460: (define_insn "andcbsi2"
5461: [(set (match_operand:SI 0 "general_operand" "")
5462: (and:SI (match_dup 0)
5463: (not:SI (match_operand:SI
5464: 1 "general_operand" ""))))]
5465: ""
5466: "bicl2 %1,%0")
5467: @end example
5468:
5469: @noindent
5470: If operand 1 is an explicit integer constant, an instruction constructed
1.1.1.2 root 5471: using that pattern can be simplified into an `and' like this:
1.1 root 5472:
5473: @example
5474: (set (reg:SI 41)
5475: (and:SI (reg:SI 41)
5476: (const_int 0xffff7fff)))
5477: @end example
5478:
5479: @noindent
5480: (where the integer constant is the one's complement of what
5481: appeared in the original instruction).
5482:
5483: To avoid a fatal error, the compiler must have a pattern that recognizes
5484: such an instruction. Here is what is used:
5485:
5486: @example
5487: (define_insn ""
5488: [(set (match_operand:SI 0 "general_operand" "")
5489: (and:SI (match_dup 0)
5490: (match_operand:SI 1 "general_operand" "")))]
5491: "GET_CODE (operands[1]) == CONST_INT"
5492: "*
1.1.1.2 root 5493: @{ operands[1]
1.1 root 5494: = gen_rtx (CONST_INT, VOIDmode, ~INTVAL (operands[1]));
5495: return \"bicl2 %1,%0\";
1.1.1.2 root 5496: @}")
1.1 root 5497: @end example
5498:
5499: @noindent
5500: Whereas a pattern to match a general `and' instruction is impossible to
5501: support on the Vax, this pattern is possible because it matches only a
5502: constant second argument: a special case that can be output as an `and not'
5503: instruction.
5504:
1.1.1.2 root 5505: A ``compare'' instruction whose RTL looks like this:
5506:
5507: @example
5508: (set (cc0) (minus @var{operand} (const_int 0)))
5509: @end example
5510:
5511: @noindent
5512: may be simplified by optimization into a ``test'' like this:
5513:
5514: @example
5515: (set (cc0) @var{operand})
5516: @end example
5517:
5518: @noindent
5519: So in the machine description, each ``compare'' pattern for an integer
5520: mode must have a corresponding ``test'' pattern that will match the
5521: result of such simplification.
5522:
5523: In some cases machines support instructions identical except for the
5524: machine mode of one or more operands. For example, there may be
5525: ``sign-extend halfword'' and ``sign-extend byte'' instructions whose
5526: patterns are
5527:
5528: @example
5529: (set (match_operand:SI 0 @dots{})
5530: (extend:SI (match_operand:HI 1 @dots{})))
5531:
5532: (set (match_operand:SI 0 @dots{})
5533: (extend:SI (match_operand:QI 1 @dots{})))
5534: @end example
5535:
5536: @noindent
5537: Constant integers do not specify a machine mode, so an instruction to
5538: extend a constant value could match either pattern. The pattern it
5539: actually will match is the one that appears first in the file. For correct
5540: results, this must be the one for the widest possible mode (@code{HImode},
5541: here). If the pattern matches the @code{QImode} instruction, the results
5542: will be incorrect if the constant value does not actually fit that mode.
5543:
5544: Such instructions to extend constants are rarely generated because they are
5545: optimized away, but they do occasionally happen in nonoptimized
5546: compilations.
5547:
1.1.1.9 ! root 5548: When an instruction has the constraint letter @samp{o}, the reload
! 5549: pass may generate instructions which copy a nonoffsetable address into
! 5550: an index register. The idea is that the register can be used as a
! 5551: replacement offsetable address. In order for these generated
! 5552: instructions to work, there must be patterns to copy any kind of valid
! 5553: address into a register.
! 5554:
! 5555: Most older machine designs have ``load address'' instructions which do
! 5556: just what is needed here. Some RISC machines do not advertise such
! 5557: instructions, but the possible addresses on these machines are very
! 5558: limited, so it is easy to fake them.
! 5559:
! 5560: Auto-increment and auto-decrement addresses are an exception; there
! 5561: need not be an instruction that can copy such an address into a
! 5562: register, because reload handles these cases in a different manner.
! 5563:
1.1.1.2 root 5564: @node Jump Patterns, Peephole Definitions, Dependent Patterns, Machine Desc
5565: @section Defining Jump Instruction Patterns
5566:
5567: GNU CC assumes that the machine has a condition code. A comparison insn
5568: sets the condition code, recording the results of both signed and unsigned
5569: comparison of the given operands. A separate branch insn tests the
5570: condition code and branches or not according its value. The branch insns
5571: come in distinct signed and unsigned flavors. Many common machines, such
5572: as the Vax, the 68000 and the 32000, work this way.
5573:
5574: Some machines have distinct signed and unsigned compare instructions, and
5575: only one set of conditional branch instructions. The easiest way to handle
5576: these machines is to treat them just like the others until the final stage
5577: where assembly code is written. At this time, when outputting code for the
5578: compare instruction, peek ahead at the following branch using
5579: @code{NEXT_INSN (insn)}. (The variable @code{insn} refers to the insn
5580: being output, in the output-writing code in an instruction pattern.) If
5581: the RTL says that is an unsigned branch, output an unsigned compare;
5582: otherwise output a signed compare. When the branch itself is output, you
5583: can treat signed and unsigned branches identically.
5584:
5585: The reason you can do this is that GNU CC always generates a pair of
5586: consecutive RTL insns, one to set the condition code and one to test it,
5587: and keeps the pair inviolate until the end.
5588:
5589: To go with this technique, you must define the machine-description macro
5590: @code{NOTICE_UPDATE_CC} to do @code{CC_STATUS_INIT}; in other words, no
5591: compare instruction is superfluous.
5592:
5593: Some machines have compare-and-branch instructions and no condition code.
5594: A similar technique works for them. When it is time to ``output'' a
5595: compare instruction, record its operands in two static variables. When
5596: outputting the branch-on-condition-code instruction that follows, actually
5597: output a compare-and-branch instruction that uses the remembered operands.
5598:
5599: It also works to define patterns for compare-and-branch instructions.
5600: In optimizing compilation, the pair of compare and branch instructions
5601: will be combined accoprding to these patterns. But this does not happen
5602: if optimization is not requested. So you must use one of the solutions
5603: above in addition to any special patterns you define.
5604:
5605: @node Peephole Definitions, Expander Definitions, Jump Patterns, Machine Desc
5606: @section Defining Machine-Specific Peephole Optimizers
5607:
5608: In addition to instruction patterns the @file{md} file may contain
5609: definitions of machine-specific peephole optimizations.
5610:
5611: The combiner does not notice certain peephole optimizations when the data
5612: flow in the program does not suggest that it should try them. For example,
5613: sometimes two consecutive insns related in purpose can be combined even
5614: though the second one does not appear to use a register computed in the
5615: first one. A machine-specific peephole optimizer can detect such
5616: opportunities.
5617:
5618: A definition looks like this:
5619:
5620: @example
5621: (define_peephole
5622: [@var{insn-pattern-1}
5623: @var{insn-pattern-2}
5624: @dots{}]
5625: "@var{condition}"
5626: "@var{template}")
5627: @end example
5628:
5629: In this skeleton, @var{insn-pattern-1} and so on are patterns to match
5630: consecutive instructions. The optimization applies to a sequence of
5631: instructions when @var{insn-pattern-1} matches the first one,
5632: @var{insn-pattern-2} matches the next, and so on.@refill
5633:
5634: @var{insn-pattern-1} and so on look @emph{almost} like the second operand
5635: of @code{define_insn}. There is one important difference: this pattern is
5636: an RTX, not a vector. If the @code{define_insn} pattern would be a vector
5637: of one element, the @var{insn-pattern} should be just that element, no
5638: vector. If the @code{define_insn} pattern would have multiple elements
5639: then the @var{insn-pattern} must place the vector inside an explicit
5640: @code{parallel} RTX.@refill
5641:
5642: The operands of the instructions are matched with @code{match_operands} and
5643: @code{match_dup}, as usual). What is not usual is that the operand numbers
5644: apply to all the instruction patterns in the definition. So, you can check
5645: for identical operands in two instructions by using @code{match_operand}
5646: in one instruction and @code{match_dup} in the other.
5647:
5648: The operand constraints used in @code{match_operand} patterns do not have
5649: any direct effect on the applicability of the optimization, but they will
5650: be validated afterward, so write constraints that are sure to fit whenever
5651: the optimization is applied. It is safe to use @code{"g"} for each
5652: operand.
5653:
5654: Once a sequence of instructions matches the patterns, the @var{condition}
5655: is checked. This is a C expression which makes the final decision whether
5656: to perform the optimization (do so if the expression is nonzero). If
5657: @var{condition} is omitted (in other words, the string is empty) then the
5658: optimization is applied to every sequence of instructions that matches the
5659: patterns.
5660:
5661: The defined peephole optimizations are applied after register allocation is
5662: complete. Therefore, the optimizer can check which operands have ended up
5663: in which kinds of registers, just by looking at the operands.
5664:
5665: The way to refer to the operands in @var{condition} is to write
5666: @code{operands[@var{i}]} for operand number @var{i} (as matched by
5667: @code{(match_operand @var{i} @dots{})}). Use the variable @code{insn} to
5668: refer to the last of the insns being matched; use @code{PREV_INSN} to find
5669: the preceding insns (but be careful to skip over any @samp{note} insns that
5670: intervene).@refill
5671:
5672: When optimizing computations with intermediate results, you can use
5673: @var{condition} to match only when the intermediate results are not used
5674: elsewhere. Use the C expression @code{dead_or_set_p (@var{insn},
5675: @var{op})}, where @var{insn} is the insn in which you expect the value to
5676: be used for the last time (from the value of @code{insn}, together with use
5677: of @code{PREV_INSN}), and @var{op} is the intermediate value (from
5678: @code{operands[@var{i}]}).@refill
5679:
5680: Applying the optimization means replacing the sequence of instructions with
5681: one new instruction. The @var{template} controls ultimate output of
5682: assembler code for this combined instruction. It works exactly like the
5683: template of a @code{define_insn}. Operand numbers in this template are the
5684: same ones used in matching the original sequence of instructions.
5685:
5686: The result of a defined peephole optimizer does not need to match any of
5687: the instruction patterns, and it does not have an opportunity to match
5688: them. The peephole optimizer definition itself serves as the instruction
5689: pattern to control how the instruction is output.
5690:
5691: Defined peephole optimizers are run in the last jump optimization pass, so
5692: the instructions they produce are never combined or rearranged
5693: automatically in any way.
5694:
5695: Here is an example, taken from the 68000 machine description:
5696:
5697: @example
5698: (define_peephole
5699: [(set (reg:SI 15) (plus:SI (reg:SI 15) (const_int 4)))
5700: (set (match_operand:DF 0 "register_operand" "f")
5701: (match_operand:DF 1 "register_operand" "ad"))]
5702: "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
5703: "*
5704: @{
5705: rtx xoperands[2];
5706: xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
5707: #ifdef MOTOROLA
5708: output_asm_insn (\"move.l %1,(sp)\", xoperands);
5709: output_asm_insn (\"move.l %1,-(sp)\", operands);
5710: return \"fmove.d (sp)+,%0\";
5711: #else
5712: output_asm_insn (\"movel %1,sp@@\", xoperands);
5713: output_asm_insn (\"movel %1,sp@@-\", operands);
5714: return \"fmoved sp@@+,%0\";
5715: #endif
5716: @}
5717: ")
5718: @end example
5719:
5720: The effect of this optimization is to change
5721:
5722: @example
5723: jbsr _foobar
5724: addql #4,sp
5725: movel d1,sp@@-
5726: movel d0,sp@@-
5727: fmoved sp@@+,fp0
5728: @end example
5729:
5730: @noindent
5731: into
5732:
5733: @example
5734: jbsr _foobar
5735: movel d1,sp@@
5736: movel d0,sp@@-
5737: fmoved sp@@+,fp0
5738: @end example
5739:
5740: @node Expander Definitions,, Peephole Definitions, Machine Desc
5741: @section Defining RTL Sequences for Code Generation
5742:
5743: On some target machines, some standard pattern names for RTL generation
5744: cannot be handled with single insn, but a sequence of RTL insns can
5745: represent them. For these target machines, you can write a
5746: @samp{define_expand} to specify how to generate the sequence of RTL.
5747:
5748: A @samp{define_expand} is an RTL expression that looks almost like a
5749: @samp{define_insn}; but, unlike the latter, a @samp{define_expand} is used
5750: only for RTL generation and it can produce more than one RTL insn.
5751:
5752: A @samp{define_expand} RTX has four operands:
5753:
5754: @itemize @bullet
5755: @item
5756: The name. Each @samp{define_expand} must have a name, since the only
5757: use for it is to refer to it by name.
5758:
5759: @item
5760: The RTL template. This is just like the RTL template for a
5761: @samp{define_peephole} in that it is a vector of RTL expressions
5762: each being one insn.
5763:
5764: @item
5765: The condition, a string containing a C expression. This expression is
5766: used to express how the availability of this pattern depends on
5767: subclasses of target machine, selected by command-line options when
5768: GNU CC is run. This is just like the condition of a
5769: @samp{define_insn} that has a standard name.
5770:
5771: @item
5772: The preparation statements, a string containing zero or more C
5773: statements which are to be executed before RTL code is generated from
5774: the RTL template.
5775:
5776: Usually these statements prepare temporary registers for use as
5777: internal operands in the RTL template, but they can also generate RTL
5778: insns directly by calling routines such as @samp{emit_insn}, etc.
5779: Any such insns precede the ones that come from the RTL template.
5780: @end itemize
5781:
5782: The RTL template, in addition to controlling generation of RTL insns,
5783: also describes the operands that need to be specified when this pattern
5784: is used. In particular, it gives a predicate for each operand.
5785:
5786: A true operand, which need to be specified in order to generate RTL from
5787: the pattern, should be described with a @samp{match_operand} in its first
5788: occurrence in the RTL template. This enters information on the operand's
5789: predicate into the tables that record such things. GNU CC uses the
5790: information to preload the operand into a register if that is required for
5791: valid RTL code. If the operand is referred to more than once, subsequent
5792: references should use @samp{match_dup}.
5793:
5794: The RTL template may also refer to internal ``operands'' which are
5795: temporary registers or labels used only within the sequence made by the
5796: @samp{define_expand}. Internal operands are substituted into the RTL
5797: template with @samp{match_dup}, never with @samp{match_operand}. The
5798: values of the internal operands are not passed in as arguments by the
5799: compiler when it requests use of this pattern. Instead, they are computed
5800: within the pattern, in the preparation statements. These statements
5801: compute the values and store them into the appropriate elements of
5802: @code{operands} so that @samp{match_dup} can find them.
5803:
5804: There are two special macros defined for use in the preparation statements:
5805: @code{DONE} and @code{FAIL}. Use them with a following semicolon,
5806: as a statement.
5807:
5808: @table @code
5809: @item DONE
5810: Use the @code{DONE} macro to end RTL generation for the pattern. The
5811: only RTL insns resulting from the pattern on this occasion will be
5812: those already emitted by explicit calls to @code{emit_insn} within the
5813: preparation statements; the RTL template will not be generated.
5814:
5815: @item FAIL
5816: Make the pattern fail on this occasion. When a pattern fails, it means
5817: that the pattern was not truly available. The calling routines in the
5818: compiler will try other strategies for code generation using other patterns.
5819:
5820: Failure is currently supported only for binary operations (addition,
5821: multiplication, shifting, etc.).
5822:
5823: Do not emit any insns explicitly with @code{emit_insn} before failing.
5824: @end table
5825:
5826: Here is an example, the definition of left-shift for the SPUR chip:
5827:
5828: @example
5829: (define_expand "ashlsi3"
5830: [(set (match_operand:SI 0 "register_operand" "")
5831: (ashift:SI
5832: (match_operand:SI 1 "register_operand" "")
5833: (match_operand:SI 2 "nonmemory_operand" "")))]
5834: ""
5835: "
5836: @{
5837: if (GET_CODE (operands[2]) != CONST_INT
5838: || (unsigned) INTVAL (operands[2]) > 3)
5839: FAIL;
5840: @}")
5841: @end example
5842:
5843: @noindent
5844: This example uses @samp{define_expand} so that it can generate an RTL insn
5845: for shifting when the shift-count is in the supported range of 0 to 3 but
5846: fail in other cases where machine insns aren't available. When it fails,
5847: the compiler tries another strategy using different patterns (such as, a
5848: library call).
5849:
5850: If the compiler were able to handle nontrivial condition-strings in
5851: patterns with names, then there would be possible to use a
5852: @samp{define_insn} in that case. Here is another case (zero-extension on
5853: the 68000) which makes more use of the power of @samp{define_expand}:
5854:
5855: @example
5856: (define_expand "zero_extendhisi2"
5857: [(set (match_operand:SI 0 "general_operand" "")
5858: (const_int 0))
5859: (set (strict_low_part
5860: (subreg:HI
5861: (match_operand:SI 0 "general_operand" "")
5862: 0))
5863: (match_operand:HI 1 "general_operand" ""))]
5864: ""
5865: "operands[1] = make_safe_from (operands[1], operands[0]);")
5866: @end example
5867:
5868: @noindent
5869: Here two RTL insns are generated, one to clear the entire output operand
5870: and the other to copy the input operand into its low half. This sequence
5871: is incorrect if the input operand refers to [the old value of] the output
5872: operand, so the preparation statement makes sure this isn't so. The
5873: function @code{make_safe_from} copies the @code{operands[1]} into a
5874: temporary register if it refers to @code{operands[0]}. It does this
5875: by emitting another RTL insn.
5876:
5877: Finally, a third example shows the use of an internal operand.
5878: Zero-extension on the SPUR chip is done by @samp{and}-ing the result
5879: against a halfword mask. But this mask cannot be represented by a
5880: @samp{const_int} because the constant value is too large to be legitimate
5881: on this machine. So it must be copied into a register with
5882: @code{force_reg} and then the register used in the @samp{and}.
5883:
5884: @example
5885: (define_expand "zero_extendhisi2"
5886: [(set (match_operand:SI 0 "register_operand" "")
5887: (and:SI (subreg:SI
5888: (match_operand:HI 1 "register_operand" "")
5889: 0)
5890: (match_dup 2)))]
5891: ""
5892: "operands[2]
5893: = force_reg (SImode, gen_rtx (CONST_INT,
5894: VOIDmode, 65535)); ")
5895: @end example
5896:
5897: @node Machine Macros, Config, Machine Desc, Top
1.1 root 5898: @chapter Machine Description Macros
5899:
5900: The other half of the machine description is a C header file conventionally
5901: given the name @file{tm-@var{machine}.h}. The file @file{tm.h} should be a
5902: link to it. The header file @file{config.h} includes @file{tm.h} and most
5903: compiler source files include @file{config.h}.
5904:
5905: @menu
1.1.1.2 root 5906: * Run-time Target:: Defining -m options like -m68000 and -m68020.
1.1 root 5907: * Storage Layout:: Defining sizes and alignments of data types.
5908: * Registers:: Naming and describing the hardware registers.
5909: * Register Classes:: Defining the classes of hardware registers.
5910: * Stack Layout:: Defining which way the stack grows and by how much.
1.1.1.2 root 5911: * Library Names:: Specifying names of subroutines to call automatically.
1.1 root 5912: * Addressing Modes:: Defining addressing modes valid for memory operands.
5913: * Condition Code:: Defining how insns update the condition code.
5914: * Assembler Format:: Defining how to write insns and pseudo-ops to output.
5915: * Misc:: Everything else.
5916: @end menu
5917:
5918: @node Run-time Target, Storage Layout, Machine Macros, Machine Macros
5919: @section Run-time Target Specification
5920:
5921: @table @code
5922: @item CPP_PREDEFINES
1.1.1.7 root 5923: Define this to be a string constant containing @samp{-D} options to
5924: define the predefined macros that identify this machine and system.
5925: These macros will be predefined unless the @samp{-ansi} option is
5926: specified.
1.1 root 5927:
5928: For example, on the Sun, one can use the value
5929:
5930: @example
1.1.1.2 root 5931: "-Dmc68000 -Dsun -Dunix"
1.1 root 5932: @end example
5933:
1.1.1.7 root 5934: @item CPP_SPEC
5935: A C string constant that tells the GNU CC driver program options to
5936: pass to CPP. It can also specify how to translate options you
5937: give to GNU CC into options for GNU CC to pass to the CPP.
5938:
5939: Do not define this macro if it does not need to do anything.
5940:
5941: @item CC1_SPEC
5942: A C string constant that tells the GNU CC driver program options to
5943: pass to CC1. It can also specify how to translate options you
5944: give to GNU CC into options for GNU CC to pass to the CC1.
5945:
5946: Do not define this macro if it does not need to do anything.
5947:
1.1 root 5948: @item extern int target_flags;
5949: This declaration should be present.
5950:
5951: @item TARGET_@dots{}
5952: This series of macros is to allow compiler command arguments to
5953: enable or disable the use of optional features of the target machine.
5954: For example, one machine description serves both the 68000 and
5955: the 68020; a command argument tells the compiler whether it should
5956: use 68020-only instructions or not. This command argument works
5957: by means of a macro @code{TARGET_68020} that tests a bit in
5958: @code{target_flags}.
5959:
5960: Define a macro @code{TARGET_@var{featurename}} for each such option.
5961: Its definition should test a bit in @code{target_flags}; for example:
5962:
5963: @example
5964: #define TARGET_68020 (target_flags & 1)
5965: @end example
5966:
5967: One place where these macros are used is in the condition-expressions
5968: of instruction patterns. Note how @code{TARGET_68020} appears
1.1.1.2 root 5969: frequently in the 68000 machine description file, @file{m68k.md}.
1.1 root 5970: Another place they are used is in the definitions of the other
5971: macros in the @file{tm-@var{machine}.h} file.
5972:
5973: @item TARGET_SWITCHES
1.1.1.2 root 5974: This macro defines names of command options to set and clear
1.1 root 5975: bits in @code{target_flags}. Its definition is an initializer
1.1.1.2 root 5976: with a subgrouping for each command option.
1.1 root 5977:
1.1.1.2 root 5978: Each subgrouping contains a string constant, that defines the option
1.1 root 5979: name, and a number, which contains the bits to set in
5980: @code{target_flags}. A negative number says to clear bits instead;
1.1.1.2 root 5981: the negative of the number is which bits to clear. The actual option
1.1 root 5982: name is made by appending @samp{-m} to the specified name.
5983:
5984: One of the subgroupings should have a null string. The number in
5985: this grouping is the default value for @code{target_flags}. Any
1.1.1.2 root 5986: target options act starting with that value.
1.1 root 5987:
5988: Here is an example which defines @samp{-m68000} and @samp{-m68020}
5989: with opposite meanings, and picks the latter as the default:
5990:
5991: @example
5992: #define TARGET_SWITCHES \
5993: @{ @{ "68020", 1@}, \
5994: @{ "68000", -1@}, \
5995: @{ "", 1@}@}
5996: @end example
5997:
1.1.1.7 root 5998: @item OVERRIDE_OPTIONS
5999: Sometimes certain combinations of command options do not make sense on
6000: a particular target machine. You can define a macro
6001: @code{OVERRIDE_OPTIONS} to take account of this. This macro, if
6002: defined, is executed once just after all the command options have been
6003: parsed.
6004: @end table
1.1.1.2 root 6005:
1.1 root 6006: @node Storage Layout, Registers, Run-time Target, Machine Macros
6007: @section Storage Layout
6008:
1.1.1.2 root 6009: Note that the definitions of the macros in this table which are sizes or
6010: alignments measured in bits do not need to be constant. They can be C
6011: expressions that refer to static variables, such as the @code{target_flags}.
6012: @xref{Run-time Target}.
6013:
1.1 root 6014: @table @code
6015: @item BITS_BIG_ENDIAN
6016: Define this macro if the most significant bit in a byte has the lowest
6017: number. This means that bit-field instructions count from the most
6018: significant bit. If the machine has no bit-field instructions, this
6019: macro is irrelevant.
6020:
6021: @item BYTES_BIG_ENDIAN
6022: Define this macro if the most significant byte in a word has the
6023: lowest number.
6024:
6025: @item WORDS_BIG_ENDIAN
1.1.1.2 root 6026: Define this macro if, in a multiword object, the most significant
1.1 root 6027: word has the lowest number.
6028:
6029: @item BITS_PER_UNIT
6030: Number of bits in an addressable storage unit (byte); normally 8.
6031:
6032: @item BITS_PER_WORD
6033: Number of bits in a word; normally 32.
6034:
6035: @item UNITS_PER_WORD
6036: Number of storage units in a word; normally 4.
6037:
6038: @item POINTER_SIZE
6039: Width of a pointer, in bits.
6040:
1.1.1.7 root 6041: @item POINTER_BOUNDARY
6042: Alignment required for pointers stored in memory, in bits.
6043:
1.1 root 6044: @item PARM_BOUNDARY
1.1.1.2 root 6045: Alignment required for function parameters on the stack, in bits.
6046:
6047: @item STACK_BOUNDARY
6048: Define this macro if you wish to preserve a certain alignment for
6049: the stack pointer at all times. The definition is a C expression
6050: for the desired alignment (measured in bits).
1.1 root 6051:
6052: @item FUNCTION_BOUNDARY
6053: Alignment required for a function entry point, in bits.
6054:
6055: @item BIGGEST_ALIGNMENT
1.1.1.2 root 6056: Biggest alignment that any data type can require on this machine, in bits.
6057:
1.1.1.7 root 6058: @item EMPTY_FIELD_BOUNDARY
1.1.1.2 root 6059: Alignment in bits to be given to a structure bit field that follows an
6060: empty field such as @code{int : 0;}.
6061:
6062: @item STRUCTURE_SIZE_BOUNDARY
6063: Number of bits which any structure or union's size must be a multiple of.
6064: Each structure or union's size is rounded up to a multiple of this.
6065:
6066: If you do not define this macro, the default is the same as
6067: @code{BITS_PER_UNIT}.
1.1 root 6068:
6069: @item STRICT_ALIGNMENT
6070: Define this if instructions will fail to work if given data not
6071: on the nominal alignment. If instructions will merely go slower
6072: in that case, do not define this macro.
1.1.1.4 root 6073:
1.1.1.6 root 6074: @item PCC_BITFIELD_TYPE_MATTERS
6075: Define this if you wish to imitate a certain bizarre behavior pattern
6076: of some instances of PCC: a bit field whose declared type is
6077: @code{int} has the same effect on the size and alignment of a
6078: structure as an actual @code{int} would have.
6079:
6080: Just what effect that is in GNU CC depends on other parameters, but on
6081: most machines it would force the structure's alignment and size to a
6082: multiple of 32 or @code{BIGGEST_ALIGNMENT} bits.
6083:
1.1.1.4 root 6084: @item CHECK_FLOAT_VALUE (@var{mode}, @var{value})
6085: A C statement to validate the value @var{value} (or type
6086: @code{double}) for mode @var{mode}. This means that you check whether
6087: @var{value} fits within the possible range of values for mode
6088: @var{mode} on this target machine. The mode @var{mode} is always
6089: @code{SFmode} or @code{DFmode}.
6090:
6091: If @var{value} is not valid, you should call @code{error} to print an
6092: error message and then assign some valid value to @var{value}.
6093: Allowing an invalid value to go through the compiler can produce
6094: incorrect assembler code which may even cause Unix assemblers to
6095: crash.
6096:
6097: This macro need not be defined if there is no work for it to do.
1.1 root 6098: @end table
6099:
6100: @node Registers, Register Classes, Storage Layout, Machine Macros
6101: @section Register Usage
6102:
6103: @table @code
6104: @item FIRST_PSEUDO_REGISTER
6105: Number of hardware registers known to the compiler. They receive
6106: numbers 0 through @code{FIRST_PSEUDO_REGISTER-1}; thus, the first
1.1.1.2 root 6107: pseudo register's number really is assigned the number
1.1 root 6108: @code{FIRST_PSEUDO_REGISTER}.
6109:
6110: @item FIXED_REGISTERS
6111: An initializer that says which registers are used for fixed purposes
6112: all throughout the compiled code and are therefore not available for
1.1.1.2 root 6113: general allocation. These would include the stack pointer, the frame
1.1.1.7 root 6114: pointer (except on machines where that can be used as a general
6115: register when no frame pointer is needed), the program counter on
6116: machines where that is considered one of the addressable registers,
6117: and any other numbered register with a standard use.
1.1 root 6118:
6119: This information is expressed as a sequence of numbers, separated by
6120: commas and surrounded by braces. The @var{n}th number is 1 if
1.1.1.2 root 6121: register @var{n} is fixed, 0 otherwise.
6122:
6123: The table initialized from this macro, and the table initialized by
6124: the following one, may be overridden at run time either automatically,
6125: by the actions of the macro @code{CONDITIONAL_REGISTER_USAGE}, or by
6126: the user with the command options @samp{-ffixed-@var{reg}},
6127: @samp{-fcall-used-@var{reg}} and @samp{-fcall-saved-@var{reg}}.
1.1 root 6128:
6129: @item CALL_USED_REGISTERS
6130: Like @code{FIXED_REGISTERS} but has 1 for each register that is
6131: clobbered (in general) by function calls as well as for fixed
6132: registers. This macro therefore identifies the registers that are not
6133: available for general allocation of values that must live across
6134: function calls.
6135:
1.1.1.2 root 6136: If a register has 0 in @code{CALL_USED_REGISTERS}, the compiler
1.1 root 6137: automatically saves it on function entry and restores it on function
6138: exit, if the register is used within the function.
6139:
1.1.1.2 root 6140: @item CONDITIONAL_REGISTER_USAGE
6141: Zero or more C statements that may conditionally modify two variables
6142: @code{fixed_regs} and @code{call_used_regs} (both of type @code{char
6143: []}) after they have been initialized from the two preceding macros.
6144:
6145: This is necessary in case the fixed or call-clobbered registers depend
6146: on target flags.
6147:
6148: You need not define this macro if it has no work to do.
6149:
1.1.1.7 root 6150: If the usage of an entire class of registers depends on the target
6151: flags, you may indicate this to gcc by using this macro to modify
6152: @code{fixed_regs} and @code{call_used_regs} to 1 for each of the
6153: registers in the classes which should not be used by gcc. Also define
6154: the macro @code{REG_CLASS_FROM_LETTER} to return @code{NO_REGS} if it
6155: is called with a letter for a class that shouldn't be used.
6156:
6157: (However, if this class is not included in @code{GENERAL_REGS} and all
6158: of the insn patterns whose constraints permit this class are
6159: controlled by target switches, then GCC will automatically avoid using
6160: these registers when the target switches are opposed to them.)
6161:
1.1.1.4 root 6162: @item OVERLAPPING_REGNO_P (@var{regno})
6163: If defined, this is a C expression whose value is @var{regno} is
6164: nonzero if hard register number @var{regno} is an overlapping
6165: register. This means a hard register which overlaps a hard register
6166: with a different number. (Such overlap is undesirable, but
6167: occasionally it allows a machine to be supported which otherwise could
6168: not be.) This macro must return nonzero for @emph{all} the registers
6169: which overlap each other. GNU CC can use an overlapping register only
6170: in certain limited ways. It can be used for allocation within a basic
6171: block, and may be spilled for reloading; that is all.
6172:
6173: If this macro is not defined, it means that none of the hard registers
6174: overlap each other. This is the usual situation.
6175:
6176: @item INSN_CLOBBERS_REGNO_P (@var{insn}, @var{regno})
6177: If defined, this is a C expression whose value should be nonzero if
6178: the insn @var{insn} has the effect of mysteriously clobbering the
6179: contents of hard register number @var{regno}. By ``mysterious'' we
6180: mean that the insn's RTL expression doesn't describe such an effect.
6181:
6182: If this macro is not defined, it means that no insn clobbers registers
6183: mysteriously. This is the usual situation; all else being equal,
6184: it is best for the RTL expression to show all the activity.
6185:
6186: @item PRESERVE_DEATH_INFO_REGNO_P (@var{regno})
6187: If defined, this is a C expression whose value is nonzero if accurate
6188: @code{REG_DEAD} notes are needed for hard register number @var{regno}
6189: at the time of outputting the assembler code. When this is so, a few
6190: optimizations that take place after register allocation and could
6191: invalidate the death notes are not done when this register is
6192: involved.
6193:
6194: You would arrange to preserve death info for a register when some
6195: of the code in the machine description which is executed to write
6196: the assembler code looks at the the death notes. This is
6197: necessary only when the actual hardware feature which GNU CC
6198: thinks of as a register is not actually a register of the usual sort.
6199: (It might, for example, be a hardware stack.)
6200:
6201: If this macro is not defined, it means that no death notes need to be
6202: preserved. This is the usual situation.
6203:
1.1 root 6204: @item HARD_REGNO_REGS (@var{regno}, @var{mode})
6205: A C expression for the number of consecutive hard registers, starting
6206: at register number @var{regno}, required to hold a value of mode
6207: @var{mode}.
6208:
6209: On a machine where all registers are exactly one word, a suitable
6210: definition of this macro is
6211:
6212: @example
6213: #define HARD_REGNO_NREGS(REGNO, MODE) \
6214: ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \
6215: / UNITS_PER_WORD))
6216: @end example
6217:
6218: @item HARD_REGNO_MODE_OK (@var{regno}, @var{mode})
6219: A C expression that is nonzero if it is permissible to store a value
6220: of mode @var{mode} in hard register number @var{regno} (or in several
6221: registers starting with that one). For a machine where all registers
6222: are equivalent, a suitable definition is
6223:
6224: @example
6225: #define HARD_REGNO_MODE_OK(REGNO, MODE) 1
6226: @end example
6227:
6228: It is not necessary for this macro to check for fixed register numbers
6229: because the allocation mechanism considers them to be always occupied.
6230:
1.1.1.2 root 6231: Many machines have special registers for floating point arithmetic.
6232: Often people assume that floating point machine modes are allowed only
6233: in floating point registers. This is not true. Any registers that
6234: can hold integers can safely @emph{hold} a floating point machine
6235: mode, whether or not floating arithmetic can be done on it in those
6236: registers.
6237:
6238: The true significance of special floating registers is rather than
6239: non-floating-point machine modes @emph{may not} go in those registers.
6240: This is true if the floating registers normalize any value stored in
6241: them, because storing a non-floating value there would garble it. If
6242: the floating registers do not automatically normalize, if you can
6243: store any bit pattern in one and retrieve it unchanged without a trap,
6244: then any machine mode may go in a floating register and this macro
6245: should say so.
6246:
6247: Sometimes there are floating registers that are especially slow to
6248: access, so that it is better to store a value in a stack frame than in
6249: such a register if floating point arithmetic is not being done. As long
6250: as the floating registers are not in class @code{GENERAL_REGS}, they
6251: will not be used unless some insn's constraint asks for one.
6252:
6253: It is obligatory to support floating point `move' instructions into
6254: and out of general registers, because unions and structures (which
6255: have modes @samp{SImode} or @samp{DImode}) can be in those registers
6256: and they may have floating point members.
6257:
1.1 root 6258: @item MODES_TIEABLE_P (@var{mode1}, @var{mode2})
6259: A C expression that is nonzero if it is desirable to choose register
6260: allocation so as to avoid move instructions between a value of mode
6261: @var{mode1} and a value of mode @var{mode2}.
6262:
6263: If @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode1})} and
6264: @code{HARD_REGNO_MODE_OK (@var{r}, @var{mode2})} are ever different
6265: for any @var{r}, then @code{MODES_TIEABLE_P (@var{mode1},
6266: @var{mode2})} must be zero.
6267:
6268: @item PC_REGNUM
6269: If the program counter has a register number, define this as that
6270: register number. Otherwise, do not define it.
6271:
6272: @item STACK_POINTER_REGNUM
6273: The register number of the stack pointer register, which must also be
6274: a fixed register according to @code{FIXED_REGISTERS}. On many
6275: machines, the hardware determines which register this is.
6276:
6277: @item FRAME_POINTER_REGNUM
6278: The register number of the frame pointer register, which is used to
1.1.1.2 root 6279: access automatic variables in the stack frame. On some machines, the
1.1 root 6280: hardware determines which register this is. On other machines, you
6281: can choose any register you wish for this purpose.
6282:
1.1.1.2 root 6283: @item FRAME_POINTER_REQUIRED
6284: A C expression which is nonzero if a function must have and use a
6285: frame pointer. This expression is evaluated in the reload pass, in
6286: the function @code{reload}, and it can in principle examine the
6287: current function and decide according to the facts, but on most
6288: machines the constant 0 or the constant 1 suffices. Use 0 when the
6289: machine allows code to be generated with no frame pointer, and doing
6290: so saves some time or space. Use 1 when there is no possible
6291: advantage to avoiding a frame pointer.
6292:
6293: In certain cases, the compiler does not know how to do without a frame
6294: pointer. The compiler recognizes those cases and automatically gives
6295: the function a frame pointer regardless of what
6296: @code{FRAME_POINTER_REQUIRED} says. You don't need to worry about
6297: them.@refill
6298:
6299: In a function that does not require a frame pointer, the frame pointer
1.1.1.4 root 6300: register can be allocated for ordinary usage, unless you mark it as a
6301: fixed register. See @code{FIXED_REGISTERS} for more information.
1.1.1.2 root 6302:
1.1 root 6303: @item ARG_POINTER_REGNUM
6304: The register number of the arg pointer register, which is used to
6305: access the function's argument list. On some machines, this is the
6306: same as the frame pointer register. On some machines, the hardware
6307: determines which register this is. On other machines, you can choose
1.1.1.4 root 6308: any register you wish for this purpose. If this is not the same
6309: register as the frame pointer register, then you must mark it as a
1.1 root 6310: fixed register according to @code{FIXED_REGISTERS}.
6311:
6312: @item STATIC_CHAIN_REGNUM
6313: The register number used for passing a function's static chain
6314: pointer. This is needed for languages such as Pascal and Algol where
6315: functions defined within other functions can access the local
6316: variables of the outer functions; it is not currently used because C
1.1.1.7 root 6317: does not provide this feature, but you must define the macro.
1.1 root 6318:
6319: The static chain register need not be a fixed register.
6320:
6321: @item STRUCT_VALUE_REGNUM
1.1.1.2 root 6322: When a function's value's mode is @code{BLKmode}, the value is not
6323: returned according to @code{FUNCTION_VALUE}. Instead, the caller
6324: passes the address of a block of memory in which the value should be
1.1.1.6 root 6325: stored.
6326:
6327: If this value is passed in a register, then @code{STRUCT_VALUE_REGNUM}
6328: should be the number of that register.
6329:
6330: @item STRUCT_VALUE
6331: If the structure value address is not passed in a register, define
6332: @code{STRUCT_VALUE} as an expression returning an RTX for the place
6333: where the address is passed. If it returns a @samp{mem} RTX, the
6334: address is passed as an ``invisible'' first argument.
6335:
6336: @item STRUCT_VALUE_INCOMING_REGNUM
6337: On some architectures the place where the structure value address
6338: is found by the called function is not the same place that the
6339: caller put it. This can be due to register windows, or it could
6340: be because the function prologue moves it to a different place.
6341:
6342: If the incoming location of the structure value address is in a
6343: register, define this macro as the register number.
6344:
6345: @item STRUCT_VALUE_INCOMING
6346: If the incoming location is not a register, define
6347: @code{STRUCT_VALUE_INCOMING} as an expression for an RTX for where the
6348: called function should find the value. If it should find the value on
6349: the stack, define this to create a @samp{mem} which refers to the
6350: frame pointer. If the value is a @samp{mem}, the compiler assumes it
6351: is for an invisible first argument, and leaves space for it when
6352: finding the first real argument.
1.1.1.5 root 6353:
6354: @item REG_ALLOC_ORDER
6355: If defined, an initializer for a vector of integers, containing the
6356: numbers of hard registers in the order in which the GNU CC should
6357: prefer to use them (from most preferred to least).
6358:
6359: If this macro is not defined, registers are used lowest numbered first
6360: (all else being equal).
6361:
6362: One use of this macro is on the 360, where the highest numbered
6363: registers must always be saved and the save-multiple-registers
6364: instruction supports only sequences of consecutive registers. This
6365: macro is defined to cause the highest numbered allocatable registers
6366: to be used first.
1.1 root 6367: @end table
6368:
6369: @node Register Classes, Stack Layout, Registers, Machine Macros
6370: @section Register Classes
6371:
6372: On many machines, the numbered registers are not all equivalent.
6373: For example, certain registers may not be allowed for indexed addressing;
6374: certain registers may not be allowed in some instructions. These machine
6375: restrictions are described to the compiler using @dfn{register classes}.
6376:
6377: You define a number of register classes, giving each one a name and saying
6378: which of the registers belong to it. Then you can specify register classes
6379: that are allowed as operands to particular instruction patterns.
6380:
6381: In general, each register will belong to several classes. In fact, one
6382: class must be named @code{ALL_REGS} and contain all the registers. Another
6383: class must be named @code{NO_REGS} and contain no registers. Often the
6384: union of two classes will be another class; however, this is not required.
6385:
6386: One of the classes must be named @code{GENERAL_REGS}. There is nothing
6387: terribly special about the name, but the operand constraint letters
6388: @samp{r} and @samp{g} specify this class. If @code{GENERAL_REGS} is
6389: the same as @code{ALL_REGS}, just define it as a macro which expands
6390: to @code{ALL_REGS}.
6391:
6392: The way classes other than @code{GENERAL_REGS} are specified in operand
6393: constraints is through machine-dependent operand constraint letters.
6394: You can define such letters to correspond to various classes, then use
6395: them in operand constraints.
6396:
1.1.1.2 root 6397: You should define a class for the union of two classes whenever some
6398: instruction allows both classes. For example, if an instruction allows
6399: either a floating-point (coprocessor) register or a general register for a
6400: certain operand, you should define a class @code{FLOAT_OR_GENERAL_REGS}
6401: which includes both of them. Otherwise you will get suboptimal code.
6402:
1.1 root 6403: You must also specify certain redundant information about the register
6404: classes: for each class, which classes contain it and which ones are
6405: contained in it; for each pair of classes, the largest class contained
6406: in their union.
6407:
1.1.1.8 root 6408: Register classes used for input-operands of bitwise-and or shift
6409: instructions have a special requirement: each such class must have, for
6410: each fixed-point machine mode, a subclass whose registers can transfer that
6411: mode to or from memory. For example, on some machines, the operations for
6412: single-byte values (@code{QImode}) are limited to certain registers. When
6413: this is so, each register class that is used in a bitwise-and or shift
6414: instruction must have a subclass consisting of registers from which
6415: single-byte values can be loaded or stored. This is so that
6416: @code{PREFERRED_RELOAD_CLASS} can always have a possible value to return.
6417:
1.1 root 6418: @table @code
6419: @item enum reg_class
6420: An enumeral type that must be defined with all the register class names
6421: as enumeral values. @code{NO_REGS} must be first. @code{ALL_REGS}
6422: must be the last register class, followed by one more enumeral value,
6423: @code{LIM_REG_CLASSES}, which is not a register class but rather
6424: tells how many classes there are.
6425:
6426: Each register class has a number, which is the value of casting
6427: the class name to type @code{int}. The number serves as an index
6428: in many of the tables described below.
6429:
1.1.1.7 root 6430: @item N_REG_CLASSES
6431: The number of distinct register classes, defined as follows:
6432:
6433: @example
6434: #define N_REG_CLASSES (int) LIM_REG_CLASSES
6435: @end example
6436:
1.1 root 6437: @item REG_CLASS_NAMES
6438: An initializer containing the names of the register classes as C string
6439: constants. These names are used in writing some of the debugging dumps.
6440:
6441: @item REG_CLASS_CONTENTS
6442: An initializer containing the contents of the register classes, as integers
6443: which are bit masks. The @var{n}th integer specifies the contents of class
6444: @var{n}. The way the integer @var{mask} is interpreted is that
6445: register @var{r} is in the class if @code{@var{mask} & (1 << @var{r})} is 1.
6446:
6447: When the machine has more than 32 registers, an integer does not suffice.
6448: Then the integers are replaced by sub-initializers, braced groupings containing
6449: several integers. Each sub-initializer must be suitable as an initializer
6450: for the type @code{HARD_REG_SET} which is defined in @file{hard-reg-set.h}.
6451:
6452: @item REGNO_REG_CLASS (@var{regno})
6453: A C expression whose value is a register class containing hard register
6454: @var{regno}. In general there is more that one such class; choose a class
6455: which is @dfn{minimal}, meaning that no smaller class also contains the
6456: register.
6457:
1.1.1.7 root 6458: @item BASE_REG_CLASS
6459: A macro whose definition is the name of the class to which a valid
6460: base register must belong. A base register is one used in an address
6461: which is the register value plus a displacement.
6462:
1.1 root 6463: @item INDEX_REG_CLASS
1.1.1.7 root 6464: A macro whose definition is the name of the class to which a valid
6465: index register must belong. An index register is one used in an
6466: address where its value is either multiplied by a scale factor or
6467: added to another register (as well as added to a displacement).
1.1 root 6468:
6469: @item REG_CLASS_FROM_LETTER (@var{char})
6470: A C expression which defines the machine-dependent operand constraint
1.1.1.7 root 6471: letters for register classes. If @var{char} is such a letter, the
6472: value should be the register class corresponding to it. Otherwise,
6473: the value should be @code{NO_REGS}.
1.1 root 6474:
1.1.1.2 root 6475: @item REGNO_OK_FOR_BASE_P (@var{num})
6476: A C expression which is nonzero if register number @var{num} is
6477: suitable for use as a base register in operand addresses. It may be
6478: either a suitable hard register or a pseudo register that has been
6479: allocated such a hard register.
6480:
6481: @item REGNO_OK_FOR_INDEX_P (@var{num})
6482: A C expression which is nonzero if register number @var{num} is
6483: suitable for use as an index register in operand addresses. It may be
6484: either a suitable hard register or a pseudo register that has been
6485: allocated such a hard register.
6486:
6487: The difference between an index register and a base register is that
6488: the index register may be scaled. If an address involves the sum of
6489: two registers, neither one of them scaled, then either one may be
6490: labeled the ``base'' and the other the ``index''; but whichever
6491: labeling is used must fit the machine's constraints of which registers
6492: may serve in each capacity. The compiler will try both labelings,
1.1.1.7 root 6493: looking for one that is valid, and will reload one or both registers
6494: only if neither labeling works.
1.1 root 6495:
6496: @item PREFERRED_RELOAD_CLASS (@var{x}, @var{class})
6497: A C expression that places additional restrictions on the register class
6498: to use when it is necessary to copy value @var{x} into a register in class
6499: @var{class}. The value is a register class; perhaps @var{class}, or perhaps
1.1.1.8 root 6500: another, smaller class. On many machines, the definition
1.1 root 6501:
6502: @example
6503: #define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
6504: @end example
6505:
6506: @noindent
1.1.1.8 root 6507: is safe.
6508:
6509: Sometimes returning a more restrictive class makes better code. For
6510: example, on the 68000, when @var{x} is an integer constant that is in range
6511: for a @samp{moveq} instruction, the value of this macro is always
6512: @code{DATA_REGS} as long as @var{class} includes the data registers.
6513: Requiring a data register guarantees that a @samp{moveq} will be used.
1.1.1.2 root 6514:
1.1.1.6 root 6515: If @var{x} is a @samp{const_double}, by returning @code{NO_REGS}
6516: you can force @var{x} into a memory constant. This is useful on
6517: certain machines where immediate floating values cannot be loaded into
6518: certain kinds of registers.
6519:
1.1.1.8 root 6520: In a shift instruction or a bitwise-and instruction, the mode of @var{x},
6521: the value being reloaded, may not be the same as the mode of the
6522: instruction's operand. (They will both be fixed-point modes, however.) In
6523: such a case, @var{class} may not be a safe value to return. @var{class} is
6524: certainly valid for the instruction, but it may not be valid for reloading
6525: @var{x}. This problem can occur on machines such as the 68000 and 80386
6526: where some registers can handle full-word values but cannot handle
6527: single-byte values.
6528:
6529: On such machines, this macro must examine the mode of @var{x} and return a
6530: subclass of @var{class} which can handle loads and stores of that mode. On
6531: the 68000, where address registers cannot handle @code{QImode}, if @var{x}
6532: has @code{QImode} then you must return @code{DATA_REGS}. If @var{class} is
6533: @code{ADDR_REGS}, then there is no correct value to return; but the shift
6534: and bitwise-and instructions don't use @code{ADDR_REGS}, so this fatal case
6535: never arises.
6536:
1.1.1.2 root 6537: @item CLASS_MAX_NREGS (@var{class}, @var{mode})
6538: A C expression for the maximum number of consecutive registers
6539: of class @var{class} needed to hold a value of mode @var{mode}.
6540:
6541: This is closely related to the macro @code{HARD_REGNO_NREGS}.
6542: In fact, the value of the macro @code{CLASS_MAX_NREGS (@var{class}, @var{mode})}
6543: should be the maximum value of @code{HARD_REGNO_NREGS (@var{regno}, @var{mode})}
6544: for all @var{regno} values in the class @var{class}.
6545:
6546: This macro helps control the handling of multiple-word values
6547: in the reload pass.
1.1 root 6548: @end table
6549:
1.1.1.2 root 6550: Two other special macros describe which constants fit which constraint
6551: letters.
1.1 root 6552:
6553: @table @code
6554: @item CONST_OK_FOR_LETTER_P (@var{value}, @var{c})
6555: A C expression that defines the machine-dependent operand constraint letters
6556: that specify particular ranges of integer values. If @var{c} is one
6557: of those letters, the expression should check that @var{value}, an integer,
6558: is in the appropriate range and return 1 if so, 0 otherwise. If @var{c} is
6559: not one of those letters, the value should be 0 regardless of @var{value}.
6560:
6561: @item CONST_DOUBLE_OK_FOR_LETTER_P (@var{value}, @var{c})
6562: A C expression that defines the machine-dependent operand constraint
6563: letters that specify particular ranges of floating values. If @var{c} is
1.1.1.2 root 6564: one of those letters, the expression should check that @var{value}, an RTX
1.1 root 6565: of code @samp{const_double}, is in the appropriate range and return 1 if
6566: so, 0 otherwise. If @var{c} is not one of those letters, the value should
6567: be 0 regardless of @var{value}.
6568: @end table
6569:
1.1.1.2 root 6570: @node Stack Layout, Library Names, Register Classes, Machine Macros
1.1 root 6571: @section Describing Stack Layout
6572:
6573: @table @code
6574: @item STACK_GROWS_DOWNWARD
6575: Define this macro if pushing a word onto the stack moves the stack
1.1.1.2 root 6576: pointer to a smaller address.
6577:
6578: When we say, ``define this macro if @dots{},'' it means that the
6579: compiler checks this macro only with @code{#ifdef} so the precise
6580: definition used does not matter.
1.1 root 6581:
6582: @item FRAME_GROWS_DOWNWARD
6583: Define this macro if the addresses of local variable slots are at negative
6584: offsets from the frame pointer.
6585:
6586: @item STARTING_FRAME_OFFSET
6587: Offset from the frame pointer to the first local variable slot to be allocated.
6588:
6589: If @code{FRAME_GROWS_DOWNWARD}, the next slot's offset is found by
6590: subtracting the length of the first slot from @code{STARTING_FRAME_OFFSET}.
6591: Otherwise, it is found by adding the length of the first slot to
6592: the value @code{STARTING_FRAME_OFFSET}.
6593:
6594: @item PUSH_ROUNDING (@var{npushed})
6595: A C expression that is the number of bytes actually pushed onto the
6596: stack when an instruction attempts to push @var{npushed} bytes.
6597:
1.1.1.2 root 6598: If the target machine does not have a push instruction, do not define
6599: this macro. That directs GNU CC to use an alternate strategy: to
6600: allocate the entire argument block and then store the arguments into
6601: it.
6602:
1.1 root 6603: On some machines, the definition
6604:
6605: @example
6606: #define PUSH_ROUNDING(BYTES) (BYTES)
6607: @end example
6608:
6609: @noindent
6610: will suffice. But on other machines, instructions that appear
6611: to push one byte actually push two bytes in an attempt to maintain
6612: alignment. Then the definition should be
6613:
6614: @example
6615: #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
6616: @end example
6617:
1.1.1.8 root 6618: @item FIRST_PARM_OFFSET (@var{fundecl})
6619: Offset from the argument pointer register to the first argument's
6620: address. On some machines it may depend on the data type of the
6621: function. (In the next version of GNU CC, the argument will be
6622: changed to the function data type rather than its declaration.)
1.1 root 6623:
1.1.1.9 ! root 6624: @item FIRST_PARM_CALLER_OFFSET (@var{fundecl})
! 6625: Define this macro on machines where register parameters have shadow
! 6626: locations on the stack, at addresses below the nominal parameter.
! 6627: This matters because certain arguments cannot be passed on the stack.
! 6628: On these machines, such arguments must be stored into the shadow
! 6629: locations.
! 6630:
! 6631: This macro should expand into a C expression whose value is the offset
! 6632: of the first parameter's shadow location from the nominal stack
! 6633: pointer value. (That value is itself computed by adding the value of
! 6634: @code{STACK_POINTER_OFFSET} to the stack pointer register.)
! 6635:
1.1.1.2 root 6636: @item RETURN_POPS_ARGS (@var{funtype})
6637: A C expression that should be 1 if a function pops its own arguments
6638: on returning, or 0 if the function pops no arguments and the caller
6639: must therefore pop them all after the function returns.
6640:
6641: @var{funtype} is a C variable whose value is a tree node that
6642: describes the function in question. Normally it is a node of type
6643: @code{FUNCTION_TYPE} that describes the data type of the function.
6644: From this it is possible to obtain the data types of the value and
6645: arguments (if known).
6646:
6647: When a call to a library function is being considered, @var{funtype}
6648: will contain an identifier node for the library function. Thus, if
6649: you need to distinguish among various library functions, you can do so
6650: by their names. Note that ``library function'' in this context means
6651: a function used to perform arithmetic, whose name is known specially
6652: in the compiler and was not mentioned in the C code being compiled.
6653:
6654: On the Vax, all functions always pop their arguments, so the
6655: definition of this macro is 1. On the 68000, using the standard
6656: calling convention, no functions pop their arguments, so the value of
6657: the macro is always 0 in this case. But an alternative calling
6658: convention is available in which functions that take a fixed number of
6659: arguments pop them but other functions (such as @code{printf}) pop
6660: nothing (the caller pops all). When this convention is in use,
6661: @var{funtype} is examined to determine whether a function takes a
6662: fixed number of arguments.
6663:
6664: @item FUNCTION_VALUE (@var{valtype}, @var{func})
6665: A C expression to create an RTX representing the place where a
6666: function returns a value of data type @var{valtype}. @var{valtype} is
6667: a tree node representing a data type. Write @code{TYPE_MODE
6668: (@var{valtype})} to get the machine mode used to represent that type.
6669: On many machines, only the mode is relevant. (Actually, on most
6670: machines, scalar values are returned in the same place regardless of
6671: mode).@refill
6672:
6673: If the precise function being called is known, @var{func} is a tree
6674: node (@code{FUNCTION_DECL}) for it; otherwise, @var{func} is a null
6675: pointer. This makes it possible to use a different value-returning
6676: convention for specific functions when all their calls are
6677: known.@refill
6678:
6679: @item FUNCTION_OUTGOING_VALUE (@var{valtype}, @var{func})
6680: Define this macro if the target machine has ``register windows''
6681: so that the register in which a function returns its value is not
6682: the same as the one in which the caller sees the value.
6683:
6684: For such machines, @code{FUNCTION_VALUE} computes the register in
6685: which the caller will see the value, and
6686: @code{FUNCTION_OUTGOING_VALUE} should be defined in a similar fashion
6687: to tell the function where to put the value.@refill
6688:
6689: If @code{FUNCTION_OUTGOING_VALUE} is not defined,
6690: @code{FUNCTION_VALUE} serves both purposes.@refill
6691:
6692: @item LIBCALL_VALUE (@var{mode})
6693: A C expression to create an RTX representing the place where a library
6694: function returns a value of mode @var{mode}. If the precise function
6695: being called is known, @var{func} is a tree node
6696: (@code{FUNCTION_DECL}) for it; otherwise, @var{func} is a null
6697: pointer. This makes it possible to use a different value-returning
6698: convention for specific functions when all their calls are
6699: known.@refill
6700:
6701: Note that ``library function'' in this context means a compiler
6702: support routine, used to perform arithmetic, whose name is known
6703: specially by the compiler and was not mentioned in the C code being
6704: compiled.
6705:
6706: @item FUNCTION_VALUE_REGNO_P (@var{regno})
6707: A C expression that is nonzero if @var{regno} is the number of a hard
1.1.1.6 root 6708: register in which the values of called function may come back.
1.1.1.2 root 6709:
6710: A register whose use for returning values is limited to serving as the
6711: second of a pair (for a value of type @code{double}, say) need not be
6712: recognized by this macro. So for most machines, this definition
6713: suffices:
6714:
6715: @example
6716: #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
6717: @end example
6718:
1.1.1.6 root 6719: If the machine has register windows, so that the caller and the called
6720: function use different registers for the return value, this macro
6721: should recognize only the caller's register numbers.
6722:
1.1.1.2 root 6723: @item FUNCTION_ARG (@var{cum}, @var{mode}, @var{type}, @var{named})
6724: A C expression that controls whether a function argument is passed
6725: in a register, and which register.
6726:
6727: The arguments are @var{cum}, which summarizes all the previous
6728: arguments; @var{mode}, the machine mode of the argument; @var{type},
6729: the data type of the argument as a tree node or 0 if that is not known
6730: (which happens for C support library functions); and @var{named},
6731: which is 1 for an ordinary argument and 0 for nameless arguments that
6732: correspond to @samp{...} in the called function's prototype.
6733:
6734: The value of the expression should either be a @samp{reg} RTX for the
6735: hard register in which to pass the argument, or zero to pass the
6736: argument on the stack.
6737:
6738: For the Vax and 68000, where normally all arguments are pushed, zero
6739: suffices as a definition.
6740:
6741: @item FUNCTION_INCOMING_ARG (@var{cum}, @var{mode}, @var{type}, @var{named})
6742: Define this macro if the target machine has ``register windows'', so
6743: that the register in which a function sees an arguments is not
6744: necessarily the same as the one in which the caller passed the
6745: argument.
6746:
6747: For such machines, @code{FUNCTION_ARG} computes the register in which
6748: the caller passes the value, and @code{FUNCTION_INCOMING_ARG} should
6749: be defined in a similar fashion to tell the function being called
6750: where the arguments will arrive.
6751:
6752: If @code{FUNCTION_INCOMING_ARG} is not defined, @code{FUNCTION_ARG}
6753: serves both purposes.@refill
6754:
6755: @item FUNCTION_ARG_PARTIAL_NREGS (@var{cum}, @var{mode}, @var{type}, @var{named})
6756: A C expression for the number of words, at the beginning of an
6757: argument, must be put in registers. The value must be zero for
6758: arguments that are passed entirely in registers or that are entirely
6759: pushed on the stack.
6760:
6761: On some machines, certain arguments must be passed partially in
6762: registers and partially in memory. On these machines, typically the
6763: first @var{n} words of arguments are passed in registers, and the rest
6764: on the stack. If a multi-word argument (a @code{double} or a
6765: structure) crosses that boundary, its first few words must be passed
6766: in registers and the rest must be pushed. This macro tells the
6767: compiler when this occurs, and how many of the words should go in
6768: registers.
6769:
6770: @code{FUNCTION_ARG} for these arguments should return the first
6771: register to be used by the caller for this argument; likewise
6772: @code{FUNCTION_INCOMING_ARG}, for the called function.
6773:
6774: @item CUMULATIVE_ARGS
6775: A C type for declaring a variable that is used as the first argument
6776: of @code{FUNCTION_ARG} and other related values. For some target
6777: machines, the type @code{int} suffices and can hold the number of
6778: bytes of argument so far.
6779:
1.1.1.7 root 6780: @item INIT_CUMULATIVE_ARGS (@var{cum}, @var{fntype})
1.1.1.2 root 6781: A C statement (sans semicolon) for initializing the variable @var{cum}
6782: for the state at the beginning of the argument list. The variable has
1.1.1.7 root 6783: type @code{CUMULATIVE_ARGS}. The value of @var{fntype} is the tree node
6784: for the data type of the function which will receive the args, or 0
6785: if the args are to a compiler support library function.
1.1.1.2 root 6786:
6787: @item FUNCTION_ARG_ADVANCE (@var{cum}, @var{mode}, @var{type}, @var{named})
6788: Update the summarizer variable @var{cum} to advance past an argument
6789: in the argument list. The values @var{mode}, @var{type} and
6790: @var{named} describe that argument. Once this is done, the variable
6791: @var{cum} is suitable for analyzing the @emph{following} argument
6792: with @code{FUNCTION_ARG}, etc.@refill
6793:
6794: @item FUNCTION_ARG_REGNO_P (@var{regno})
6795: A C expression that is nonzero if @var{regno} is the number of a hard
6796: register in which function arguments are sometimes passed. This does
6797: @emph{not} include implicit arguments such as the static chain and
6798: the structure-value address. On many machines, no registers can be
6799: used for this purpose since all function arguments are pushed on the
6800: stack.
1.1 root 6801:
1.1.1.6 root 6802: @item FUNCTION_ARG_PADDING (@var{mode}, @var{size})
6803: If defined, a C expression which determines whether, and in which direction,
6804: to pad out an argument with extra space. The value should be of type
6805: @code{enum direction}: either @code{upward} to pad above the argument,
6806: @code{downward} to pad below, or @code{none} to inhibit padding.
6807:
6808: The argument @var{size} is an RTX which describes the size of the
6809: argument, in bytes. It should be used only if @var{mode} is
6810: @code{BLKmode}. Otherwise, @var{size} is 0.
6811:
6812: This macro does not control the @emph{amount} of padding; that is
6813: always just enough to reach the next multiple of @code{PARM_BOUNDARY}.
6814:
6815: This macro has a default definition which is right for most systems.
6816: For little-endian machines, the default is to pad upward. For
6817: big-endian machines, the default is to pad downward for an argument of
6818: constant size shorter than an @code{int}, and upward otherwise.
6819:
1.1 root 6820: @item FUNCTION_PROLOGUE (@var{file}, @var{size})
6821: A C compound statement that outputs the assembler code for entry to a
6822: function. The prologue is responsible for setting up the stack frame,
6823: initializing the frame pointer register, saving registers that must be
1.1.1.2 root 6824: saved, and allocating @var{size} additional bytes of storage for the
6825: local variables. @var{size} is an integer. @var{file} is a stdio
6826: stream to which the assembler code should be output.
1.1 root 6827:
6828: The label for the beginning of the function need not be output by this
6829: macro. That has already been done when the macro is run.
6830:
6831: To determine which registers to save, the macro can refer to the array
1.1.1.2 root 6832: @code{regs_ever_live}: element @var{r} is nonzero if hard register
6833: @var{r} is used anywhere within the function. This implies the
6834: function prologue should save register @var{r}, but not if it is one
6835: of the call-used registers.
6836:
6837: On machines where functions may or may not have frame-pointers, the
6838: function entry code must vary accordingly; it must set up the frame
6839: pointer if one is wanted, and not otherwise. To determine whether a
6840: frame pointer is in wanted, the macro can refer to the variable
6841: @code{frame_pointer_needed}. The variable's value will be 1 at run
6842: time in a function that needs a frame pointer.
6843:
6844: @item FUNCTION_PROFILER (@var{file}, @var{labelno})
6845: A C statement or compound statement to output to @var{file} some
6846: assembler code to call the profiling subroutine @code{mcount}.
6847: Before calling, the assembler code must load the address of a
6848: counter variable into a register where @code{mcount} expects to
6849: find the address. The name of this variable is @samp{LP} followed
6850: by the number @var{labelno}, so you would generate the name using
6851: @samp{LP%d} in a @code{fprintf}.
6852:
6853: The details of how the address should be passed to @code{mcount} are
6854: determined by your operating system environment, not by GNU CC. To
6855: figure them out, compile a small program for profiling using the
6856: system's installed C compiler and look at the assembler code that
6857: results.
6858:
6859: @item EXIT_IGNORES_STACK
6860: Define this macro as a C expression that is nonzero if the return
6861: instruction or the function epilogue ignores the value of the stack
6862: pointer; in other words, if it is safe to delete an instruction to
6863: adjust the stack pointer before a return from the function.
6864:
6865: Note that this macro's value is relevant only for for which frame
6866: pointers are maintained. It is never possible to delete a final stack
6867: adjustment in a function that has no frame pointer, and the compiler
6868: knows this regardless of @code{EXIT_IGNORES_STACK}.
1.1 root 6869:
6870: @item FUNCTION_EPILOGUE (@var{file}, @var{size})
6871: A C compound statement that outputs the assembler code for exit from a
6872: function. The epilogue is responsible for restoring the saved
6873: registers and stack pointer to their values when the function was
6874: called, and returning control to the caller. This macro takes the
6875: same arguments as the macro @code{FUNCTION_PROLOGUE}, and the
6876: registers to restore are determined from @code{regs_ever_live} and
6877: @code{CALL_USED_REGISTERS} in the same way.
6878:
1.1.1.2 root 6879: On some machines, there is a single instruction that does all the work
6880: of returning from the function. On these machines, give that
6881: instruction the name @samp{return} and do not define the macro
6882: @code{FUNCTION_EPILOGUE} at all.
6883:
1.1.1.8 root 6884: Do not define a pattern named @samp{return} if you want the
6885: @code{FUNCTION_EPILOGUE} to be used. If you want the target switches
6886: to control whether return instructions or epilogues are used, define a
6887: @samp{return} pattern with a validity condition that tests the target
6888: switches appropriately. If the @samp{return} pattern's validity
6889: condition is false, epilogues will be used.
6890:
1.1.1.2 root 6891: On machines where functions may or may not have frame-pointers, the
6892: function exit code must vary accordingly. Sometimes the code for
6893: these two cases is completely different. To determine whether a frame
6894: pointer is in wanted, the macro can refer to the variable
6895: @code{frame_pointer_needed}. The variable's value will be 1 at run
6896: time in a function that needs a frame pointer.
6897:
6898: On some machines, some functions pop their arguments on exit while
6899: others leave that for the caller to do. For example, the 68020 when
6900: given @samp{-mrtd} pops arguments in functions that take a fixed
6901: number of arguments.
6902:
6903: Your definition of the macro @code{RETURN_POPS_ARGS} decides which
6904: functions pop their own arguments. @code{FUNCTION_EPILOGUE} needs to
6905: know what was decided. The variable @code{current_function_pops_args}
6906: is nonzero if the function should pop its own arguments. If so, use
6907: the variable @code{current_function_args_size} as the number of bytes
6908: to pop.
6909:
6910: @item FIX_FRAME_POINTER_ADDRESS (@var{addr}, @var{depth})
6911: A C compound statement to alter a memory address that uses the frame
6912: pointer register so that it uses the stack pointer register instead.
6913: This must be done in the instructions that load parameter values into
6914: registers, when the reload pass determines that a frame pointer is not
6915: necessary for the function. @var{addr} will be a C variable name, and
6916: the updated address should be stored in that variable. @var{depth}
6917: will be the current depth of stack temporaries (number of bytes of
6918: arguments currently pushed). The change in offset between a
6919: frame-pointer-relative address and a stack-pointer-relative address
6920: must include @var{depth}.
6921:
6922: Even if your machine description specifies there will always be a
6923: frame pointer in the frame pointer register, you must still define
6924: @code{FIX_FRAME_POINTER_ADDRESS}, but the definition will never be
6925: executed at run time, so it may be empty.
6926: @end table
6927:
6928: @node Library Names, Addressing Modes, Stack Layout, Machine Macros
6929: @section Library Subroutine Names
6930:
6931: @table @code
6932: @item UDIVSI3_LIBCALL
6933: A C string constant giving the name of the function to call for
6934: division of a full-word by a full-word. If you do not define this
6935: macro, the default name is used, which is @code{_udivsi3}, a function
6936: defined in @file{gnulib}.
6937:
6938: @item UMODSI3_LIBCALL
6939: A C string constant giving the name of the function to call for the
6940: remainder in division of a full-word by a full-word. If you do not
6941: define this macro, the default name is used, which is @code{_umodsi3},
6942: a function defined in @file{gnulib}.
6943:
6944: @item TARGET_MEM_FUNCTIONS
6945: Define this macro if GNU CC should generate calls to the System V
6946: (and ANSI C) library functions @code{memcpy} and @code{memset}
6947: rather than the BSD functions @code{bcopy} and @code{bzero}.
1.1 root 6948: @end table
6949:
1.1.1.2 root 6950: @node Addressing Modes, Misc, Library Names, Machine Macros
1.1 root 6951: @section Addressing Modes
6952:
6953: @table @code
6954: @item HAVE_POST_INCREMENT
6955: Define this macro if the machine supports post-increment addressing.
6956:
6957: @item HAVE_PRE_INCREMENT
6958: @itemx HAVE_POST_DECREMENT
6959: @itemx HAVE_PRE_DECREMENT
6960: Similar for other kinds of addressing.
6961:
6962: @item CONSTANT_ADDRESS_P (@var{x})
1.1.1.2 root 6963: A C expression that is 1 if the RTX @var{x} is a constant whose value
1.1 root 6964: is an integer. This includes integers whose values are not explicitly
1.1.1.2 root 6965: known, such as @samp{symbol_ref} and @samp{label_ref} expressions and
6966: @samp{const} arithmetic expressions.
6967:
6968: On most machines, this can be defined as @code{CONSTANT_P (@var{x})},
6969: but a few machines are more restrictive in which constant addresses
6970: are supported.
1.1 root 6971:
6972: @item MAX_REGS_PER_ADDRESS
6973: A number, the maximum number of registers that can appear in a valid
6974: memory address.
6975:
6976: @item GO_IF_LEGITIMATE_ADDRESS (@var{mode}, @var{x}, @var{label})
6977: A C compound statement with a conditional @code{goto @var{label};}
1.1.1.2 root 6978: executed if @var{x} (an RTX) is a legitimate memory address on the
6979: target machine for a memory operand of mode @var{mode}.
1.1 root 6980:
6981: It usually pays to define several simpler macros to serve as
1.1.1.2 root 6982: subroutines for this one. Otherwise it may be too complicated to
6983: understand.
6984:
6985: This macro must exist in two variants: a strict variant and a
6986: non-strict one. The strict variant is used in the reload pass. It
6987: must be defined so that any pseudo-register that has not been
6988: allocated a hard register is considered a memory reference. In
6989: contexts where some kind of register is required, a pseudo-register
6990: with no hard register must be rejected.
6991:
6992: The non-strict variant is used in other passes. It must be defined to
6993: accept all pseudo-registers in every context where some kind of
6994: register is required.
6995:
6996: Compiler source files that want to use the strict variant of this
6997: macro define the macro @code{REG_OK_STRICT}. You should use an
6998: @code{#ifdef REG_OK_STRICT} conditional to define the strict variant
6999: in that case and the non-strict variant otherwise.
7000:
7001: Typically among the subroutines used to define
7002: @code{GO_IF_LEGITIMATE_ADDRESS} are subroutines to check for
7003: acceptable registers for various purposes (one for base registers, one
7004: for index registers, and so on). Then only these subroutine macros
7005: need have two variants; the higher levels of macros may be the same
7006: whether strict or not.@refill
1.1 root 7007:
1.1.1.7 root 7008: @item REG_OK_FOR_BASE_P (@var{x})
7009: A C expression that is nonzero if @var{x} (asumed to be a @code{reg}
7010: RTX) is valid for use as a base register. For hard registers, it
7011: should always accept those which the hardware permits and reject the
7012: others. Whether the macro accepts or rejects pseudo registers must be
7013: controlled by @code{REG_OK_STRICT} as described above. This usually
7014: requires two variant definitions, of which @code{REG_OK_STRICT}
7015: controls the one actually used.
7016:
7017: @item REG_OK_FOR_INDEX_P (@var{x})
7018: A C expression that is nonzero if @var{x} (asumed to be a @code{reg}
7019: RTX) is valid for use as an index register.
7020:
7021: The difference between an index register and a base register is that
7022: the index register may be scaled. If an address involves the sum of
7023: two registers, neither one of them scaled, then either one may be
7024: labeled the ``base'' and the other the ``index''; but whichever
7025: labeling is used must fit the machine's constraints of which registers
7026: may serve in each capacity. The compiler will try both labelings,
7027: looking for one that is valid, and will reload one or both registers
7028: only if neither labeling works.
7029:
1.1 root 7030: @item LEGITIMIZE_ADDRESS (@var{x}, @var{oldx}, @var{mode}, @var{win})
7031: A C compound statement that attempts to replace @var{x} with a valid
1.1.1.2 root 7032: memory address for an operand of mode @var{mode}. @var{win} will be a
7033: C statement label elsewhere in the code; the macro definition may use
1.1 root 7034:
7035: @example
7036: GO_IF_LEGITIMATE_ADDRESS (@var{mode}, @var{x}, @var{win});
7037: @end example
7038:
7039: @noindent
7040: to avoid further processing if the address has become legitimate.
7041:
7042: @var{x} will always be the result of a call to @code{break_out_memory_refs},
7043: and @var{oldx} will be the operand that was given to that function to produce
7044: @var{x}.
7045:
1.1.1.2 root 7046: The code generated by this macro should not alter the substructure of
7047: @var{x}. If it transforms @var{x} into a more legitimate form, it
7048: should assign @var{x} (which will always be a C variable) a new value.
7049:
7050: It is not necessary for this macro to come up with a legitimate
7051: address. The compiler has standard ways of doing so in all cases. In
7052: fact, it is safe for this macro to do nothing. But often a
7053: machine-dependent strategy can generate better code.
7054:
7055: @item GO_IF_MODE_DEPENDENT_ADDRESS (@var{addr}, @var{label})
7056: A C statement or compound statement with a conditional @code{goto
7057: @var{label};} executed if memory address @var{x} (an RTX) can have
7058: different meanings depending on the machine mode of the memory
7059: reference it is used for.
7060:
7061: Autoincrement and autodecrement addresses typically have mode-dependent
7062: effects because the amount of the increment or decrement is the size
7063: of the operand being addressed. Some machines have other mode-dependent
7064: addresses. Many RISC machines have no mode-dependent addresses.
7065:
7066: You may assume that @var{addr} is a valid address for the machine.
7067:
7068: @item LEGITIMATE_CONSTANT_P (@var{x})
7069: A C expression that is nonzero if @var{x} is a legitimate constant for
7070: an immediate operand on the target machine. You can assume that
7071: either @var{x} is a @samp{const_double} or it satisfies
7072: @code{CONSTANT_P}, so you need not check these things. In fact,
7073: @samp{1} is a suitable definition for this macro on machines where any
7074: @samp{const_double} is valid and anything @code{CONSTANT_P} is valid.@refill
1.1 root 7075: @end table
7076:
7077: @node Misc, Condition Code, Addressing Modes, Machine Macros
7078: @section Miscellaneous Parameters
7079:
7080: @table @code
7081: @item CASE_VECTOR_MODE
1.1.1.2 root 7082: An alias for a machine mode name. This is the machine mode that
7083: elements of a jump-table should have.
1.1 root 7084:
7085: @item CASE_VECTOR_PC_RELATIVE
7086: Define this macro if jump-tables should contain relative addresses.
7087:
1.1.1.2 root 7088: @item CASE_DROPS_THROUGH
7089: Define this if control falls through a @code{case} insn when the index
7090: value is out of range. This means the specified default-label is
7091: actually ignored by the @code{case} insn proper.
7092:
1.1 root 7093: @item IMPLICIT_FIX_EXPR
7094: An alias for a tree code that should be used by default for conversion
1.1.1.2 root 7095: of floating point values to fixed point. Normally,
7096: @code{FIX_ROUND_EXPR} is used.@refill
7097:
7098: @item FIXUNS_TRUNC_LIKE_FIX_TRUNC
7099: Define this macro if the same instructions that convert a floating
7100: point number to a signed fixed point number also convert validly to an
7101: unsigned one.
1.1 root 7102:
7103: @item EASY_DIV_EXPR
1.1.1.2 root 7104: An alias for a tree code that is the easiest kind of division to
7105: compile code for in the general case. It may be
7106: @code{TRUNC_DIV_EXPR}, @code{FLOOR_DIV_EXPR}, @code{CEIL_DIV_EXPR} or
7107: @code{ROUND_DIV_EXPR}. These four division operators differ in how
7108: they round the result to an integer. @code{EASY_DIV_EXPR} is used
7109: when it is permissible to use any of those kinds of division and the
7110: choice should be made on the basis of efficiency.@refill
7111:
7112: @item DEFAULT_SIGNED_CHAR
7113: An expression whose value is 1 or 0, according to whether the type
7114: @code{char} should be signed or unsigned by default. The user can
7115: always override this default with the options @samp{-fsigned-char}
7116: and @samp{-funsigned-char}.
7117:
7118: @item SCCS_DIRECTIVE
7119: Define this if the preprocessor should ignore @code{#sccs} directives
1.1.1.4 root 7120: and print no error message.
7121:
7122: @item IDENT_DIRECTIVE
7123: Define this if the preprocessor should ignore @code{#ident} directives
7124: and print no error message.
1.1 root 7125:
7126: @item MOVE_MAX
7127: The maximum number of bytes that a single instruction can move quickly
7128: from memory to memory.
7129:
1.1.1.2 root 7130: @item INT_TYPE_SIZE
7131: A C expression for the size in bits of the type @code{int} on the
7132: target machine.
7133:
7134: @item SLOW_BYTE_ACCESS
7135: Define this macro as a C expression which is nonzero if accessing less
7136: than a word of memory (i.e. a @code{char} or a @code{short}) is slow
7137: (requires more than one instruction).
7138:
1.1 root 7139: @item SLOW_ZERO_EXTEND
1.1.1.2 root 7140: Define this macro if zero-extension (of a @code{char} or @code{short}
7141: to an @code{int}) can be done faster if the destination is a register
7142: that is known to be zero.
7143:
7144: If you define this macro, you must have instruction patterns that
7145: recognize RTL structures like this:
7146:
7147: @example
7148: (set (strict-low-part (subreg:QI (reg:SI @dots{}) 0)) @dots{})
7149: @end example
7150:
7151: @noindent
7152: and likewise for @code{HImode}.
1.1 root 7153:
7154: @item SHIFT_COUNT_TRUNCATED
7155: Define this macro if shift instructions ignore all but the lowest few
7156: bits of the shift count. It implies that a sign-extend or zero-extend
7157: instruction for the shift count can be omitted.
7158:
1.1.1.2 root 7159: @item TRULY_NOOP_TRUNCATION (@var{outprec}, @var{inprec})
1.1 root 7160: A C expression which is nonzero if on this machine it is safe to
1.1.1.2 root 7161: ``convert'' an integer of @var{inprec} bits to one of @var{outprec}
7162: bits (where @var{outprec} is smaller than @var{inprec}) by merely
7163: operating on it as if it had only @var{outprec} bits.
1.1 root 7164:
7165: On many machines, this expression can be 1.
7166:
1.1.1.2 root 7167: @item NO_FUNCTION_CSE
7168: Define this macro if it is as good or better to call a constant
7169: function address than to call an address kept in a register.
7170:
1.1.1.6 root 7171: @item PROMOTE_PROTOTYPES
7172: Define this macro if an argument declared as @code{char} or
7173: @code{short} in a prototype should actually be passed as an
7174: @code{int}. In addition to avoiding errors in certain cases of
7175: mismatch, it also makes for better code on certain machines.
7176:
1.1.1.2 root 7177: @item STORE_FLAG_VALUE
7178: A C expression for the value stored by a store-flag instruction
7179: (@code{s@var{cond}}) when the condition is true. This is usually 1 or
7180: -1; it is required to be an odd number.
7181:
7182: Do not define @code{STORE_FLAG_VALUE} if the machine has no store-flag
7183: instructions.
7184:
1.1 root 7185: @item Pmode
1.1.1.2 root 7186: An alias for the machine mode for pointers. Normally the definition
7187: can be
1.1 root 7188:
7189: @example
7190: #define Pmode SImode
7191: @end example
7192:
7193: @item FUNCTION_MODE
1.1.1.2 root 7194: An alias for the machine mode used for memory references to functions
7195: being called, in @samp{call} RTL expressions. On most machines this
7196: should be @code{QImode}.
1.1 root 7197:
1.1.1.7 root 7198: @item CONST_COSTS (@var{x}, @var{code})
1.1.1.2 root 7199: A part of a C @code{switch} statement that describes the relative
7200: costs of constant RTL expressions. It must contain @code{case} labels
7201: for expression codes @samp{const_int}, @samp{const}, @samp{symbol_ref}, @samp{label_ref}
7202: and @samp{const_double}. Each case must ultimately reach a
7203: @code{return} statement to return the relative cost of the use of that
1.1 root 7204: kind of constant value in an expression. The cost may depend on the
7205: precise value of the constant, which is available for examination in
7206: @var{x}.
7207:
1.1.1.2 root 7208: @var{code} is the expression code---redundant, since it can be
7209: obtained with @code{GET_CODE (@var{x})}.
7210:
7211: @item DOLLARS_IN_IDENTIFIERS
1.1.1.4 root 7212: Define this to be nonzero if the character @samp{$} should be allowed
7213: by default in identifier names.
1.1 root 7214: @end table
7215:
7216: @node Condition Code, Assembler Format, Misc, Machine Macros
7217: @section Condition Code Information
7218:
7219: The file @file{conditions.h} defines a variable @code{cc_status} to
7220: describe how the condition code was computed (in case the interpretation of
7221: the condition code depends on the instruction that it was set by). This
7222: variable contains the RTL expressions on which the condition code is
7223: currently based, and several standard flags.
7224:
7225: Sometimes additional machine-specific flags must be defined in the machine
7226: description header file. It can also add additional machine-specific
7227: information by defining @code{CC_STATUS_MDEP}.
7228:
7229: @table @code
7230: @item CC_STATUS_MDEP
1.1.1.2 root 7231: C code for a data type which is used for declaring the @code{mdep}
7232: component of @code{cc_status}. It defaults to @code{int}.
1.1 root 7233:
7234: @item CC_STATUS_MDEP_INIT
1.1.1.2 root 7235: A C expression for the initial value of the @code{mdep} field. It
7236: defaults to 0.
1.1 root 7237:
7238: @item NOTICE_UPDATE_CC (@var{exp})
7239: A C compound statement to set the components of @code{cc_status}
1.1.1.2 root 7240: appropriately for an insn whose body is @var{exp}. It is this macro's
7241: responsibility to recognize insns that set the condition code as a
7242: byproduct of other activity as well as those that explicitly set
7243: @code{(cc0)}.
7244:
7245: If there are insn that do not set the condition code but do alter
7246: other machine registers, this macro must check to see whether they
7247: invalidate the expressions that the condition code is recorded as
7248: reflecting. For example, on the 68000, insns that store in address
7249: registers do not set the condition code, which means that usually
7250: @code{NOTICE_UPDATE_CC} can leave @code{cc_status} unaltered for such
7251: insns. But suppose that the previous insn set the condition code
7252: based on location @samp{a4@@(102)} and the current insn stores a new
7253: value in @samp{a4}. Although the condition code is not changed by
7254: this, it will no longer be true that it reflects the contents of
7255: @samp{a4@@(102)}. Therefore, @code{NOTICE_UPDATE_CC} must alter
1.1 root 7256: @code{cc_status} in this case to say that nothing is known about the
7257: condition code value.
1.1.1.8 root 7258:
7259: The definition of @code{NOTICE_UPDATE_CC} must be prepared to deal
7260: with the results of peephole optimization: insns whose patterns are
7261: @samp{parallel} RTXs containing various @samp{reg}, @samp{mem} or
7262: constants which are just the operands. The RTL structure of these
7263: insns is not sufficient to indicate what the insns actually do. What
7264: @code{NOTICE_UPDATE_CC} should do when it sees one is just to run
7265: @code{CC_STATUS_INIT}.
1.1 root 7266: @end table
7267:
7268: @node Assembler Format,, Condition Code, Machine Macros
7269: @section Output of Assembler Code
7270:
7271: @table @code
1.1.1.2 root 7272: @item ASM_SPEC
7273: A C string constant that tells the GNU CC driver program options to
7274: pass to the assembler. It can also specify how to translate options
7275: you give to GNU CC into options for GNU CC to pass to the assembler.
7276: See the file @file{tm-sun3.h} for an example of this.
7277:
7278: Do not define this macro if it does not need to do anything.
7279:
7280: @item LINK_SPEC
7281: A C string constant that tells the GNU CC driver program options to
7282: pass to the linker. It can also specify how to translate options you
7283: give to GNU CC into options for GNU CC to pass to the linker.
7284:
7285: Do not define this macro if it does not need to do anything.
7286:
1.1.1.7 root 7287: @item LIB_SPEC
7288: Another C string constant used much like @code{LINK_SPEC}. The difference
7289: between the two is that @code{LIBS_SPEC} is used at the end of the
7290: command given to the linker.
7291:
7292: If this macro is not defined, a default is provided that
7293: loads the standard C library from the usual place. See @file{gcc.c}.
7294:
7295: @item STARTFILE_SPEC
7296: Another C string constant used much like @code{LINK_SPEC}. The
7297: difference between the two is that @code{STARTFILE_SPEC} is used at
7298: the very beginning of the command given to the linker.
7299:
7300: If this macro is not defined, a default is provided that loads the
7301: standard C startup file from the usual place. See @file{gcc.c}.
7302:
1.1.1.4 root 7303: @item ASM_FILE_START (@var{stream})
7304: A C expression which outputs to the stdio stream @var{stream}
7305: some appropriate text to go at the start of an assembler file.
7306:
7307: Normally this macro is defined to output a line containing
7308: @samp{#NO_APP}, which is a comment that has no effect on most
7309: assemblers but tells the GNU assembler that it can save time by not
7310: checking for certain assembler constructs.
7311:
7312: On systems that use SDB, it is necessary to output certain commands;
7313: see @file{tm-attasm.h}.
1.1.1.2 root 7314:
7315: @item ASM_APP_ON
7316: A C string constant for text to be output before each @code{asm}
7317: statement or group of consecutive ones. Normally this is
7318: @code{"#APP"}, which is a comment that has no effect on most
7319: assemblers but tells the GNU assembler that it must check the lines
7320: that follow for all valid assembler constructs.
7321:
7322: @item ASM_APP_OFF
7323: A C string constant for text to be output after each @code{asm}
7324: statement or group of consecutive ones. Normally this is
7325: @code{"#NO_APP"}, which tells the GNU assembler to resume making the
7326: time-saving assumptions that are valid for ordinary compiler output.
7327:
1.1 root 7328: @item TEXT_SECTION_ASM_OP
7329: A C string constant for the assembler operation that should precede
7330: instructions and read-only data. Normally @code{".text"} is right.
7331:
7332: @item DATA_SECTION_ASM_OP
1.1.1.2 root 7333: A C string constant for the assembler operation to identify the
7334: following data as writable initialized data. Normally @code{".data"}
7335: is right.
1.1 root 7336:
7337: @item REGISTER_NAMES
1.1.1.2 root 7338: A C initializer containing the assembler's names for the machine
7339: registers, each one as a C string constant. This is what translates
7340: register numbers in the compiler into assembler language.
1.1 root 7341:
7342: @item DBX_REGISTER_NUMBER (@var{regno})
1.1.1.2 root 7343: A C expression that returns the DBX register number for the compiler
7344: register number @var{regno}. In simple cases, the value of this
7345: expression may be @var{regno} itself. But sometimes there are some
7346: registers that the compiler knows about and DBX does not, or vice
7347: versa. In such cases, some register may need to have one number in
7348: the compiler and another for DBX.
7349:
1.1.1.4 root 7350: @item DBX_DEBUGGING_INFO
7351: Define this macro if GNU CC should produce debugging output for DBX
7352: in response to the @samp{-g} option.
7353:
7354: @item SDB_DEBUGGING_INFO
7355: Define this macro if GNU CC should produce debugging output for SDB
7356: in response to the @samp{-g} option.
7357:
1.1.1.6 root 7358: @item PUT_SDB_@var{op}
7359: Define these macros to override the assembler syntax for the special
7360: SDB assembler directives. See @file{sdbout.c} for a list of these
7361: macros and their arguments. If the standard syntax is used, you need
7362: not define them yourself.
7363:
7364: @item SDB_GENERATE_FAKE
7365: Define this macro to override the usual method of constructing a dummy
7366: name for anonymous structure and union types. See @file{sdbout.c} for
7367: more infomation.
7368:
1.1.1.2 root 7369: @item DBX_NO_XREFS
7370: Define this macro if DBX on your system does not support the construct
7371: @samp{xs@var{tagname}}. On some systems, this construct is used to
7372: describe a forward reference to a structure named @var{tagname}.
7373: On other systems, this construct is not supported at all.
7374:
7375: @item DBX_CONTIN_LENGTH
7376: A symbol name in DBX-format debugging information is normally
7377: continued (split into two separate @code{.stabs} directives) when it
7378: exceeds a certain length (by default, 80 characters). On some
7379: operating systems, DBX requires this splitting; on others, splitting
7380: must not be done. You can inhibit splitting by defining this macro
7381: with the value zero. You can override the default splitting-length by
7382: defining this macro as an expression for the length you desire.
7383:
7384: @item DBX_CONTIN_CHAR
7385: Normally continuation is indicated by adding a @samp{\} character to
7386: the end of a @code{.stabs} string when a continuation follows. To use
7387: a different character instead, define this macro as a character
7388: constant for the character you want to use. Do not define this macro
7389: if backslash is correct for your system.
7390:
1.1.1.4 root 7391: @item ASM_OUTPUT_LABEL (@var{stream}, @var{name})
1.1.1.2 root 7392: A C statement (sans semicolon) to output to the stdio stream
1.1.1.4 root 7393: @var{stream} the assembler definition of a label named @var{name}. Use
7394: the expression @code{assemble_name (@var{stream}, @var{name})} to output
1.1.1.2 root 7395: the name itself; before and after that, output the additional
7396: assembler syntax for defining the name, and a newline.
7397:
1.1.1.7 root 7398: @item ASM_DECLARE_FUNCTION_NAME (@var{stream}, @var{name}, @var{decl})
1.1.1.2 root 7399: A C statement (sans semicolon) to output to the stdio stream
1.1.1.7 root 7400: @var{stream} any text necessary for declaring the name @var{name} of a
7401: function which is being defined. This macro is responsible for
7402: outputting the label definition (perhaps using
7403: @code{ASM_OUTPUT_LABEL}). The argument @var{decl} is the
7404: @code{FUNCTION_DECL} tree node representing the function.
1.1.1.2 root 7405:
7406: If this macro is not defined, then the function name is defined in the
7407: usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
7408:
1.1.1.4 root 7409: @item ASM_GLOBALIZE_LABEL (@var{stream}, @var{name})
1.1.1.2 root 7410: A C statement (sans semicolon) to output to the stdio stream
1.1.1.4 root 7411: @var{stream} some commands that will make the label @var{name} global;
1.1.1.2 root 7412: that is, available for reference from other files. Use the expression
1.1.1.4 root 7413: @code{assemble_name (@var{stream}, @var{name})} to output the name
1.1.1.2 root 7414: itself; before and after that, output the additional assembler syntax
7415: for making that name global, and a newline.
7416:
1.1.1.7 root 7417: @item ASM_OUTPUT_EXTERNAL (@var{stream}, @var{name}, @var{decl})
1.1.1.2 root 7418: A C statement (sans semicolon) to output to the stdio stream
1.1.1.4 root 7419: @var{stream} any text necessary for declaring the name of an external
1.1.1.7 root 7420: symbol named @var{name} which is referenced in this compilation but
7421: not defined. The value of @var{decl} is the tree node for the
7422: declaration.
1.1.1.2 root 7423:
7424: This macro need not be defined if it does not need to output anything.
7425: The GNU assembler and most Unix assemblers don't require anything.
7426:
1.1.1.4 root 7427: @item ASM_OUTPUT_LABELREF (@var{stream}, @var{name})
7428: A C statement to output to the stdio stream @var{stream} a reference in
1.1.1.2 root 7429: assembler syntax to a label named @var{name}. The character @samp{_}
7430: should be added to the front of the name, if that is customary on your
7431: operating system, as it is in most Berkeley Unix systems. This macro
7432: is used in @code{assemble_name}.
7433:
1.1.1.7 root 7434: @item ASM_GENERATE_INTERNAL_LABEL (@var{string}, @var{prefix}, @var{num})
7435: A C statement to store into the string @var{string} a label whose
7436: name is made from the string @var{prefix} and the number @var{num}.
7437:
7438: This string, when output subsequently by @code{ASM_OUTPUT_LABELREF},
7439: should produce the same output that @code{ASM_OUTPUT_INTERNAL_LABEL}
7440: would produce with the same @var{prefix} and @var{num}.
7441:
1.1.1.4 root 7442: @item ASM_OUTPUT_INTERNAL_LABEL (@var{stream}, @var{prefix}, @var{num})
7443: A C statement to output to the stdio stream @var{stream} a label whose
1.1.1.2 root 7444: name is made from the string @var{prefix} and the number @var{num}.
7445: These labels are used for internal purposes, and there is no reason
7446: for them to appear in the symbol table of the object file. On many
7447: systems, the letter @samp{L} at the beginning of a label has this
7448: effect. The usual definition of this macro is as follows:
7449:
7450: @example
1.1.1.4 root 7451: fprintf (@var{stream}, "L%s%d:\n", @var{prefix}, @var{num})
1.1.1.2 root 7452: @end example
7453:
1.1.1.4 root 7454: @item ASM_OUTPUT_CASE_LABEL (@var{stream}, @var{prefix}, @var{num}, @var{table})
1.1.1.2 root 7455: Define this if the label before a jump-table needs to be output
7456: specially. The first three arguments are the same as for
7457: @code{ASM_OUTPUT_INTERNAL_LABEL}; the fourth argument is the
7458: jump-table which follows (a @samp{jump_insn} containing an
7459: @samp{addr_vec} or @samp{addr_diff_vec}).
7460:
7461: This feature is used on system V to output a @code{swbeg} statement
7462: for the table.
7463:
7464: If this macro is not defined, these labels are output with
7465: @code{ASM_OUTPUT_INTERNAL_LABEL}.
7466:
1.1.1.4 root 7467: @item ASM_OUTPUT_CASE_END (@var{stream}, @var{num}, @var{table})
7468: Define this if something special must be output at the end of a jump-table.
7469: The definition should be a C statement to be executed after the assembler
7470: code for the table is written. It should write the appropriate code to
7471: stdio stream @var{stream}. The argument @var{table} is the jump-table
7472: insn, and @var{num} is the label-number of the preceding label.
7473:
7474: If this macro is not defined, nothing special is output at the end of
7475: the jump-table.
7476:
1.1.1.2 root 7477: @item ASM_FORMAT_PRIVATE_NAME (@var{outvar}, @var{name}, @var{number})
7478: A C expression to assign to @var{outvar} (which is a variable of type
7479: @code{char *}) a newly allocated string made from the string
7480: @var{name} and the number @var{number}, with some suitable punctuation
7481: added. Use @code{alloca} to get space for the string.
7482:
7483: This string will be used as the argument to @code{ASM_OUTPUT_LABELREF}
7484: to produce an assembler label for an internal static variable whose
7485: name is @var{name}. Therefore, the string must be such as to result
7486: in valid assembler code. The argument @var{number} is different each
7487: time this macro is executed; it prevents conflicts between
7488: similarly-named internal static variables in different scopes.
7489:
7490: Ideally this string should not be a valid C identifier, to prevent any
7491: conflict with the user's own symbols. Most assemblers allow periods
7492: or percent signs in assembler symbols; putting at least one of these
7493: between the name and the number will suffice.
7494:
1.1.1.4 root 7495: @item ASM_OUTPUT_ADDR_DIFF_ELT (@var{stream}, @var{value}, @var{rel})
1.1.1.2 root 7496: This macro should be provided on machines where the addresses
7497: in a dispatch table are relative to the table's own address.
7498:
7499: The definition should be a C statement to output to the stdio stream
1.1.1.4 root 7500: @var{stream} an assembler pseudo-instruction to generate a difference
1.1.1.2 root 7501: between two labels. @var{value} and @var{rel} are the numbers of two
7502: internal labels. The definitions of these labels are output using
7503: @code{ASM_OUTPUT_INTERNAL_LABEL}, and they must be printed in the same
7504: way here. For example,
7505:
7506: @example
1.1.1.4 root 7507: fprintf (@var{stream}, "\t.word L%d-L%d\n",
1.1.1.2 root 7508: @var{value}, @var{rel})
7509: @end example
7510:
1.1.1.4 root 7511: @item ASM_OUTPUT_ADDR_VEC_ELT (@var{stream}, @var{value})
1.1.1.2 root 7512: This macro should be provided on machines where the addresses
7513: in a dispatch table are absolute.
7514:
7515: The definition should be a C statement to output to the stdio stream
1.1.1.4 root 7516: @var{stream} an assembler pseudo-instruction to generate a reference to
1.1.1.2 root 7517: a label. @var{value} is the number of an internal label whose
7518: definition is output using @code{ASM_OUTPUT_INTERNAL_LABEL}.
7519: For example,
7520:
7521: @example
1.1.1.4 root 7522: fprintf (@var{stream}, "\t.word L%d\n", @var{value})
1.1.1.2 root 7523: @end example
1.1 root 7524:
1.1.1.4 root 7525: @item ASM_OUTPUT_DOUBLE (@var{stream}, @var{value})
7526: A C statement to output to the stdio stream @var{stream} an assembler
1.1 root 7527: instruction to assemble a @code{double} constant whose value is
1.1.1.2 root 7528: @var{value}. @var{value} will be a C expression of type
7529: @code{double}.
1.1 root 7530:
1.1.1.4 root 7531: @item ASM_OUTPUT_FLOAT (@var{stream}, @var{value})
7532: A C statement to output to the stdio stream @var{stream} an assembler
1.1.1.2 root 7533: instruction to assemble a @code{float} constant whose value is
7534: @var{value}. @var{value} will be a C expression of type @code{float}.
7535:
1.1.1.4 root 7536: @item ASM_OUTPUT_INT (@var{stream}, @var{exp})
7537: @itemx ASM_OUTPUT_SHORT (@var{stream}, @var{exp})
7538: @itemx ASM_OUTPUT_CHAR (@var{stream}, @var{exp})
7539: A C statement to output to the stdio stream @var{stream} an assembler
1.1.1.2 root 7540: instruction to assemble a @code{int}, @code{short} or @code{char}
7541: constant whose value is @var{value}. The argument @var{exp} will be
7542: an RTL expression which represents a constant value. Use
7543: @samp{output_addr_const (@var{exp})} to output this value as an
7544: assembler expression.@refill
7545:
1.1.1.4 root 7546: @item ASM_OUTPUT_BYTE (@var{stream}, @var{value})
7547: A C statement to output to the stdio stream @var{stream} an assembler
1.1.1.2 root 7548: instruction to assemble a single byte containing the number @var{value}.
7549:
1.1.1.4 root 7550: @item ASM_OUTPUT_ASCII (@var{stream}, @var{ptr}, @var{len})
7551: A C statement to output to the stdio stream @var{stream} an assembler
1.1.1.2 root 7552: instruction to assemble a string constant containing the @var{len}
7553: bytes at @var{ptr}. @var{ptr} will be a C expression of type
7554: @code{char *} and @var{len} a C expression of type @code{int}.
7555:
7556: If the assembler has a @code{.ascii} pseudo-op as found in the
7557: Berkeley Unix assembler, do not define the macro
7558: @code{ASM_OUTPUT_ASCII}.
1.1 root 7559:
1.1.1.4 root 7560: @item ASM_OUTPUT_SKIP (@var{stream}, @var{nbytes})
7561: A C statement to output to the stdio stream @var{stream} an assembler
1.1 root 7562: instruction to advance the location counter by @var{nbytes} bytes.
7563: @var{nbytes} will be a C expression of type @code{int}.
7564:
1.1.1.4 root 7565: @item ASM_OUTPUT_ALIGN (@var{stream}, @var{power})
7566: A C statement to output to the stdio stream @var{stream} an assembler
1.1 root 7567: instruction to advance the location counter to a multiple of 2 to the
7568: @var{power} bytes. @var{power} will be a C expression of type @code{int}.
7569:
1.1.1.4 root 7570: @item ASM_OUTPUT_COMMON (@var{stream}, @var{name}, @var{size})
1.1.1.2 root 7571: A C statement (sans semicolon) to output to the stdio stream
1.1.1.4 root 7572: @var{stream} the assembler definition of a common-label named @var{name}
1.1.1.2 root 7573: whose size is @var{size} bytes. Use the expression
1.1.1.4 root 7574: @code{assemble_name (@var{stream}, @var{name})} to output the name
1.1.1.2 root 7575: itself; before and after that, output the additional assembler syntax
7576: for defining the name, and a newline.
7577:
7578: This macro controls how the assembler definitions of uninitialized
7579: global variables are output.
7580:
1.1.1.4 root 7581: @item ASM_OUTPUT_LOCAL (@var{stream}, @var{name}, @var{size})
1.1.1.2 root 7582: A C statement (sans semicolon) to output to the stdio stream
1.1.1.4 root 7583: @var{stream} the assembler definition of a local-common-label named
1.1.1.2 root 7584: @var{name} whose size is @var{size} bytes. Use the expression
1.1.1.4 root 7585: @code{assemble_name (@var{stream}, @var{name})} to output the name
1.1.1.2 root 7586: itself; before and after that, output the additional assembler syntax
7587: for defining the name, and a newline.
7588:
7589: This macro controls how the assembler definitions of uninitialized
7590: static variables are output.
1.1 root 7591:
1.1.1.4 root 7592: @item ASM_OUTPUT_SOURCE_LINE (@var{stream}, @var{line})
7593: A C statment to output DBX or SDB debugging information before code
7594: for line number @var{line} of the current source file to the
7595: stdio stream @var{stream}.
7596:
7597: This macro need not be defined if the standard form of debugging
7598: information for the debugger in use is appropriate.
7599:
1.1 root 7600: @item TARGET_BELL
1.1.1.2 root 7601: A C constant expression for the integer value for escape sequence
7602: @samp{\a}.
1.1 root 7603:
7604: @item TARGET_BS
7605: @itemx TARGET_TAB
7606: @itemx TARGET_NEWLINE
7607: C constant expressions for the integer values for escape sequences
7608: @samp{\b}, @samp{\t} and @samp{\n}.
7609:
7610: @item TARGET_VT
7611: @itemx TARGET_FF
7612: @itemx TARGET_CR
7613: C constant expressions for the integer values for escape sequences
7614: @samp{\v}, @samp{\f} and @samp{\r}.
7615:
1.1.1.4 root 7616: @item ASM_OUTPUT_OPCODE (@var{stream}, @var{ptr})
1.1.1.2 root 7617: Define this macro if you are using an unusual assembler that
7618: requires different names for the machine instructions.
7619:
7620: The definition is a C statement or statements which output an
1.1.1.4 root 7621: assembler instruction opcode to the stdio stream @var{stream}. The
1.1.1.2 root 7622: macro-operand @var{ptr} is a variable of type @code{char *} which
7623: points to the opcode name in its ``internal'' form---the form that is
7624: written in the machine description. The definition should output the
1.1.1.4 root 7625: opcode name to @var{stream}, performing any translation you desire, and
1.1.1.2 root 7626: increment the variable @var{ptr} to point at the end of the opcode
7627: so that it will not be output twice.
7628:
7629: In fact, your macro definition may process less than the entire opcode
7630: name, or more than the opcode name; but if you want to process text
7631: that includes @samp{%}-sequences to substitute operands, you must take
7632: care of the substitution yourself. Just be sure to increment
7633: @var{ptr} over whatever text should not be output normally.
7634:
7635: If the macro definition does nothing, the instruction is output
7636: in the usual way.
7637:
1.1.1.4 root 7638: @item FINAL_PRESCAN_INSN (@var{insn}, @var{opvec}, @var{noperands})
7639: If defined, a C statement to be executed just prior to the output of
7640: assembler code for @var{insn}, to modify the extracted operands so
7641: they will be output differently.
7642:
7643: Here the argument @var{opvec} is the vector containing the operands
7644: extracted from @var{insn}, and @var{noperands} is the number of
7645: elements of the vector which contain meaningful data for this insn.
7646: The contents of this vector are what will be used to convert the insn
7647: template into assembler code, so you can change the assembler output
7648: by changing the contents of the vector.
7649:
7650: This macro is useful when various assembler syntaxes share a single
7651: file of instruction patterns; by defining this macro differently, you
7652: can cause a large class of instructions to be output differently (such
7653: as with rearranged operands). Naturally, variations in assembler
7654: syntax affecting individual insn patterns ought to be handled by
7655: writing conditional output routines in those patterns.
7656:
7657: If this macro is not defined, it is equivalent to a null statement.
7658:
7659: @item PRINT_OPERAND (@var{stream}, @var{x}, @var{code})
7660: A C compound statement to output to stdio stream @var{stream} the
1.1.1.2 root 7661: assembler syntax for an instruction operand @var{x}. @var{x} is an
7662: RTL expression.
7663:
7664: @var{code} is a value that can be used to specify one of several ways
7665: of printing the operand. It is used when identical operands must be
7666: printed differently depending on the context. @var{code} comes from
7667: the @samp{%} specification that was used to request printing of the
7668: operand. If the specification was just @samp{%@var{digit}} then
7669: @var{code} is 0; if the specification was @samp{%@var{ltr}
7670: @var{digit}} then @var{code} is the ASCII code for @var{ltr}.
7671:
7672: If @var{x} is a register, this macro should print the register's name.
7673: The names can be found in an array @code{reg_names} whose type is
7674: @code{char *[]}. @code{reg_names} is initialized from
7675: @code{REGISTER_NAMES}.
7676:
7677: When the machine description has a specification @samp{%@var{punct}}
7678: (a @samp{%} followed by a punctuation character), this macro is called
7679: with a null pointer for @var{x} and the punctuation character for
7680: @var{code}.
1.1 root 7681:
1.1.1.4 root 7682: @item PRINT_OPERAND_ADDRESS (@var{stream}, @var{x})
7683: A C compound statement to output to stdio stream @var{stream} the
1.1.1.2 root 7684: assembler syntax for an instruction operand that is a memory reference
7685: whose address is @var{x}. @var{x} is an RTL expression.
7686:
7687: @item ASM_OPEN_PAREN
7688: @itemx ASM_CLOSE_PAREN
7689: These macros are defined as C string constant, describing the syntax
7690: in the assembler for grouping arithmetic expressions. The following
7691: definitions are correct for most assemblers:
7692:
7693: @example
7694: #define ASM_OPEN_PAREN "("
7695: #define ASM_CLOSE_PAREN ")"
7696: @end example
7697: @end table
7698:
7699: @node Config,, Machine Macros, Top
7700: @chapter The Configuration File
7701:
7702: The configuration file @file{config-@var{machine}.h} contains macro
7703: definitions that describe the machine and system on which the compiler is
7704: running. Most of the values in it are actually the same on all machines
7705: that GNU CC runs on, so most all configuration files are identical. But
7706: there are some macros that vary:
7707:
7708: @table @code
7709: @item FAILURE_EXIT_CODE
7710: A C expression for the status code to be returned when the compiler
7711: exits after serious errors.
7712:
7713: @item SUCCESS_EXIT_CODE
7714: A C expression for the status code to be returned when the compiler
7715: exits without serious errors.
1.1 root 7716: @end table
7717:
7718: @contents
7719: @bye
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.