]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/sourcebuild.texi
[ARM] Implement support for ACLE Coprocessor CDP intrinsics
[thirdparty/gcc.git] / gcc / doc / sourcebuild.texi
CommitLineData
cbe34bb5 1@c Copyright (C) 2002-2017 Free Software Foundation, Inc.
0a553c7e
JM
2@c This is part of the GCC manual.
3@c For copying conditions, see the file gcc.texi.
4
5@node Source Tree
6@chapter Source Tree Structure and Build System
7
8This chapter describes the structure of the GCC source tree, and how
9GCC is built. The user documentation for building and installing GCC
10is in a separate manual (@uref{http://gcc.gnu.org/install/}), with
11which it is presumed that you are familiar.
12
13@menu
14* Configure Terms:: Configuration terminology and history.
15* Top Level:: The top level source directory.
16* gcc Directory:: The @file{gcc} subdirectory.
0a553c7e
JM
17@end menu
18
19@include configterms.texi
20
21@node Top Level
22@section Top Level Source Directory
23
24The top level source directory in a GCC distribution contains several
25files and directories that are shared with other software
26distributions such as that of GNU Binutils. It also contains several
27subdirectories that contain parts of GCC and its runtime libraries:
28
29@table @file
30@item boehm-gc
97a2feb6
MK
31The Boehm conservative garbage collector, optionally used as part of
32the ObjC runtime library when configured with @option{--enable-objc-gc}.
0a553c7e 33
3a1ef68a 34@item config
7a50adb7 35Autoconf macros and Makefile fragments used throughout the tree.
3a1ef68a 36
0a553c7e
JM
37@item contrib
38Contributed scripts that may be found useful in conjunction with GCC@.
39One of these, @file{contrib/texi2pod.pl}, is used to generate man
40pages from Texinfo manuals as part of the GCC build process.
41
10270471
LG
42@item fixincludes
43The support for fixing system headers to work with GCC@. See
44@file{fixincludes/README} for more information. The headers fixed by
45this mechanism are installed in @file{@var{libsubdir}/include-fixed}.
46Along with those headers, @file{README-fixinc} is also installed, as
47@file{@var{libsubdir}/include-fixed/README}.
48
0a553c7e
JM
49@item gcc
50The main sources of GCC itself (except for runtime libraries),
51including optimizers, support for different target architectures,
2eac577f 52language front ends, and testsuites. @xref{gcc Directory, , The
0a553c7e
JM
53@file{gcc} Subdirectory}, for details.
54
3a1ef68a
RO
55@item gnattools
56Support tools for GNAT.
57
0a553c7e
JM
58@item include
59Headers for the @code{libiberty} library.
60
10270471
LG
61@item intl
62GNU @code{libintl}, from GNU @code{gettext}, for systems which do not
3a1ef68a 63include it in @code{libc}.
10270471 64
cd271054
AC
65@item libada
66The Ada runtime library.
67
39ce30d8
SB
68@item libatomic
69The runtime support library for atomic operations (e.g. for @code{__sync}
70and @code{__atomic}).
71
3c95eb0e
GDR
72@item libcpp
73The C preprocessor library.
74
3a1ef68a
RO
75@item libdecnumber
76The Decimal Float support library.
0a553c7e
JM
77
78@item libffi
97a2feb6 79The @code{libffi} library, used as part of the Go runtime library.
0a553c7e 80
3a1ef68a
RO
81@item libgcc
82The GCC runtime library.
83
84@item libgfortran
85The Fortran runtime library.
86
7a938933
ILT
87@item libgo
88The Go runtime library. The bulk of this library is mirrored from the
a1ece5c0 89@uref{https://github.com/@/golang/go, master Go repository}.
7a938933 90
3a1ef68a 91@item libgomp
f1f3453e 92The GNU Offloading and Multi Processing Runtime Library.
3a1ef68a 93
0a553c7e 94@item libiberty
81034129 95The @code{libiberty} library, used for portability and for some
0a553c7e
JM
96generally useful data structures and algorithms. @xref{Top, ,
97Introduction, libiberty, @sc{gnu} libiberty}, for more information
98about this library.
99
39ce30d8
SB
100@item libitm
101The runtime support library for transactional memory.
102
0a553c7e 103@item libobjc
46e34f96 104The Objective-C and Objective-C++ runtime library.
0a553c7e 105
39ce30d8
SB
106@item libquadmath
107The runtime support library for quad-precision math operations.
108
3a1ef68a
RO
109@item libssp
110The Stack protector runtime library.
111
0a553c7e
JM
112@item libstdc++-v3
113The C++ runtime library.
114
d7f09764 115@item lto-plugin
0d40ed43 116Plugin used by the linker if link-time optimizations are enabled.
d7f09764 117
0a553c7e
JM
118@item maintainer-scripts
119Scripts used by the @code{gccadmin} account on @code{gcc.gnu.org}.
120
121@item zlib
97a2feb6
MK
122The @code{zlib} compression library, used for compressing and
123uncompressing GCC's intermediate language in LTO object files.
0a553c7e
JM
124@end table
125
126The build system in the top level directory, including how recursion
127into subdirectories works and how building runtime libraries for
128multilibs is handled, is documented in a separate manual, included
129with GNU Binutils. @xref{Top, , GNU configure and build system,
130configure, The GNU configure and build system}, for details.
131
132@node gcc Directory
133@section The @file{gcc} Subdirectory
134
135The @file{gcc} directory contains many files that are part of the C
136sources of GCC, other files used as part of the configuration and
137build process, and subdirectories including documentation and a
2eac577f 138testsuite. The files that are sources of GCC are documented in a
0a553c7e
JM
139separate chapter. @xref{Passes, , Passes and Files of the Compiler}.
140
141@menu
142* Subdirectories:: Subdirectories of @file{gcc}.
143* Configuration:: The configuration process, and the files it uses.
144* Build:: The build system in the @file{gcc} directory.
145* Makefile:: Targets in @file{gcc/Makefile}.
146* Library Files:: Library source files and headers under @file{gcc/}.
147* Headers:: Headers installed by GCC.
148* Documentation:: Building documentation in GCC.
149* Front End:: Anatomy of a language front end.
150* Back End:: Anatomy of a target back end.
151@end menu
152
153@node Subdirectories
154@subsection Subdirectories of @file{gcc}
155
156The @file{gcc} directory contains the following subdirectories:
157
158@table @file
159@item @var{language}
160Subdirectories for various languages. Directories containing a file
161@file{config-lang.in} are language subdirectories. The contents of
d4a10d0a
SB
162the subdirectories @file{c} (for C), @file{cp} (for C++),
163@file{objc} (for Objective-C), @file{objcp} (for Objective-C++),
164and @file{lto} (for LTO) are documented in this
165manual (@pxref{Passes, , Passes and Files of the Compiler});
166those for other languages are not. @xref{Front End, ,
d7f09764
DN
167Anatomy of a Language Front End}, for details of the files in these
168directories.
0a553c7e 169
9a99299d
JM
170@item common
171Source files shared between the compiler drivers (such as
172@command{gcc}) and the compilers proper (such as @file{cc1}). If an
173architecture defines target hooks shared between those places, it also
174has a subdirectory in @file{common/config}. @xref{Target Structure}.
175
0a553c7e
JM
176@item config
177Configuration files for supported architectures and operating
178systems. @xref{Back End, , Anatomy of a Target Back End}, for
c0cbdbd9 179details of the files in this directory.
0a553c7e
JM
180
181@item doc
182Texinfo documentation for GCC, together with automatically generated
183man pages and support for converting the installation manual to
184HTML@. @xref{Documentation}.
185
0a553c7e
JM
186@item ginclude
187System headers installed by GCC, mainly those required by the C
188standard of freestanding implementations. @xref{Headers, , Headers
189Installed by GCC}, for details of when these and other headers are
190installed.
191
0a553c7e
JM
192@item po
193Message catalogs with translations of messages produced by GCC into
194various languages, @file{@var{language}.po}. This directory also
195contains @file{gcc.pot}, the template for these message catalogues,
196@file{exgettext}, a wrapper around @command{gettext} to extract the
197messages from the GCC sources and create @file{gcc.pot}, which is run
7ba4ca63 198by @samp{make gcc.pot}, and @file{EXCLUDES}, a list of files from
0a553c7e
JM
199which messages should not be extracted.
200
201@item testsuite
2eac577f
JM
202The GCC testsuites (except for those for runtime libraries).
203@xref{Testsuites}.
0a553c7e
JM
204@end table
205
206@node Configuration
207@subsection Configuration in the @file{gcc} Directory
208
209The @file{gcc} directory is configured with an Autoconf-generated
210script @file{configure}. The @file{configure} script is generated
3986a20d
KC
211from @file{configure.ac} and @file{aclocal.m4}. From the files
212@file{configure.ac} and @file{acconfig.h}, Autoheader generates the
0a553c7e
JM
213file @file{config.in}. The file @file{cstamp-h.in} is used as a
214timestamp.
215
216@menu
217* Config Fragments:: Scripts used by @file{configure}.
330532ab
NN
218* System Config:: The @file{config.build}, @file{config.host}, and
219 @file{config.gcc} files.
0a553c7e
JM
220* Configuration Files:: Files created by running @file{configure}.
221@end menu
222
223@node Config Fragments
224@subsubsection Scripts Used by @file{configure}
225
226@file{configure} uses some other scripts to help in its work:
227
228@itemize @bullet
229@item The standard GNU @file{config.sub} and @file{config.guess}
6ccde948 230files, kept in the top level directory, are used.
0a553c7e
JM
231
232@item The file @file{config.gcc} is used to handle configuration
daf2f129
JM
233specific to the particular target machine. The file
234@file{config.build} is used to handle configuration specific to the
330532ab
NN
235particular build machine. The file @file{config.host} is used to handle
236configuration specific to the particular host machine. (In general,
237these should only be used for features that cannot reasonably be tested in
238Autoconf feature tests.)
640d429d 239@xref{System Config, , The @file{config.build}; @file{config.host};
330532ab 240and @file{config.gcc} Files}, for details of the contents of these files.
0a553c7e
JM
241
242@item Each language subdirectory has a file
243@file{@var{language}/config-lang.in} that is used for
244front-end-specific configuration. @xref{Front End Config, , The Front
245End @file{config-lang.in} File}, for details of this file.
246
247@item A helper script @file{configure.frag} is used as part of
248creating the output of @file{configure}.
249@end itemize
250
251@node System Config
640d429d 252@subsubsection The @file{config.build}; @file{config.host}; and @file{config.gcc} Files
330532ab
NN
253
254The @file{config.build} file contains specific rules for particular systems
255which GCC is built on. This should be used as rarely as possible, as the
256behavior of the build system can always be detected by autoconf.
257
258The @file{config.host} file contains specific rules for particular systems
259which GCC will run on. This is rarely needed.
260
261The @file{config.gcc} file contains specific rules for particular systems
262which GCC will generate code for. This is usually needed.
263
264Each file has a list of the shell variables it sets, with descriptions, at the
265top of the file.
0a553c7e 266
5b28c537 267FIXME: document the contents of these files, and what variables should
0a553c7e
JM
268be set to control build, host and target configuration.
269
270@include configfiles.texi
271
272@node Build
273@subsection Build System in the @file{gcc} Directory
274
275FIXME: describe the build system, including what is built in what
276stages. Also list the various source files that are used in the build
277process but aren't source files of GCC itself and so aren't documented
278below (@pxref{Passes}).
279
280@include makefile.texi
281
282@node Library Files
283@subsection Library Source Files and Headers under the @file{gcc} Directory
284
285FIXME: list here, with explanation, all the C source files and headers
286under the @file{gcc} directory that aren't built into the GCC
287executable but rather are part of runtime libraries and object files,
288such as @file{crtstuff.c} and @file{unwind-dw2.c}. @xref{Headers, ,
289Headers Installed by GCC}, for more information about the
290@file{ginclude} directory.
291
292@node Headers
293@subsection Headers Installed by GCC
294
295In general, GCC expects the system C library to provide most of the
296headers to be used with it. However, GCC will fix those headers if
297necessary to make them work with GCC, and will install some headers
298required of freestanding implementations. These headers are installed
299in @file{@var{libsubdir}/include}. Headers for non-C runtime
300libraries are also installed by GCC; these are not documented here.
301(FIXME: document them somewhere.)
302
303Several of the headers GCC installs are in the @file{ginclude}
304directory. These headers, @file{iso646.h},
6c535c69
ZW
305@file{stdarg.h}, @file{stdbool.h}, and @file{stddef.h},
306are installed in @file{@var{libsubdir}/include},
0a553c7e
JM
307unless the target Makefile fragment (@pxref{Target Fragment})
308overrides this by setting @code{USER_H}.
309
310In addition to these headers and those generated by fixing system
311headers to work with GCC, some other headers may also be installed in
312@file{@var{libsubdir}/include}. @file{config.gcc} may set
313@code{extra_headers}; this specifies additional headers under
cd42d3df
RH
314@file{config} to be installed on some systems.
315
316GCC installs its own version of @code{<float.h>}, from @file{ginclude/float.h}.
daf2f129 317This is done to cope with command-line options that change the
cd42d3df
RH
318representation of floating point numbers.
319
320GCC also installs its own version of @code{<limits.h>}; this is generated
0a553c7e
JM
321from @file{glimits.h}, together with @file{limitx.h} and
322@file{limity.h} if the system also has its own version of
323@code{<limits.h>}. (GCC provides its own header because it is
324required of ISO C freestanding implementations, but needs to include
325the system header from its own header as well because other standards
326such as POSIX specify additional values to be defined in
327@code{<limits.h>}.) The system's @code{<limits.h>} header is used via
328@file{@var{libsubdir}/include/syslimits.h}, which is copied from
329@file{gsyslimits.h} if it does not need fixing to work with GCC; if it
330needs fixing, @file{syslimits.h} is the fixed copy.
331
1617e5ee
GK
332GCC can also install @code{<tgmath.h>}. It will do this when
333@file{config.gcc} sets @code{use_gcc_tgmath} to @code{yes}.
334
0a553c7e
JM
335@node Documentation
336@subsection Building Documentation
337
338The main GCC documentation is in the form of manuals in Texinfo
cc5c2741
BM
339format. These are installed in Info format; DVI versions may be
340generated by @samp{make dvi}, PDF versions by @samp{make pdf}, and
3a1ef68a 341HTML versions by @samp{make html}. In addition, some man pages are
0a553c7e
JM
342generated from the Texinfo manuals, there are some other text files
343with miscellaneous documentation, and runtime libraries have their own
344documentation outside the @file{gcc} directory. FIXME: document the
345documentation for runtime libraries somewhere.
346
347@menu
348* Texinfo Manuals:: GCC manuals in Texinfo format.
349* Man Page Generation:: Generating man pages from Texinfo manuals.
350* Miscellaneous Docs:: Miscellaneous text files with documentation.
351@end menu
352
353@node Texinfo Manuals
354@subsubsection Texinfo Manuals
355
356The manuals for GCC as a whole, and the C and C++ front ends, are in
357files @file{doc/*.texi}. Other front ends have their own manuals in
358files @file{@var{language}/*.texi}. Common files
359@file{doc/include/*.texi} are provided which may be included in
360multiple manuals; the following files are in @file{doc/include}:
361
362@table @file
363@item fdl.texi
364The GNU Free Documentation License.
365@item funding.texi
366The section ``Funding Free Software''.
367@item gcc-common.texi
368Common definitions for manuals.
7db2226d 369@item gpl_v3.texi
0a553c7e
JM
370The GNU General Public License.
371@item texinfo.tex
372A copy of @file{texinfo.tex} known to work with the GCC manuals.
373@end table
374
cc5c2741 375DVI-formatted manuals are generated by @samp{make dvi}, which uses
ff2ce160 376@command{texi2dvi} (via the Makefile macro @code{$(TEXI2DVI)}).
cc5c2741
BM
377PDF-formatted manuals are generated by @samp{make pdf}, which uses
378@command{texi2pdf} (via the Makefile macro @code{$(TEXI2PDF)}). HTML
3a1ef68a 379formatted manuals are generated by @samp{make html}. Info
7ba4ca63 380manuals are generated by @samp{make info} (which is run as part of
0a553c7e
JM
381a bootstrap); this generates the manuals in the source directory,
382using @command{makeinfo} via the Makefile macro @code{$(MAKEINFO)},
383and they are included in release distributions.
384
385Manuals are also provided on the GCC web site, in both HTML and
386PostScript forms. This is done via the script
822a338e 387@file{maintainer-scripts/update_web_docs_svn}. Each manual to be
0a553c7e
JM
388provided online must be listed in the definition of @code{MANUALS} in
389that file; a file @file{@var{name}.texi} must only appear once in the
390source tree, and the output manual must have the same name as the
391source file. (However, other Texinfo files, included in manuals but
392not themselves the root files of manuals, may have names that appear
393more than once in the source tree.) The manual file
394@file{@var{name}.texi} should only include other files in its own
395directory or in @file{doc/include}. HTML manuals will be generated by
cc5c2741
BM
396@samp{makeinfo --html}, PostScript manuals by @command{texi2dvi}
397and @command{dvips}, and PDF manuals by @command{texi2pdf}.
398All Texinfo files that are parts of manuals must
3a1ef68a 399be version-controlled, even if they are generated files, for the
0a553c7e
JM
400generation of online manuals to work.
401
402The installation manual, @file{doc/install.texi}, is also provided on
403the GCC web site. The HTML version is generated by the script
404@file{doc/install.texi2html}.
405
406@node Man Page Generation
407@subsubsection Man Page Generation
408
409Because of user demand, in addition to full Texinfo manuals, man pages
410are provided which contain extracts from those manuals. These man
411pages are generated from the Texinfo manuals using
412@file{contrib/texi2pod.pl} and @command{pod2man}. (The man page for
413@command{g++}, @file{cp/g++.1}, just contains a @samp{.so} reference
414to @file{gcc.1}, but all the other man pages are generated from
415Texinfo manuals.)
416
417Because many systems may not have the necessary tools installed to
418generate the man pages, they are only generated if the
419@file{configure} script detects that recent enough tools are
420installed, and the Makefiles allow generating man pages to fail
421without aborting the build. Man pages are also included in release
422distributions. They are generated in the source directory.
423
424Magic comments in Texinfo files starting @samp{@@c man} control what
425parts of a Texinfo file go into a man page. Only a subset of Texinfo
426is supported by @file{texi2pod.pl}, and it may be necessary to add
427support for more Texinfo features to this script when generating new
428man pages. To improve the man page output, some special Texinfo
429macros are provided in @file{doc/include/gcc-common.texi} which
430@file{texi2pod.pl} understands:
431
432@table @code
433@item @@gcctabopt
434Use in the form @samp{@@table @@gcctabopt} for tables of options,
435where for printed output the effect of @samp{@@code} is better than
436that of @samp{@@option} but for man page output a different effect is
437wanted.
438@item @@gccoptlist
439Use for summary lists of options in manuals.
440@item @@gol
441Use at the end of each line inside @samp{@@gccoptlist}. This is
442necessary to avoid problems with differences in how the
443@samp{@@gccoptlist} macro is handled by different Texinfo formatters.
444@end table
445
446FIXME: describe the @file{texi2pod.pl} input language and magic
447comments in more detail.
448
449@node Miscellaneous Docs
450@subsubsection Miscellaneous Documentation
451
452In addition to the formal documentation that is installed by GCC,
3a1ef68a
RO
453there are several other text files in the @file{gcc} subdirectory
454with miscellaneous documentation:
0a553c7e
JM
455
456@table @file
457@item ABOUT-GCC-NLS
458Notes on GCC's Native Language Support. FIXME: this should be part of
459this manual rather than a separate file.
460@item ABOUT-NLS
461Notes on the Free Translation Project.
462@item COPYING
3a1ef68a
RO
463@itemx COPYING3
464The GNU General Public License, Versions 2 and 3.
0a553c7e 465@item COPYING.LIB
3a1ef68a
RO
466@itemx COPYING3.LIB
467The GNU Lesser General Public License, Versions 2.1 and 3.
0a553c7e
JM
468@item *ChangeLog*
469@itemx */ChangeLog*
470Change log files for various parts of GCC@.
471@item LANGUAGES
472Details of a few changes to the GCC front-end interface. FIXME: the
473information in this file should be part of general documentation of
474the front-end interface in this manual.
475@item ONEWS
476Information about new features in old versions of GCC@. (For recent
477versions, the information is on the GCC web site.)
478@item README.Portability
479Information about portability issues when writing code in GCC@. FIXME:
480why isn't this part of this manual or of the GCC Coding Conventions?
0a553c7e
JM
481@end table
482
483FIXME: document such files in subdirectories, at least @file{config},
d4a10d0a 484@file{c}, @file{cp}, @file{objc}, @file{testsuite}.
0a553c7e
JM
485
486@node Front End
487@subsection Anatomy of a Language Front End
488
489A front end for a language in GCC has the following parts:
490
491@itemize @bullet
492@item
493A directory @file{@var{language}} under @file{gcc} containing source
494files for that front end. @xref{Front End Directory, , The Front End
495@file{@var{language}} Directory}, for details.
496@item
497A mention of the language in the list of supported languages in
498@file{gcc/doc/install.texi}.
499@item
a72967cd
JM
500A mention of the name under which the language's runtime library is
501recognized by @option{--enable-shared=@var{package}} in the
502documentation of that option in @file{gcc/doc/install.texi}.
503@item
504A mention of any special prerequisites for building the front end in
505the documentation of prerequisites in @file{gcc/doc/install.texi}.
506@item
0a553c7e
JM
507Details of contributors to that front end in
508@file{gcc/doc/contrib.texi}. If the details are in that front end's
509own manual then there should be a link to that manual's list in
510@file{contrib.texi}.
511@item
512Information about support for that language in
513@file{gcc/doc/frontends.texi}.
514@item
515Information about standards for that language, and the front end's
516support for them, in @file{gcc/doc/standards.texi}. This may be a
517link to such information in the front end's own manual.
518@item
519Details of source file suffixes for that language and @option{-x
520@var{lang}} options supported, in @file{gcc/doc/invoke.texi}.
521@item
522Entries in @code{default_compilers} in @file{gcc.c} for source file
523suffixes for that language.
524@item
2eac577f 525Preferably testsuites, which may be under @file{gcc/testsuite} or
0a553c7e 526runtime library directories. FIXME: document somewhere how to write
2eac577f 527testsuite harnesses.
0a553c7e
JM
528@item
529Probably a runtime library for the language, outside the @file{gcc}
530directory. FIXME: document this further.
531@item
532Details of the directories of any runtime libraries in
533@file{gcc/doc/sourcebuild.texi}.
60911f14 534@item
3a1ef68a
RO
535Check targets in @file{Makefile.def} for the top-level @file{Makefile}
536to check just the compiler or the compiler and runtime library for the
537language.
0a553c7e
JM
538@end itemize
539
5dc81ee9 540If the front end is added to the official GCC source repository, the
0a553c7e
JM
541following are also necessary:
542
543@itemize @bullet
544@item
c487d8b6 545At least one Bugzilla component for bugs in that front end and runtime
fda9c731 546libraries. This category needs to be added to the Bugzilla database.
0a553c7e
JM
547@item
548Normally, one or more maintainers of that front end listed in
549@file{MAINTAINERS}.
550@item
551Mentions on the GCC web site in @file{index.html} and
552@file{frontends.html}, with any relevant links on
553@file{readings.html}. (Front ends that are not an official part of
554GCC may also be listed on @file{frontends.html}, with relevant links.)
555@item
556A news item on @file{index.html}, and possibly an announcement on the
557@email{gcc-announce@@gcc.gnu.org} mailing list.
558@item
559The front end's manuals should be mentioned in
822a338e 560@file{maintainer-scripts/update_web_docs_svn} (@pxref{Texinfo Manuals})
0a553c7e
JM
561and the online manuals should be linked to from
562@file{onlinedocs/index.html}.
563@item
564Any old releases or CVS repositories of the front end, before its
565inclusion in GCC, should be made available on the GCC FTP site
566@uref{ftp://gcc.gnu.org/pub/gcc/old-releases/}.
567@item
568The release and snapshot script @file{maintainer-scripts/gcc_release}
569should be updated to generate appropriate tarballs for this front end.
570@item
571If this front end includes its own version files that include the
572current date, @file{maintainer-scripts/update_version} should be
573updated accordingly.
0a553c7e
JM
574@end itemize
575
576@menu
577* Front End Directory:: The front end @file{@var{language}} directory.
578* Front End Config:: The front end @file{config-lang.in} file.
3a1ef68a 579* Front End Makefile:: The front end @file{Make-lang.in} file.
0a553c7e
JM
580@end menu
581
582@node Front End Directory
583@subsubsection The Front End @file{@var{language}} Directory
584
585A front end @file{@var{language}} directory contains the source files
586of that front end (but not of any runtime libraries, which should be
587outside the @file{gcc} directory). This includes documentation, and
3a1ef68a 588possibly some subsidiary programs built alongside the front end.
0a553c7e
JM
589Certain files are special and other parts of the compiler depend on
590their names:
591
592@table @file
593@item config-lang.in
594This file is required in all language subdirectories. @xref{Front End
595Config, , The Front End @file{config-lang.in} File}, for details of
596its contents
597@item Make-lang.in
3a1ef68a
RO
598This file is required in all language subdirectories. @xref{Front End
599Makefile, , The Front End @file{Make-lang.in} File}, for details of its
600contents.
601@item lang.opt
602This file registers the set of switches that the front end accepts on
603the command line, and their @option{--help} text. @xref{Options}.
604@item lang-specs.h
605This file provides entries for @code{default_compilers} in
606@file{gcc.c} which override the default of giving an error that a
607compiler for that language is not installed.
608@item @var{language}-tree.def
609This file, which need not exist, defines any language-specific tree
610codes.
611@end table
612
613@node Front End Config
614@subsubsection The Front End @file{config-lang.in} File
615
d4a10d0a
SB
616Each language subdirectory contains a @file{config-lang.in} file.
617This file is a shell script that may define some variables describing
618the language:
3a1ef68a
RO
619
620@table @code
621@item language
622This definition must be present, and gives the name of the language
623for some purposes such as arguments to @option{--enable-languages}.
624@item lang_requires
625If defined, this variable lists (space-separated) language front ends
626other than C that this front end requires to be enabled (with the
627names given being their @code{language} settings). For example, the
97a2feb6
MK
628Obj-C++ front end depends on the C++ and ObjC front ends, so sets
629@samp{lang_requires="objc c++"}.
3a1ef68a
RO
630@item subdir_requires
631If defined, this variable lists (space-separated) front end directories
632other than C that this front end requires to be present. For example,
633the Objective-C++ front end uses source files from the C++ and
634Objective-C front ends, so sets @samp{subdir_requires="cp objc"}.
635@item target_libs
636If defined, this variable lists (space-separated) targets in the top
637level @file{Makefile} to build the runtime libraries for this
638language, such as @code{target-libobjc}.
639@item lang_dirs
640If defined, this variable lists (space-separated) top level
641directories (parallel to @file{gcc}), apart from the runtime libraries,
642that should not be configured if this front end is not built.
643@item build_by_default
644If defined to @samp{no}, this language front end is not built unless
645enabled in a @option{--enable-languages} argument. Otherwise, front
646ends are built by default, subject to any special logic in
647@file{configure.ac} (as is present to disable the Ada front end if the
648Ada compiler is not already installed).
649@item boot_language
650If defined to @samp{yes}, this front end is built in stage1 of the
651bootstrap. This is only relevant to front ends written in their own
652languages.
653@item compilers
654If defined, a space-separated list of compiler executables that will
655be run by the driver. The names here will each end
656with @samp{\$(exeext)}.
657@item outputs
658If defined, a space-separated list of files that should be generated
659by @file{configure} substituting values in them. This mechanism can
660be used to create a file @file{@var{language}/Makefile} from
661@file{@var{language}/Makefile.in}, but this is deprecated, building
662everything from the single @file{gcc/Makefile} is preferred.
663@item gtfiles
664If defined, a space-separated list of files that should be scanned by
665@file{gengtype.c} to generate the garbage collection tables and routines for
666this language. This excludes the files that are common to all front
667ends. @xref{Type Information}.
668
669@end table
670
671@node Front End Makefile
672@subsubsection The Front End @file{Make-lang.in} File
673
674Each language subdirectory contains a @file{Make-lang.in} file. It contains
0a553c7e
JM
675targets @code{@var{lang}.@var{hook}} (where @code{@var{lang}} is the
676setting of @code{language} in @file{config-lang.in}) for the following
677values of @code{@var{hook}}, and any other Makefile rules required to
678build those targets (which may if necessary use other Makefiles
679specified in @code{outputs} in @file{config-lang.in}, although this is
880b9e7b 680deprecated). It also adds any testsuite targets that can use the
49a41726
JM
681standard rule in @file{gcc/Makefile.in} to the variable
682@code{lang_checks}.
0a553c7e
JM
683
684@table @code
f457c50c 685@item all.cross
0a553c7e
JM
686@itemx start.encap
687@itemx rest.encap
688FIXME: exactly what goes in each of these targets?
65ebbf81
TT
689@item tags
690Build an @command{etags} @file{TAGS} file in the language subdirectory
691in the source tree.
0a553c7e 692@item info
ce5c1cf3 693Build info documentation for the front end, in the build directory.
7ba4ca63 694This target is only called by @samp{make bootstrap} if a suitable
0a553c7e 695version of @command{makeinfo} is available, so does not need to check
ce5c1cf3 696for this, and should fail if an error occurs.
0a553c7e
JM
697@item dvi
698Build DVI documentation for the front end, in the build directory.
699This should be done using @code{$(TEXI2DVI)}, with appropriate
700@option{-I} arguments pointing to directories of included files.
cc5c2741
BM
701@item pdf
702Build PDF documentation for the front end, in the build directory.
703This should be done using @code{$(TEXI2PDF)}, with appropriate
704@option{-I} arguments pointing to directories of included files.
9d65c5cb 705@item html
0e8f8fea 706Build HTML documentation for the front end, in the build directory.
ce5c1cf3 707@item man
0a553c7e 708Build generated man pages for the front end from Texinfo manuals
ce5c1cf3 709(@pxref{Man Page Generation}), in the build directory. This target
0a553c7e
JM
710is only called if the necessary tools are available, but should ignore
711errors so as not to stop the build if errors occur; man pages are
712optional and the tools involved may be installed in a broken way.
0a553c7e
JM
713@item install-common
714Install everything that is part of the front end, apart from the
715compiler executables listed in @code{compilers} in
8e5f33ff 716@file{config-lang.in}.
0a553c7e
JM
717@item install-info
718Install info documentation for the front end, if it is present in the
97ae108d 719source directory. This target should have dependencies on info files
880b9e7b 720that should be installed.
0a553c7e
JM
721@item install-man
722Install man pages for the front end. This target should ignore
723errors.
2a4c0366
TG
724@item install-plugin
725Install headers needed for plugins.
ce5c1cf3
KC
726@item srcextra
727Copies its dependencies into the source directory. This generally should
da543234 728be used for generated files such as Bison output files which are not
3a1ef68a 729version-controlled, but should be included in any release tarballs. This
ce5c1cf3
KC
730target will be executed during a bootstrap if
731@samp{--enable-generated-files-in-srcdir} was specified as a
732@file{configure} option.
733@item srcinfo
734@itemx srcman
735Copies its dependencies into the source directory. These targets will be
736executed during a bootstrap if @samp{--enable-generated-files-in-srcdir}
737was specified as a @file{configure} option.
0a553c7e
JM
738@item uninstall
739Uninstall files installed by installing the compiler. This is
740currently documented not to be supported, so the hook need not do
741anything.
742@item mostlyclean
743@itemx clean
744@itemx distclean
0a553c7e 745@itemx maintainer-clean
a03ad584 746The language parts of the standard GNU
8a36672b 747@samp{*clean} targets. @xref{Standard Targets, , Standard Targets for
0a553c7e 748Users, standards, GNU Coding Standards}, for details of the standard
a03ad584 749targets. For GCC, @code{maintainer-clean} should delete
3a1ef68a
RO
750all generated files in the source directory that are not version-controlled,
751but should not delete anything that is.
0a553c7e
JM
752@end table
753
6cba282a
TT
754@file{Make-lang.in} must also define a variable @code{@var{lang}_OBJS}
755to a list of host object files that are used by that language.
756
0a553c7e
JM
757@node Back End
758@subsection Anatomy of a Target Back End
759
760A back end for a target architecture in GCC has the following parts:
761
762@itemize @bullet
763@item
764A directory @file{@var{machine}} under @file{gcc/config}, containing a
765machine description @file{@var{machine}.md} file (@pxref{Machine Desc,
766, Machine Descriptions}), header files @file{@var{machine}.h} and
767@file{@var{machine}-protos.h} and a source file @file{@var{machine}.c}
768(@pxref{Target Macros, , Target Description Macros and Functions}),
769possibly a target Makefile fragment @file{t-@var{machine}}
770(@pxref{Target Fragment, , The Target Makefile Fragment}), and maybe
771some other files. The names of these files may be changed from the
772defaults given by explicit specifications in @file{config.gcc}.
773@item
a5381466
ZW
774If necessary, a file @file{@var{machine}-modes.def} in the
775@file{@var{machine}} directory, containing additional machine modes to
776represent condition codes. @xref{Condition Code}, for further details.
777@item
75685792
RS
778An optional @file{@var{machine}.opt} file in the @file{@var{machine}}
779directory, containing a list of target-specific options. You can also
780add other option files using the @code{extra_options} variable in
781@file{config.gcc}. @xref{Options}.
782@item
0a553c7e
JM
783Entries in @file{config.gcc} (@pxref{System Config, , The
784@file{config.gcc} File}) for the systems with this target
785architecture.
786@item
787Documentation in @file{gcc/doc/invoke.texi} for any command-line
788options supported by this target (@pxref{Run-time Target, , Run-time
789Target Specification}). This means both entries in the summary table
790of options and details of the individual options.
791@item
792Documentation in @file{gcc/doc/extend.texi} for any target-specific
793attributes supported (@pxref{Target Attributes, , Defining
794target-specific uses of @code{__attribute__}}), including where the
795same attribute is already supported on some targets, which are
796enumerated in the manual.
797@item
798Documentation in @file{gcc/doc/extend.texi} for any target-specific
799pragmas supported.
800@item
0975678f
JM
801Documentation in @file{gcc/doc/extend.texi} of any target-specific
802built-in functions supported.
0a553c7e 803@item
a2bec818
DJ
804Documentation in @file{gcc/doc/extend.texi} of any target-specific
805format checking styles supported.
806@item
0a553c7e
JM
807Documentation in @file{gcc/doc/md.texi} of any target-specific
808constraint letters (@pxref{Machine Constraints, , Constraints for
809Particular Machines}).
810@item
811A note in @file{gcc/doc/contrib.texi} under the person or people who
812contributed the target support.
813@item
814Entries in @file{gcc/doc/install.texi} for all target triplets
815supported with this target architecture, giving details of any special
816notes about installation for this target, or saying that there are no
817special notes if there are none.
818@item
819Possibly other support outside the @file{gcc} directory for runtime
3a1ef68a 820libraries. FIXME: reference docs for this. The @code{libstdc++} porting
0a553c7e
JM
821manual needs to be installed as info for this to work, or to be a
822chapter of this manual.
823@end itemize
824
5dc81ee9 825If the back end is added to the official GCC source repository, the
0a553c7e
JM
826following are also necessary:
827
828@itemize @bullet
829@item
830An entry for the target architecture in @file{readings.html} on the
831GCC web site, with any relevant links.
832@item
0acdc221
JM
833Details of the properties of the back end and target architecture in
834@file{backends.html} on the GCC web site.
835@item
0a553c7e
JM
836A news item about the contribution of support for that target
837architecture, in @file{index.html} on the GCC web site.
838@item
839Normally, one or more maintainers of that target listed in
840@file{MAINTAINERS}. Some existing architectures may be unmaintained,
841but it would be unusual to add support for a target that does not have
842a maintainer when support is added.
bcb521e9
JM
843@item
844Target triplets covering all @file{config.gcc} stanzas for the target,
845in the list in @file{contrib/config-list.mk}.
0a553c7e
JM
846@end itemize
847
2eac577f 848@node Testsuites
500cdcb0 849@chapter Testsuites
0a553c7e 850
2eac577f
JM
851GCC contains several testsuites to help maintain compiler quality.
852Most of the runtime libraries and language front ends in GCC have
853testsuites. Currently only the C language testsuites are documented
0a553c7e
JM
854here; FIXME: document the others.
855
856@menu
2eac577f 857* Test Idioms:: Idioms used in testsuite code.
35fdf04e 858* Test Directives:: Directives used within DejaGnu tests.
2eac577f
JM
859* Ada Tests:: The Ada language testsuites.
860* C Tests:: The C language testsuites.
d7f09764 861* LTO Testing:: Support for testing link-time optimizations.
138d4703
JJ
862* gcov Testing:: Support for testing gcov.
863* profopt Testing:: Support for testing profile-directed optimizations.
46b2356d 864* compat Testing:: Support for testing binary compatibility.
91a5b394 865* Torture Tests:: Support for torture testing using multiple options.
0a553c7e
JM
866@end menu
867
868@node Test Idioms
500cdcb0 869@section Idioms Used in Testsuite Code
0a553c7e 870
1eaf20ec 871In general, C testcases have a trailing @file{-@var{n}.c}, starting
4ef84575
JM
872with @file{-1.c}, in case other testcases with similar names are added
873later. If the test is a test of some well-defined feature, it should
874have a name referring to that feature such as
875@file{@var{feature}-1.c}. If it does not test a well-defined feature
876but just happens to exercise a bug somewhere in the compiler, and a
877bug report has been filed for this bug in the GCC bug database,
878@file{pr@var{bug-number}-1.c} is the appropriate form of name.
879Otherwise (for miscellaneous bugs not filed in the GCC bug database),
880and previously more generally, test cases are named after the date on
881which they were added. This allows people to tell at a glance whether
882a test failure is because of a recently found bug that has not yet
883been fixed, or whether it may be a regression, but does not give any
884other information about the bug or where discussion of it may be
885found. Some other language testsuites follow similar conventions.
0a553c7e 886
2eac577f 887In the @file{gcc.dg} testsuite, it is often necessary to test that an
0a553c7e
JM
888error is indeed a hard error and not just a warning---for example,
889where it is a constraint violation in the C standard, which must
890become an error with @option{-pedantic-errors}. The following idiom,
891where the first line shown is line @var{line} of the file and the line
892that generates the error, is used for this:
893
894@smallexample
895/* @{ dg-bogus "warning" "warning in place of error" @} */
896/* @{ dg-error "@var{regexp}" "@var{message}" @{ target *-*-* @} @var{line} @} */
897@end smallexample
898
899It may be necessary to check that an expression is an integer constant
900expression and has a certain value. To check that @code{@var{E}} has
901value @code{@var{V}}, an idiom similar to the following is used:
902
903@smallexample
904char x[((E) == (V) ? 1 : -1)];
905@end smallexample
906
907In @file{gcc.dg} tests, @code{__typeof__} is sometimes used to make
908assertions about the types of expressions. See, for example,
909@file{gcc.dg/c99-condexpr-1.c}. The more subtle uses depend on the
910exact rules for the types of conditional expressions in the C
911standard; see, for example, @file{gcc.dg/c99-intconst-1.c}.
912
913It is useful to be able to test that optimizations are being made
914properly. This cannot be done in all cases, but it can be done where
915the optimization will lead to code being optimized away (for example,
916where flow analysis or alias analysis should show that certain code
917cannot be called) or to functions not being called because they have
918been expanded as built-in functions. Such tests go in
919@file{gcc.c-torture/execute}. Where code should be optimized away, a
920call to a nonexistent function such as @code{link_failure ()} may be
921inserted; a definition
922
923@smallexample
924#ifndef __OPTIMIZE__
925void
926link_failure (void)
927@{
928 abort ();
929@}
930#endif
931@end smallexample
932
933@noindent
934will also be needed so that linking still succeeds when the test is
935run without optimization. When all calls to a built-in function
936should have been optimized and no calls to the non-built-in version of
937the function should remain, that function may be defined as
938@code{static} to call @code{abort ()} (although redeclaring a function
939as static may not work on all targets).
940
4b2ece8f
NN
941All testcases must be portable. Target-specific testcases must have
942appropriate code to avoid causing failures on unsupported systems;
943unfortunately, the mechanisms for this differ by directory.
944
2eac577f 945FIXME: discuss non-C testsuites here.
0a553c7e 946
35fdf04e 947@node Test Directives
500cdcb0 948@section Directives used within DejaGnu tests
35fdf04e 949
d4f3924a
JJ
950@menu
951* Directives:: Syntax and descriptions of test directives.
952* Selectors:: Selecting targets to which a test applies.
953* Effective-Target Keywords:: Keywords describing target attributes.
954* Add Options:: Features for @code{dg-add-options}
955* Require Support:: Variants of @code{dg-require-@var{support}}
956* Final Actions:: Commands for use in @code{dg-final}
957@end menu
958
959@node Directives
960@subsection Syntax and Descriptions of test directives
961
35fdf04e 962Test directives appear within comments in a test source file and begin
0ee5ccdf 963with @code{dg-}. Some of these are defined within DejaGnu and others
35fdf04e
JJ
964are local to the GCC testsuite.
965
966The order in which test directives appear in a test can be important:
967directives local to GCC sometimes override information used by the
968DejaGnu directives, which know nothing about the GCC directives, so the
969DejaGnu directives must precede GCC directives.
970
d4f3924a
JJ
971Several test directives include selectors (@pxref{Selectors, , })
972which are usually preceded by the keyword @code{target} or @code{xfail}.
8d2d2ec6 973
d4f3924a 974@subsubsection Specify how to build the test
35fdf04e
JJ
975
976@table @code
977@item @{ dg-do @var{do-what-keyword} [@{ target/xfail @var{selector} @}] @}
978@var{do-what-keyword} specifies how the test is compiled and whether
979it is executed. It is one of:
980
981@table @code
982@item preprocess
983Compile with @option{-E} to run only the preprocessor.
35fdf04e 984@item compile
e492980b
RIL
985Compile with @option{-S} to produce an assembly code file.
986@item assemble
35fdf04e
JJ
987Compile with @option{-c} to produce a relocatable object file.
988@item link
989Compile, assemble, and link to produce an executable file.
990@item run
991Produce and run an executable file, which is expected to return
992an exit code of 0.
993@end table
994
995The default is @code{compile}. That can be overridden for a set of
996tests by redefining @code{dg-do-what-default} within the @code{.exp}
997file for those tests.
998
999If the directive includes the optional @samp{@{ target @var{selector} @}}
d4f3924a
JJ
1000then the test is skipped unless the target system matches the
1001@var{selector}.
35fdf04e 1002
17a7cb4e 1003If @var{do-what-keyword} is @code{run} and the directive includes
fdaea7e2
JJ
1004the optional @samp{@{ xfail @var{selector} @}} and the selector is met
1005then the test is expected to fail. The @code{xfail} clause is ignored
17a7cb4e 1006for other values of @var{do-what-keyword}; those tests can use
fdaea7e2 1007directive @code{dg-xfail-if}.
d4f3924a
JJ
1008@end table
1009
1010@subsubsection Specify additional compiler options
35fdf04e 1011
d4f3924a 1012@table @code
35fdf04e
JJ
1013@item @{ dg-options @var{options} [@{ target @var{selector} @}] @}
1014This DejaGnu directive provides a list of compiler options, to be used
1015if the target system matches @var{selector}, that replace the default
1016options used for this set of tests.
1017
923158be 1018@item @{ dg-add-options @var{feature} @dots{} @}
db9a0df0
RS
1019Add any compiler options that are needed to access certain features.
1020This directive does nothing on targets that enable the features by
1021default, or that don't provide them at all. It must come after
1022all @code{dg-options} directives.
d4f3924a 1023For supported values of @var{feature} see @ref{Add Options, ,}.
91ffe356
RO
1024
1025@item @{ dg-additional-options @var{options} [@{ target @var{selector} @}] @}
1026This directive provides a list of compiler options, to be used
1027if the target system matches @var{selector}, that are added to the default
1028options used for this set of tests.
db9a0df0
RS
1029@end table
1030
d4f3924a
JJ
1031@subsubsection Modify the test timeout value
1032
1033The normal timeout limit, in seconds, is found by searching the
1034following in order:
d4038ca2
JJ
1035
1036@itemize @bullet
1037@item the value defined by an earlier @code{dg-timeout} directive in
1038the test
1039
1040@item variable @var{tool_timeout} defined by the set of tests
1041
e2f08cac 1042@item @var{gcc},@var{timeout} set in the target board
d4038ca2
JJ
1043
1044@item 300
1045@end itemize
1046
d4f3924a
JJ
1047@table @code
1048@item @{ dg-timeout @var{n} [@{target @var{selector} @}] @}
1049Set the time limit for the compilation and for the execution of the test
1050to the specified number of seconds.
1051
17a7cb4e
RO
1052@item @{ dg-timeout-factor @var{x} [@{ target @var{selector} @}] @}
1053Multiply the normal time limit for compilation and execution of the test
1054by the specified floating-point factor.
d4f3924a
JJ
1055@end table
1056
1057@subsubsection Skip a test for some targets
17a7cb4e 1058
d4f3924a 1059@table @code
8ec49cff 1060@item @{ dg-skip-if @var{comment} @{ @var{selector} @} [@{ @var{include-opts} @} [@{ @var{exclude-opts} @}]] @}
15e7a617
JJ
1061Arguments @var{include-opts} and @var{exclude-opts} are lists in which
1062each element is a string of zero or more GCC options.
1063Skip the test if all of the following conditions are met:
1064@itemize @bullet
1065@item the test system is included in @var{selector}
1066
1067@item for at least one of the option strings in @var{include-opts},
1068every option from that string is in the set of options with which
1069the test would be compiled; use @samp{"*"} for an @var{include-opts} list
8ec49cff
JJ
1070that matches any options; that is the default if @var{include-opts} is
1071not specified
15e7a617
JJ
1072
1073@item for each of the option strings in @var{exclude-opts}, at least one
1074option from that string is not in the set of options with which the test
8ec49cff
JJ
1075would be compiled; use @samp{""} for an empty @var{exclude-opts} list;
1076that is the default if @var{exclude-opts} is not specified
15e7a617
JJ
1077@end itemize
1078
1079For example, to skip a test if option @code{-Os} is present:
1080
1081@smallexample
1082/* @{ dg-skip-if "" @{ *-*-* @} @{ "-Os" @} @{ "" @} @} */
1083@end smallexample
1084
1085To skip a test if both options @code{-O2} and @code{-g} are present:
1086
1087@smallexample
1088/* @{ dg-skip-if "" @{ *-*-* @} @{ "-O2 -g" @} @{ "" @} @} */
1089@end smallexample
1090
1091To skip a test if either @code{-O2} or @code{-O3} is present:
1092
1093@smallexample
1094/* @{ dg-skip-if "" @{ *-*-* @} @{ "-O2" "-O3" @} @{ "" @} @} */
1095@end smallexample
1096
d4f3924a 1097To skip a test unless option @code{-Os} is present:
15e7a617
JJ
1098
1099@smallexample
1100/* @{ dg-skip-if "" @{ *-*-* @} @{ "*" @} @{ "-Os" @} @} */
1101@end smallexample
1102
1103To skip a test if either @code{-O2} or @code{-O3} is used with @code{-g}
1104but not if @code{-fpic} is also present:
1105
1106@smallexample
1107/* @{ dg-skip-if "" @{ *-*-* @} @{ "-O2 -g" "-O3 -g" @} @{ "-fpic" @} @} */
1108@end smallexample
35fdf04e 1109
40f1bdd9 1110@item @{ dg-require-effective-target @var{keyword} [@{ @var{selector} @}] @}
d4f3924a
JJ
1111Skip the test if the test target, including current multilib flags,
1112is not covered by the effective-target keyword.
40f1bdd9
RO
1113If the directive includes the optional @samp{@{ @var{selector} @}}
1114then the effective-target test is only performed if the target system
1115matches the @var{selector}.
d4f3924a
JJ
1116This directive must appear after any @code{dg-do} directive in the test
1117and before any @code{dg-additional-sources} directive.
1118@xref{Effective-Target Keywords, , }.
35fdf04e
JJ
1119
1120@item @{ dg-require-@var{support} args @}
d4f3924a 1121Skip the test if the target does not provide the required support.
9f143763
JJ
1122These directives must appear after any @code{dg-do} directive in the test
1123and before any @code{dg-additional-sources} directive.
35fdf04e
JJ
1124They require at least one argument, which can be an empty string if the
1125specific procedure does not examine the argument.
d4f3924a
JJ
1126@xref{Require Support, , }, for a complete list of these directives.
1127@end table
35fdf04e 1128
d4f3924a
JJ
1129@subsubsection Expect a test to fail for some targets
1130
1131@table @code
1132@item @{ dg-xfail-if @var{comment} @{ @var{selector} @} [@{ @var{include-opts} @} [@{ @var{exclude-opts} @}]] @}
1133Expect the test to fail if the conditions (which are the same as for
1134@code{dg-skip-if}) are met. This does not affect the execute step.
1135
1136@item @{ dg-xfail-run-if @var{comment} @{ @var{selector} @} [@{ @var{include-opts} @} [@{ @var{exclude-opts} @}]] @}
1137Expect the execute step of a test to fail if the conditions (which are
1138the same as for @code{dg-skip-if}) are met.
1139@end table
1140
1141@subsubsection Expect the test executable to fail
35fdf04e 1142
d4f3924a 1143@table @code
8ec49cff 1144@item @{ dg-shouldfail @var{comment} [@{ @var{selector} @} [@{ @var{include-opts} @} [@{ @var{exclude-opts} @}]]] @}
263108e1
JJ
1145Expect the test executable to return a nonzero exit status if the
1146conditions (which are the same as for @code{dg-skip-if}) are met.
d4f3924a
JJ
1147@end table
1148
1149@subsubsection Verify compiler messages
263108e1 1150
d4f3924a 1151@table @code
8964d5aa 1152@item @{ dg-error @var{regexp} [@var{comment} [@{ target/xfail @var{selector} @} [@var{line}] ]] @}
35fdf04e
JJ
1153This DejaGnu directive appears on a source line that is expected to get
1154an error message, or else specifies the source line associated with the
1155message. If there is no message for that line or if the text of that
1156message is not matched by @var{regexp} then the check fails and
1157@var{comment} is included in the @code{FAIL} message. The check does
d4f3924a 1158not look for the string @samp{error} unless it is part of @var{regexp}.
35fdf04e 1159
8964d5aa 1160@item @{ dg-warning @var{regexp} [@var{comment} [@{ target/xfail @var{selector} @} [@var{line}] ]] @}
35fdf04e
JJ
1161This DejaGnu directive appears on a source line that is expected to get
1162a warning message, or else specifies the source line associated with the
1163message. If there is no message for that line or if the text of that
1164message is not matched by @var{regexp} then the check fails and
1165@var{comment} is included in the @code{FAIL} message. The check does
d4f3924a 1166not look for the string @samp{warning} unless it is part of @var{regexp}.
35fdf04e 1167
8964d5aa 1168@item @{ dg-message @var{regexp} [@var{comment} [@{ target/xfail @var{selector} @} [@var{line}] ]] @}
ba2f32a9
JJ
1169The line is expected to get a message other than an error or warning.
1170If there is no message for that line or if the text of that message is
1171not matched by @var{regexp} then the check fails and @var{comment} is
1172included in the @code{FAIL} message.
1173
8964d5aa 1174@item @{ dg-bogus @var{regexp} [@var{comment} [@{ target/xfail @var{selector} @} [@var{line}] ]] @}
35fdf04e
JJ
1175This DejaGnu directive appears on a source line that should not get a
1176message matching @var{regexp}, or else specifies the source line
1177associated with the bogus message. It is usually used with @samp{xfail}
1178to indicate that the message is a known problem for a particular set of
1179targets.
1180
1181@item @{ dg-excess-errors @var{comment} [@{ target/xfail @var{selector} @}] @}
1182This DejaGnu directive indicates that the test is expected to fail due
cc95a845 1183to compiler messages that are not handled by @samp{dg-error},
ce396345
JJ
1184@samp{dg-warning} or @samp{dg-bogus}. For this directive @samp{xfail}
1185has the same effect as @samp{target}.
35fdf04e 1186
d4f3924a
JJ
1187@item @{ dg-prune-output @var{regexp} @}
1188Prune messages matching @var{regexp} from the test output.
1189@end table
1190
1191@subsubsection Verify output of the test executable
1192
1193@table @code
35fdf04e
JJ
1194@item @{ dg-output @var{regexp} [@{ target/xfail @var{selector} @}] @}
1195This DejaGnu directive compares @var{regexp} to the combined output
1196that the test executable writes to @file{stdout} and @file{stderr}.
d4f3924a 1197@end table
35fdf04e 1198
d4f3924a 1199@subsubsection Specify additional files for a test
35fdf04e 1200
d4f3924a 1201@table @code
35fdf04e
JJ
1202@item @{ dg-additional-files "@var{filelist}" @}
1203Specify additional files, other than source files, that must be copied
1204to the system where the compiler runs.
1205
1206@item @{ dg-additional-sources "@var{filelist}" @}
1207Specify additional source files to appear in the compile line
1208following the main test file.
d4f3924a 1209@end table
35fdf04e 1210
d4f3924a
JJ
1211@subsubsection Add checks at the end of a test
1212
1213@table @code
35fdf04e
JJ
1214@item @{ dg-final @{ @var{local-directive} @} @}
1215This DejaGnu directive is placed within a comment anywhere in the
1216source file and is processed after the test has been compiled and run.
cc95a845 1217Multiple @samp{dg-final} commands are processed in the order in which
d4f3924a
JJ
1218they appear in the source file. @xref{Final Actions, , }, for a list
1219of directives that can be used within @code{dg-final}.
1220@end table
35fdf04e 1221
d4f3924a
JJ
1222@node Selectors
1223@subsection Selecting targets to which a test applies
1224
1225Several test directives include @var{selector}s to limit the targets
1226for which a test is run or to declare that a test is expected to fail
1227on particular targets.
1228
1229A selector is:
1230@itemize @bullet
776de6b2
JJ
1231@item one or more target triplets, possibly including wildcard characters;
1232use @samp{*-*-*} to match any target
d4f3924a
JJ
1233@item a single effective-target keyword (@pxref{Effective-Target Keywords})
1234@item a logical expression
1235@end itemize
1236
776de6b2
JJ
1237Depending on the context, the selector specifies whether a test is
1238skipped and reported as unsupported or is expected to fail. A context
1239that allows either @samp{target} or @samp{xfail} also allows
1240@samp{@{ target @var{selector1} xfail @var{selector2} @}}
1241to skip the test for targets that don't match @var{selector1} and the
1242test to fail for targets that match @var{selector2}.
d4f3924a
JJ
1243
1244A selector expression appears within curly braces and uses a single
1245logical operator: one of @samp{!}, @samp{&&}, or @samp{||}. An
1246operand is another selector expression, an effective-target keyword,
1247a single target triplet, or a list of target triplets within quotes or
1248curly braces. For example:
1249
1250@smallexample
1251@{ target @{ ! "hppa*-*-* ia64*-*-*" @} @}
1252@{ target @{ powerpc*-*-* && lp64 @} @}
1253@{ xfail @{ lp64 || vect_no_align @} @}
1254@end smallexample
1255
1256@node Effective-Target Keywords
1257@subsection Keywords describing target attributes
1258
1259Effective-target keywords identify sets of targets that support
1260particular functionality. They are used to limit tests to be run only
1261for particular targets, or to specify that particular sets of targets
1262are expected to fail some tests.
1263
1264Effective-target keywords are defined in @file{lib/target-supports.exp} in
1265the GCC testsuite, with the exception of those that are documented as
1266being local to a particular test directory.
1267
1268The @samp{effective target} takes into account all of the compiler options
1269with which the test will be compiled, including the multilib options.
1270By convention, keywords ending in @code{_nocache} can also include options
1271specified for the particular test in an earlier @code{dg-options} or
1272@code{dg-add-options} directive.
1273
1274@subsubsection Data type sizes
35fdf04e
JJ
1275
1276@table @code
d4f3924a
JJ
1277@item ilp32
1278Target has 32-bit @code{int}, @code{long}, and pointers.
0455fecf 1279
d4f3924a
JJ
1280@item lp64
1281Target has 32-bit @code{int}, 64-bit @code{long} and pointers.
0455fecf 1282
d4f3924a
JJ
1283@item llp64
1284Target has 32-bit @code{int} and @code{long}, 64-bit @code{long long}
1285and pointers.
0455fecf 1286
d4f3924a
JJ
1287@item double64
1288Target has 64-bit @code{double}.
0455fecf 1289
d4f3924a
JJ
1290@item double64plus
1291Target has @code{double} that is 64 bits or longer.
1292
8241efd1
PB
1293@item longdouble128
1294Target has 128-bit @code{long double}.
1295
d4f3924a
JJ
1296@item int32plus
1297Target has @code{int} that is at 32 bits or longer.
1298
1299@item int16
1300Target has @code{int} that is 16 bits or shorter.
1301
75bc3841
BS
1302@item long_neq_int
1303Target has @code{int} and @code{long} with different sizes.
1304
d4f3924a
JJ
1305@item large_double
1306Target supports @code{double} that is longer than @code{float}.
1307
1308@item large_long_double
1309Target supports @code{long double} that is longer than @code{double}.
1310
1311@item ptr32plus
1312Target has pointers that are 32 bits or longer.
1313
1314@item size32plus
1315Target supports array and structure sizes that are 32 bits or longer.
1316
1317@item 4byte_wchar_t
1318Target has @code{wchar_t} that is at least 4 bytes.
c65699ef
JM
1319
1320@item float@var{n}
1321Target has the @code{_Float@var{n}} type.
1322
1323@item float@var{n}x
1324Target has the @code{_Float@var{n}x} type.
1325
1326@item float@var{n}_runtime
1327Target has the @code{_Float@var{n}} type, including runtime support
1328for any options added with @code{dg-add-options}.
1329
1330@item float@var{n}x_runtime
1331Target has the @code{_Float@var{n}x} type, including runtime support
1332for any options added with @code{dg-add-options}.
1333
1334@item floatn_nx_runtime
1335Target has runtime support for any options added with
1336@code{dg-add-options} for any @code{_Float@var{n}} or
1337@code{_Float@var{n}x} type.
d4f3924a
JJ
1338@end table
1339
1340@subsubsection Fortran-specific attributes
1341
1342@table @code
1343@item fortran_integer_16
1344Target supports Fortran @code{integer} that is 16 bytes or longer.
1345
1346@item fortran_large_int
1347Target supports Fortran @code{integer} kinds larger than @code{integer(8)}.
1348
1349@item fortran_large_real
1350Target supports Fortran @code{real} kinds larger than @code{real(8)}.
1351@end table
1352
1353@subsubsection Vector-specific attributes
1354
1355@table @code
1356@item vect_condition
1357Target supports vector conditional operations.
1358
5a02adf6
BC
1359@item vect_cond_mixed
1360Target supports vector conditional operations where comparison operands
1361have different type from the value operands.
1362
d4f3924a
JJ
1363@item vect_double
1364Target supports hardware vectors of @code{double}.
1365
1366@item vect_float
1367Target supports hardware vectors of @code{float}.
1368
1369@item vect_int
1370Target supports hardware vectors of @code{int}.
1371
d4f3924a
JJ
1372@item vect_long
1373Target supports hardware vectors of @code{long}.
1374
1375@item vect_long_long
1376Target supports hardware vectors of @code{long long}.
1377
1378@item vect_aligned_arrays
1379Target aligns arrays to vector alignment boundary.
1380
1381@item vect_hw_misalign
1382Target supports a vector misalign access.
1383
1384@item vect_no_align
1385Target does not support a vector alignment mechanism.
1386
1b950569
TV
1387@item vect_no_int_min_max
1388Target does not support a vector min and max instruction on @code{int}.
d4f3924a
JJ
1389
1390@item vect_no_int_add
1391Target does not support a vector add instruction on @code{int}.
1392
1393@item vect_no_bitwise
1394Target does not support vector bitwise instructions.
1395
1396@item vect_char_mult
1397Target supports @code{vector char} multiplication.
1398
1399@item vect_short_mult
1400Target supports @code{vector short} multiplication.
1401
1402@item vect_int_mult
1403Target supports @code{vector int} multiplication.
1404
1405@item vect_extract_even_odd
1406Target supports vector even/odd element extraction.
1407
1408@item vect_extract_even_odd_wide
1409Target supports vector even/odd element extraction of vectors with elements
1410@code{SImode} or larger.
1411
1412@item vect_interleave
1413Target supports vector interleaving.
1414
1415@item vect_strided
1416Target supports vector interleaving and extract even/odd.
1417
1418@item vect_strided_wide
1419Target supports vector interleaving and extract even/odd for wide
1420element types.
1421
1422@item vect_perm
1423Target supports vector permutation.
1424
1425@item vect_shift
1426Target supports a hardware vector shift operation.
1427
1428@item vect_widen_sum_hi_to_si
1429Target supports a vector widening summation of @code{short} operands
1430into @code{int} results, or can promote (unpack) from @code{short}
1431to @code{int}.
1432
1433@item vect_widen_sum_qi_to_hi
1434Target supports a vector widening summation of @code{char} operands
1435into @code{short} results, or can promote (unpack) from @code{char}
1436to @code{short}.
1437
1438@item vect_widen_sum_qi_to_si
1439Target supports a vector widening summation of @code{char} operands
1440into @code{int} results.
1441
1442@item vect_widen_mult_qi_to_hi
1443Target supports a vector widening multiplication of @code{char} operands
1444into @code{short} results, or can promote (unpack) from @code{char} to
1445@code{short} and perform non-widening multiplication of @code{short}.
1446
1447@item vect_widen_mult_hi_to_si
1448Target supports a vector widening multiplication of @code{short} operands
1449into @code{int} results, or can promote (unpack) from @code{short} to
1450@code{int} and perform non-widening multiplication of @code{int}.
1451
5d1a5a53
CH
1452@item vect_widen_mult_si_to_di_pattern
1453Target supports a vector widening multiplication of @code{int} operands
1454into @code{long} results.
1455
d4f3924a
JJ
1456@item vect_sdot_qi
1457Target supports a vector dot-product of @code{signed char}.
1458
1459@item vect_udot_qi
1460Target supports a vector dot-product of @code{unsigned char}.
1461
1462@item vect_sdot_hi
1463Target supports a vector dot-product of @code{signed short}.
1464
1465@item vect_udot_hi
1466Target supports a vector dot-product of @code{unsigned short}.
1467
1468@item vect_pack_trunc
1469Target supports a vector demotion (packing) of @code{short} to @code{char}
1470and from @code{int} to @code{short} using modulo arithmetic.
1471
1472@item vect_unpack
1473Target supports a vector promotion (unpacking) of @code{char} to @code{short}
1474and from @code{char} to @code{int}.
1475
1476@item vect_intfloat_cvt
1477Target supports conversion from @code{signed int} to @code{float}.
1478
1479@item vect_uintfloat_cvt
1480Target supports conversion from @code{unsigned int} to @code{float}.
1481
1482@item vect_floatint_cvt
1483Target supports conversion from @code{float} to @code{signed int}.
1484
1485@item vect_floatuint_cvt
1486Target supports conversion from @code{float} to @code{unsigned int}.
af29617a
AH
1487
1488@item vect_max_reduc
1489Target supports max reduction for vectors.
d4f3924a
JJ
1490@end table
1491
1492@subsubsection Thread Local Storage attributes
1493
1494@table @code
1495@item tls
1496Target supports thread-local storage.
1497
1498@item tls_native
1499Target supports native (rather than emulated) thread-local storage.
1500
1501@item tls_runtime
1502Test system supports executing TLS executables.
1503@end table
1504
1505@subsubsection Decimal floating point attributes
1506
1507@table @code
1508@item dfp
1509Targets supports compiling decimal floating point extension to C.
1510
1511@item dfp_nocache
1512Including the options used to compile this particular test, the
1513target supports compiling decimal floating point extension to C.
1514
1515@item dfprt
1516Test system can execute decimal floating point tests.
1517
1518@item dfprt_nocache
1519Including the options used to compile this particular test, the
1520test system can execute decimal floating point tests.
1521
1522@item hard_dfp
1523Target generates decimal floating point instructions with current options.
1524@end table
1525
1526@subsubsection ARM-specific attributes
1527
1528@table @code
1529@item arm32
1530ARM target generates 32-bit code.
1531
1532@item arm_eabi
1533ARM target adheres to the ABI for the ARM Architecture.
1534
d7cf3dc7
CL
1535@item arm_fp_ok
1536@anchor{arm_fp_ok}
1537ARM target defines @code{__ARM_FP} using @code{-mfloat-abi=softfp} or
1538equivalent options. Some multilibs may be incompatible with these
1539options.
1540
552b56fc
JB
1541@item arm_hf_eabi
1542ARM target adheres to the VFP and Advanced SIMD Register Arguments
1543variant of the ABI for the ARM Architecture (as selected with
1544@code{-mfloat-abi=hard}).
1545
d4f3924a
JJ
1546@item arm_hard_vfp_ok
1547ARM target supports @code{-mfpu=vfp -mfloat-abi=hard}.
1548Some multilibs may be incompatible with these options.
1549
1550@item arm_iwmmxt_ok
1551ARM target supports @code{-mcpu=iwmmxt}.
1552Some multilibs may be incompatible with this option.
1553
1554@item arm_neon
1555ARM target supports generating NEON instructions.
1556
d45c2a1b
BC
1557@item arm_tune_string_ops_prefer_neon
1558Test CPU tune supports inlining string operations with NEON instructions.
1559
d4f3924a
JJ
1560@item arm_neon_hw
1561Test system supports executing NEON instructions.
1562
8b2ab9cb
RR
1563@item arm_neonv2_hw
1564Test system supports executing NEON v2 instructions.
1565
d4f3924a 1566@item arm_neon_ok
0c422e74
DJ
1567@anchor{arm_neon_ok}
1568ARM Target supports @code{-mfpu=neon -mfloat-abi=softfp} or compatible
1569options. Some multilibs may be incompatible with these options.
1570
8b2ab9cb 1571@item arm_neonv2_ok
178a71a9
RR
1572@anchor{arm_neonv2_ok}
1573ARM Target supports @code{-mfpu=neon-vfpv4 -mfloat-abi=softfp} or compatible
8b2ab9cb
RR
1574options. Some multilibs may be incompatible with these options.
1575
7fe43755
MW
1576@item arm_fp16_ok
1577@anchor{arm_fp16_ok}
1578Target supports options to generate VFP half-precision floating-point
1579instructions. Some multilibs may be incompatible with these
1580options. This test is valid for ARM only.
1581
1582@item arm_fp16_hw
1583Target supports executing VFP half-precision floating-point
1584instructions. This test is valid for ARM only.
1585
0c422e74
DJ
1586@item arm_neon_fp16_ok
1587@anchor{arm_neon_fp16_ok}
1588ARM Target supports @code{-mfpu=neon-fp16 -mfloat-abi=softfp} or compatible
48c44783
AL
1589options, including @code{-mfp16-format=ieee} if necessary to obtain the
1590@code{__fp16} type. Some multilibs may be incompatible with these options.
1591
1592@item arm_neon_fp16_hw
1593Test system supports executing Neon half-precision float instructions.
1594(Implies previous.)
d4f3924a 1595
a5b42ee7
MW
1596@item arm_fp16_alternative_ok
1597ARM target supports the ARM FP16 alternative format. Some multilibs
1598may be incompatible with the options needed.
1599
1600@item arm_fp16_none_ok
1601ARM target supports specifying none as the ARM FP16 format.
1602
d4f3924a
JJ
1603@item arm_thumb1_ok
1604ARM target generates Thumb-1 code for @code{-mthumb}.
1605
1606@item arm_thumb2_ok
1607ARM target generates Thumb-2 code for @code{-mthumb}.
1608
1609@item arm_vfp_ok
1610ARM target supports @code{-mfpu=vfp -mfloat-abi=softfp}.
1611Some multilibs may be incompatible with these options.
cf5607f8 1612
6d3715b9 1613@item arm_vfp3_ok
e332c729 1614@anchor{arm_vfp3_ok}
6d3715b9
RL
1615ARM target supports @code{-mfpu=vfp3 -mfloat-abi=softfp}.
1616Some multilibs may be incompatible with these options.
1617
e3f9361d
KT
1618@item arm_v8_vfp_ok
1619ARM target supports @code{-mfpu=fp-armv8 -mfloat-abi=softfp}.
1620Some multilibs may be incompatible with these options.
1621
71aa66e4
KT
1622@item arm_v8_neon_ok
1623ARM target supports @code{-mfpu=neon-fp-armv8 -mfloat-abi=softfp}.
1624Some multilibs may be incompatible with these options.
1625
07b140c2 1626@item arm_v8_1a_neon_ok
1b9e31cf 1627@anchor{arm_v8_1a_neon_ok}
07b140c2
MW
1628ARM target supports options to generate ARMv8.1 Adv.SIMD instructions.
1629Some multilibs may be incompatible with these options.
1630
1631@item arm_v8_1a_neon_hw
1632ARM target supports executing ARMv8.1 Adv.SIMD instructions. Some
1633multilibs may be incompatible with the options needed. Implies
1634arm_v8_1a_neon_ok.
1635
042dee3e
TP
1636@item arm_acq_rel
1637ARM target supports acquire-release instructions.
1638
1b9e31cf
MW
1639@item arm_v8_2a_fp16_scalar_ok
1640@anchor{arm_v8_2a_fp16_scalar_ok}
1641ARM target supports options to generate instructions for ARMv8.2 and
1642scalar instructions from the FP16 extension. Some multilibs may be
1643incompatible with these options.
1644
1645@item arm_v8_2a_fp16_scalar_hw
1646ARM target supports executing instructions for ARMv8.2 and scalar
1647instructions from the FP16 extension. Some multilibs may be
1648incompatible with these options. Implies arm_v8_2a_fp16_neon_ok.
1649
1650@item arm_v8_2a_fp16_neon_ok
1651@anchor{arm_v8_2a_fp16_neon_ok}
1652ARM target supports options to generate instructions from ARMv8.2 with
1653the FP16 extension. Some multilibs may be incompatible with these
1654options. Implies arm_v8_2a_fp16_scalar_ok.
1655
1656@item arm_v8_2a_fp16_neon_hw
1657ARM target supports executing instructions from ARMv8.2 with the FP16
1658extension. Some multilibs may be incompatible with these options.
1659Implies arm_v8_2a_fp16_neon_ok and arm_v8_2a_fp16_scalar_hw.
1660
cf5607f8
GY
1661@item arm_prefer_ldrd_strd
1662ARM target prefers @code{LDRD} and @code{STRD} instructions over
1663@code{LDM} and @code{STM} instructions.
1664
2b9509a3
TP
1665@item arm_thumb1_movt_ok
1666ARM target generates Thumb-1 code for @code{-mthumb} with @code{MOVW}
1667and @code{MOVT} instructions available.
1668
5ce15300
TP
1669@item arm_thumb1_cbz_ok
1670ARM target generates Thumb-1 code for @code{-mthumb} with
1671@code{CBZ} and @code{CBNZ} instructions available.
1672
e72531b9
PK
1673@item arm_divmod_simode
1674ARM target for which divmod transform is disabled, if it supports hardware
1675div instruction.
1676
de7b5723
AV
1677@item arm_cmse_ok
1678ARM target supports ARMv8-M Security Extensions, enabled by the @code{-mcmse}
1679option.
1680
d57daa0c
AV
1681@item arm_coproc1_ok
1682@anchor{arm_coproc1_ok}
1683ARM target supports the following coprocessor instructions: @code{CDP},
1684@code{LDC}, @code{STC}, @code{MCR} and @code{MRC}.
1685
1686@item arm_coproc2_ok
1687@anchor{arm_coproc2_ok}
1688ARM target supports all the coprocessor instructions also listed as supported
1689in @ref{arm_coproc1_ok} in addition to the following: @code{CDP2}, @code{LDC2},
1690@code{LDC2l}, @code{STC2}, @code{STC2l}, @code{MCR2} and @code{MRC2}.
1691
1692@item arm_coproc3_ok
1693@anchor{arm_coproc3_ok}
1694ARM target supports all the coprocessor instructions also listed as supported
1695in @ref{arm_coproc2_ok} in addition the following: @code{MCRR} and @code{MRRC}.
1696
1697@item arm_coproc4_ok
1698ARM target supports all the coprocessor instructions also listed as supported
1699in @ref{arm_coproc3_ok} in addition the following: @code{MCRR2} and @code{MRRC2}.
d4f3924a
JJ
1700@end table
1701
8997ef18
JW
1702@subsubsection AArch64-specific attributes
1703
1704@table @code
2db16594
KT
1705@item aarch64_asm_<ext>_ok
1706AArch64 assembler supports the architecture extension @code{ext} via the
1707@code{.arch_extension} pseudo-op.
d0baaae3
JW
1708@item aarch64_tiny
1709AArch64 target which generates instruction sequences for tiny memory model.
1710@item aarch64_small
1711AArch64 target which generates instruction sequences for small memory model.
1712@item aarch64_large
1713AArch64 target which generates instruction sequences for large memory model.
1714@item aarch64_little_endian
1715AArch64 target which generates instruction sequences for little endian.
1716@item aarch64_big_endian
1717AArch64 target which generates instruction sequences for big endian.
8997ef18
JW
1718@item aarch64_small_fpic
1719Binutils installed on test system supports relocation types required by -fpic
1720for AArch64 small memory model.
1721
1722@end table
1723
d4f3924a
JJ
1724@subsubsection MIPS-specific attributes
1725
1726@table @code
1727@item mips64
1728MIPS target supports 64-bit instructions.
1729
1730@item nomips16
1731MIPS target does not produce MIPS16 code.
1732
1733@item mips16_attribute
1734MIPS target can generate MIPS16 code.
1735
1736@item mips_loongson
1737MIPS target is a Loongson-2E or -2F target using an ABI that supports
1738the Loongson vector modes.
1739
6cf538da
RS
1740@item mips_msa
1741MIPS target supports @code{-mmsa}, MIPS SIMD Architecture (MSA).
1742
d4f3924a
JJ
1743@item mips_newabi_large_long_double
1744MIPS target supports @code{long double} larger than @code{double}
1745when using the new ABI.
1746
1747@item mpaired_single
1748MIPS target supports @code{-mpaired-single}.
1749@end table
1750
1751@subsubsection PowerPC-specific attributes
0455fecf 1752
d4f3924a 1753@table @code
f4853e92
PB
1754
1755@item dfp_hw
1756PowerPC target supports executing hardware DFP instructions.
1757
1758@item p8vector_hw
1759PowerPC target supports executing VSX instructions (ISA 2.07).
1760
d4f3924a
JJ
1761@item powerpc64
1762Test system supports executing 64-bit instructions.
1763
1764@item powerpc_altivec
1765PowerPC target supports AltiVec.
1766
1767@item powerpc_altivec_ok
1768PowerPC target supports @code{-maltivec}.
1769
f4853e92
PB
1770@item powerpc_eabi_ok
1771PowerPC target supports @code{-meabi}.
1772
1773@item powerpc_elfv2
1774PowerPC target supports @code{-mabi=elfv2}.
1775
d4f3924a
JJ
1776@item powerpc_fprs
1777PowerPC target supports floating-point registers.
1778
1779@item powerpc_hard_double
1780PowerPC target supports hardware double-precision floating-point.
1781
f4853e92
PB
1782@item powerpc_htm_ok
1783PowerPC target supports @code{-mhtm}
1784
1785@item powerpc_p8vector_ok
1786PowerPC target supports @code{-mpower8-vector}
1787
598bd687
KN
1788@item powerpc_popcntb_ok
1789PowerPC target supports the @code{popcntb} instruction, indicating
1790that this target supports @code{-mcpu=power5}.
1791
d4f3924a
JJ
1792@item powerpc_ppu_ok
1793PowerPC target supports @code{-mcpu=cell}.
1794
1795@item powerpc_spe
1796PowerPC target supports PowerPC SPE.
1797
1798@item powerpc_spe_nocache
1799Including the options used to compile this particular test, the
1800PowerPC target supports PowerPC SPE.
1801
1802@item powerpc_spu
1803PowerPC target supports PowerPC SPU.
1804
d4f3924a
JJ
1805@item powerpc_vsx_ok
1806PowerPC target supports @code{-mvsx}.
1807
1808@item powerpc_405_nocache
1809Including the options used to compile this particular test, the
1810PowerPC target supports PowerPC 405.
1811
f4853e92
PB
1812@item ppc_recip_hw
1813PowerPC target supports executing reciprocal estimate instructions.
1814
1815@item spu_auto_overlay
1816SPU target has toolchain that supports automatic overlay generation.
1817
d4f3924a
JJ
1818@item vmx_hw
1819PowerPC target supports executing AltiVec instructions.
f4853e92
PB
1820
1821@item vsx_hw
1822PowerPC target supports executing VSX instructions (ISA 2.06).
d4f3924a
JJ
1823@end table
1824
1825@subsubsection Other hardware attributes
1826
1827@table @code
1828@item avx
500b16c3
RO
1829Target supports compiling @code{avx} instructions.
1830
1831@item avx_runtime
1832Target supports the execution of @code{avx} instructions.
d4f3924a
JJ
1833
1834@item cell_hw
1835Test system can execute AltiVec and Cell PPU instructions.
1836
1837@item coldfire_fpu
1838Target uses a ColdFire FPU.
1839
1840@item hard_float
1841Target supports FPU instructions.
1842
94910f22
SE
1843@item non_strict_align
1844Target does not require strict alignment.
1845
1e43cc94
KT
1846@item sqrt_insn
1847Target has a square root instruction that the compiler can generate.
1848
ae6a0535
RO
1849@item sse
1850Target supports compiling @code{sse} instructions.
1851
39354b3b
RO
1852@item sse_runtime
1853Target supports the execution of @code{sse} instructions.
1854
40f1bdd9
RO
1855@item sse2
1856Target supports compiling @code{sse2} instructions.
1857
39354b3b
RO
1858@item sse2_runtime
1859Target supports the execution of @code{sse2} instructions.
1860
d4f3924a
JJ
1861@item sync_char_short
1862Target supports atomic operations on @code{char} and @code{short}.
1863
1864@item sync_int_long
1865Target supports atomic operations on @code{int} and @code{long}.
1866
1867@item ultrasparc_hw
1868Test environment appears to run executables on a simulator that
1869accepts only @code{EM_SPARC} executables and chokes on @code{EM_SPARC32PLUS}
1870or @code{EM_SPARCV9} executables.
1871
1872@item vect_cmdline_needed
1873Target requires a command line argument to enable a SIMD instruction set.
77ad54d9
ST
1874
1875@item pie_copyreloc
1876The x86-64 target linker supports PIE with copy reloc.
e72531b9
PK
1877
1878@item divmod
1879Target supporting hardware divmod insn or divmod libcall.
1880
1881@item divmod_simode
1882Target supporting hardware divmod insn or divmod libcall for SImode.
1883
d4f3924a
JJ
1884@end table
1885
1886@subsubsection Environment attributes
1887
1888@table @code
1889@item c
1890The language for the compiler under test is C.
1891
1892@item c++
1893The language for the compiler under test is C++.
1894
1895@item c99_runtime
1896Target provides a full C99 runtime.
1897
1898@item correct_iso_cpp_string_wchar_protos
1899Target @code{string.h} and @code{wchar.h} headers provide C++ required
1900overloads for @code{strchr} etc. functions.
1901
1902@item dummy_wcsftime
1903Target uses a dummy @code{wcsftime} function that always returns zero.
1904
1905@item fd_truncate
1906Target can truncate a file from a file descriptor, as used by
1907@file{libgfortran/io/unix.c:fd_truncate}; i.e. @code{ftruncate} or
1908@code{chsize}.
1909
1910@item freestanding
1911Target is @samp{freestanding} as defined in section 4 of the C99 standard.
1912Effectively, it is a target which supports no extra headers or libraries
1913other than what is considered essential.
1914
1915@item init_priority
1916Target supports constructors with initialization priority arguments.
1917
1918@item inttypes_types
1919Target has the basic signed and unsigned types in @code{inttypes.h}.
1920This is for tests that GCC's notions of these types agree with those
1921in the header, as some systems have only @code{inttypes.h}.
1922
1923@item lax_strtofp
1924Target might have errors of a few ULP in string to floating-point
1925conversion functions and overflow is not always detected correctly by
1926those functions.
1927
37b12f58
IE
1928@item mempcpy
1929Target provides @code{mempcpy} function.
1930
8175c19c
RO
1931@item mmap
1932Target supports @code{mmap}.
1933
d4f3924a
JJ
1934@item newlib
1935Target supports Newlib.
1936
1937@item pow10
1938Target provides @code{pow10} function.
1939
1940@item pthread
1941Target can compile using @code{pthread.h} with no errors or warnings.
1942
1943@item pthread_h
1944Target has @code{pthread.h}.
1945
0fa3d594
RO
1946@item run_expensive_tests
1947Expensive testcases (usually those that consume excessive amounts of CPU
1948time) should be run on this target. This can be enabled by setting the
1949@env{GCC_TEST_RUN_EXPENSIVE} environment variable to a non-empty string.
1950
d4f3924a
JJ
1951@item simulator
1952Test system runs executables on a simulator (i.e. slowly) rather than
1953hardware (i.e. fast).
1954
01704e5a
RO
1955@item stabs
1956Target supports the stabs debugging format.
1957
d4f3924a
JJ
1958@item stdint_types
1959Target has the basic signed and unsigned C types in @code{stdint.h}.
1960This will be obsolete when GCC ensures a working @code{stdint.h} for
1961all targets.
1962
37b12f58
IE
1963@item stpcpy
1964Target provides @code{stpcpy} function.
1965
d4f3924a
JJ
1966@item trampolines
1967Target supports trampolines.
1968
1969@item uclibc
1970Target supports uClibc.
1971
1972@item unwrapped
1973Target does not use a status wrapper.
1974
1975@item vxworks_kernel
1976Target is a VxWorks kernel.
1977
1978@item vxworks_rtp
1979Target is a VxWorks RTP.
1980
1981@item wchar
1982Target supports wide characters.
1983@end table
1984
1985@subsubsection Other attributes
1986
1987@table @code
1988@item automatic_stack_alignment
1989Target supports automatic stack alignment.
1990
713dedcd
RO
1991@item cilkplus_runtime
1992Target supports the Cilk Plus runtime library.
1993
d4f3924a
JJ
1994@item cxa_atexit
1995Target uses @code{__cxa_atexit}.
1996
1997@item default_packed
1998Target has packed layout of structure members by default.
1999
2000@item fgraphite
2001Target supports Graphite optimizations.
2002
2003@item fixed_point
2004Target supports fixed-point extension to C.
2005
41dbbb37
TS
2006@item fopenacc
2007Target supports OpenACC via @option{-fopenacc}.
2008
d4f3924a
JJ
2009@item fopenmp
2010Target supports OpenMP via @option{-fopenmp}.
2011
2012@item fpic
2013Target supports @option{-fpic} and @option{-fPIC}.
2014
2015@item freorder
2016Target supports @option{-freorder-blocks-and-partition}.
2017
2018@item fstack_protector
2019Target supports @option{-fstack-protector}.
2020
659b24d6
RO
2021@item gas
2022Target uses GNU @command{as}.
2023
d4f3924a
JJ
2024@item gc_sections
2025Target supports @option{--gc-sections}.
2026
14a393a3
RO
2027@item gld
2028Target uses GNU @command{ld}.
2029
d4f3924a
JJ
2030@item keeps_null_pointer_checks
2031Target keeps null pointer checks, either due to the use of
2032@option{-fno-delete-null-pointer-checks} or hardwired into the target.
2033
2034@item lto
2035Compiler has been configured to support link-time optimization (LTO).
2036
d45eae79
SL
2037@item naked_functions
2038Target supports the @code{naked} function attribute.
2039
d4f3924a
JJ
2040@item named_sections
2041Target supports named sections.
2042
2043@item natural_alignment_32
2044Target uses natural alignment (aligned to type size) for types of
204532 bits or less.
2046
2047@item target_natural_alignment_64
2048Target uses natural alignment (aligned to type size) for types of
204964 bits or less.
2050
2051@item nonpic
2052Target does not generate PIC by default.
2053
a8d790df
L
2054@item pie_enabled
2055Target generates PIE by default.
2056
d4f3924a
JJ
2057@item pcc_bitfield_type_matters
2058Target defines @code{PCC_BITFIELD_TYPE_MATTERS}.
2059
2060@item pe_aligned_commons
2061Target supports @option{-mpe-aligned-commons}.
2062
8340fbd7
RO
2063@item pie
2064Target supports @option{-pie}, @option{-fpie} and @option{-fPIE}.
2065
d4f3924a
JJ
2066@item section_anchors
2067Target supports section anchors.
2068
2069@item short_enums
2070Target defaults to short enums.
2071
2072@item static
2073Target supports @option{-static}.
2074
2075@item static_libgfortran
2076Target supports statically linking @samp{libgfortran}.
2077
2078@item string_merging
2079Target supports merging string constants at link time.
2080
2081@item ucn
2082Target supports compiling and assembling UCN.
2083
2084@item ucn_nocache
2085Including the options used to compile this particular test, the
2086target supports compiling and assembling UCN.
2087
2088@item unaligned_stack
2089Target does not guarantee that its @code{STACK_BOUNDARY} is greater than
2090or equal to the required vector alignment.
2091
2092@item vector_alignment_reachable
2093Vector alignment is reachable for types of 32 bits or less.
2094
2095@item vector_alignment_reachable_for_64bit
2096Vector alignment is reachable for types of 64 bits or less.
2097
2098@item wchar_t_char16_t_compatible
2099Target supports @code{wchar_t} that is compatible with @code{char16_t}.
2100
2101@item wchar_t_char32_t_compatible
2102Target supports @code{wchar_t} that is compatible with @code{char32_t}.
813ba013
JJ
2103
2104@item comdat_group
2105Target uses comdat groups.
d4f3924a
JJ
2106@end table
2107
2108@subsubsection Local to tests in @code{gcc.target/i386}
2109
2110@table @code
40f1bdd9
RO
2111@item 3dnow
2112Target supports compiling @code{3dnow} instructions.
2113
d4f3924a
JJ
2114@item aes
2115Target supports compiling @code{aes} instructions.
2116
2117@item fma4
2118Target supports compiling @code{fma4} instructions.
2119
2120@item ms_hook_prologue
2121Target supports attribute @code{ms_hook_prologue}.
2122
2123@item pclmul
2124Target supports compiling @code{pclmul} instructions.
2125
40f1bdd9
RO
2126@item sse3
2127Target supports compiling @code{sse3} instructions.
2128
d4f3924a
JJ
2129@item sse4
2130Target supports compiling @code{sse4} instructions.
2131
2132@item sse4a
2133Target supports compiling @code{sse4a} instructions.
2134
2135@item ssse3
2136Target supports compiling @code{ssse3} instructions.
2137
2138@item vaes
2139Target supports compiling @code{vaes} instructions.
2140
2141@item vpclmul
2142Target supports compiling @code{vpclmul} instructions.
2143
2144@item xop
2145Target supports compiling @code{xop} instructions.
2146@end table
2147
2148@subsubsection Local to tests in @code{gcc.target/spu/ea}
2149
2150@table @code
2151@item ealib
2152Target @code{__ea} library functions are available.
2153@end table
2154
2155@subsubsection Local to tests in @code{gcc.test-framework}
2156
2157@table @code
2158@item no
2159Always returns 0.
2160
2161@item yes
2162Always returns 1.
2163@end table
2164
2165@node Add Options
2166@subsection Features for @code{dg-add-options}
2167
2168The supported values of @var{feature} for directive @code{dg-add-options}
2169are:
2170
2171@table @code
d7cf3dc7
CL
2172@item arm_fp
2173@code{__ARM_FP} definition. Only ARM targets support this feature, and only then
2174in certain modes; see the @ref{arm_fp_ok,,arm_fp_ok effective target
2175keyword}.
2176
16c9d3b1
RO
2177@item arm_neon
2178NEON support. Only ARM targets support this feature, and only then
2179in certain modes; see the @ref{arm_neon_ok,,arm_neon_ok effective target
2180keyword}.
2181
7fe43755
MW
2182@item arm_fp16
2183VFP half-precision floating point support. This does not select the
2184FP16 format; for that, use @ref{arm_fp16_ieee,,arm_fp16_ieee} or
2185@ref{arm_fp16_alternative,,arm_fp16_alternative} instead. This
2186feature is only supported by ARM targets and then only in certain
2187modes; see the @ref{arm_fp16_ok,,arm_fp16_ok effective target
2188keyword}.
2189
2190@item arm_fp16_ieee
2191@anchor{arm_fp16_ieee}
2192ARM IEEE 754-2008 format VFP half-precision floating point support.
2193This feature is only supported by ARM targets and then only in certain
2194modes; see the @ref{arm_fp16_ok,,arm_fp16_ok effective target
2195keyword}.
2196
2197@item arm_fp16_alternative
2198@anchor{arm_fp16_alternative}
2199ARM Alternative format VFP half-precision floating point support.
2200This feature is only supported by ARM targets and then only in certain
2201modes; see the @ref{arm_fp16_ok,,arm_fp16_ok effective target
2202keyword}.
2203
16c9d3b1
RO
2204@item arm_neon_fp16
2205NEON and half-precision floating point support. Only ARM targets
2206support this feature, and only then in certain modes; see
48c44783 2207the @ref{arm_neon_fp16_ok,,arm_neon_fp16_ok effective target keyword}.
16c9d3b1 2208
6d3715b9
RL
2209@item arm_vfp3
2210arm vfp3 floating point support; see
2211the @ref{arm_vfp3_ok,,arm_vfp3_ok effective target keyword}.
2212
1b9e31cf
MW
2213@item arm_v8_1a_neon
2214Add options for ARMv8.1 with Adv.SIMD support, if this is supported
2215by the target; see the @ref{arm_v8_1a_neon_ok,,arm_v8_1a_neon_ok}
2216effective target keyword.
2217
2218@item arm_v8_2a_fp16_scalar
2219Add options for ARMv8.2 with scalar FP16 support, if this is
2220supported by the target; see the
2221@ref{arm_v8_2a_fp16_scalar_ok,,arm_v8_2a_fp16_scalar_ok} effective
2222target keyword.
2223
2224@item arm_v8_2a_fp16_neon
2225Add options for ARMv8.2 with Adv.SIMD FP16 support, if this is
2226supported by the target; see the
2227@ref{arm_v8_2a_fp16_neon_ok,,arm_v8_2a_fp16_neon_ok} effective target
2228keyword.
2229
d4f3924a
JJ
2230@item bind_pic_locally
2231Add the target-specific flags needed to enable functions to bind
2232locally when using pic/PIC passes in the testsuite.
2233
2234@item c99_runtime
2235Add the target-specific flags needed to access the C99 runtime.
2236
c65699ef
JM
2237@item float@var{n}
2238Add the target-specific flags needed to use the @code{_Float@var{n}} type.
2239
2240@item float@var{n}x
2241Add the target-specific flags needed to use the @code{_Float@var{n}x} type.
2242
d4f3924a
JJ
2243@item ieee
2244Add the target-specific flags needed to enable full IEEE
2245compliance mode.
2246
2247@item mips16_attribute
2248@code{mips16} function attributes.
2249Only MIPS targets support this feature, and only then in certain modes.
0c422e74 2250
16c9d3b1
RO
2251@item tls
2252Add the target-specific flags needed to use thread-local storage.
d4f3924a
JJ
2253@end table
2254
2255@node Require Support
2256@subsection Variants of @code{dg-require-@var{support}}
2257
2258A few of the @code{dg-require} directives take arguments.
2259
2260@table @code
2261@item dg-require-iconv @var{codeset}
2262Skip the test if the target does not support iconv. @var{codeset} is
2263the codeset to convert to.
2264
2265@item dg-require-profiling @var{profopt}
2266Skip the test if the target does not support profiling with option
2267@var{profopt}.
2268
2269@item dg-require-visibility @var{vis}
2270Skip the test if the target does not support the @code{visibility} attribute.
2271If @var{vis} is @code{""}, support for @code{visibility("hidden")} is
2272checked, for @code{visibility("@var{vis}")} otherwise.
2273@end table
2274
2275The original @code{dg-require} directives were defined before there
2276was support for effective-target keywords. The directives that do not
2277take arguments could be replaced with effective-target keywords.
2278
2279@table @code
2280@item dg-require-alias ""
2281Skip the test if the target does not support the @samp{alias} attribute.
2282
6dd2a13c
RO
2283@item dg-require-ascii-locale ""
2284Skip the test if the host does not support an ASCII locale.
2285
d4f3924a
JJ
2286@item dg-require-compat-dfp ""
2287Skip this test unless both compilers in a @file{compat} testsuite
2288support decimal floating point.
2289
2290@item dg-require-cxa-atexit ""
2291Skip the test if the target does not support @code{__cxa_atexit}.
2292This is equivalent to @code{dg-require-effective-target cxa_atexit}.
2293
2294@item dg-require-dll ""
2295Skip the test if the target does not support DLL attributes.
2296
2297@item dg-require-fork ""
2298Skip the test if the target does not support @code{fork}.
2299
2300@item dg-require-gc-sections ""
2301Skip the test if the target's linker does not support the
2302@code{--gc-sections} flags.
2303This is equivalent to @code{dg-require-effective-target gc-sections}.
2304
2305@item dg-require-host-local ""
2306Skip the test if the host is remote, rather than the same as the build
2307system. Some tests are incompatible with DejaGnu's handling of remote
2308hosts, which involves copying the source file to the host and compiling
2309it with a relative path and "@code{-o a.out}".
2310
2311@item dg-require-mkfifo ""
2312Skip the test if the target does not support @code{mkfifo}.
2313
2314@item dg-require-named-sections ""
2315Skip the test is the target does not support named sections.
2316This is equivalent to @code{dg-require-effective-target named_sections}.
2317
2318@item dg-require-weak ""
2319Skip the test if the target does not support weak symbols.
2320
2321@item dg-require-weak-override ""
2322Skip the test if the target does not support overriding weak symbols.
2323@end table
2324
2325@node Final Actions
2326@subsection Commands for use in @code{dg-final}
2327
2328The GCC testsuite defines the following directives to be used within
2329@code{dg-final}.
2330
2331@subsubsection Scan a particular file
2332
2333@table @code
35fdf04e
JJ
2334@item scan-file @var{filename} @var{regexp} [@{ target/xfail @var{selector} @}]
2335Passes if @var{regexp} matches text in @var{filename}.
35fdf04e
JJ
2336@item scan-file-not @var{filename} @var{regexp} [@{ target/xfail @var{selector} @}]
2337Passes if @var{regexp} does not match text in @var{filename}.
d4f3924a
JJ
2338@item scan-module @var{module} @var{regexp} [@{ target/xfail @var{selector} @}]
2339Passes if @var{regexp} matches in Fortran module @var{module}.
2340@end table
35fdf04e 2341
d4f3924a 2342@subsubsection Scan the assembly output
35fdf04e 2343
d4f3924a 2344@table @code
35fdf04e
JJ
2345@item scan-assembler @var{regex} [@{ target/xfail @var{selector} @}]
2346Passes if @var{regex} matches text in the test's assembler output.
2347
2348@item scan-assembler-not @var{regex} [@{ target/xfail @var{selector} @}]
2349Passes if @var{regex} does not match text in the test's assembler output.
2350
d4f3924a
JJ
2351@item scan-assembler-times @var{regex} @var{num} [@{ target/xfail @var{selector} @}]
2352Passes if @var{regex} is matched exactly @var{num} times in the test's
2353assembler output.
2354
35fdf04e
JJ
2355@item scan-assembler-dem @var{regex} [@{ target/xfail @var{selector} @}]
2356Passes if @var{regex} matches text in the test's demangled assembler output.
2357
2358@item scan-assembler-dem-not @var{regex} [@{ target/xfail @var{selector} @}]
2359Passes if @var{regex} does not match text in the test's demangled assembler
2360output.
2361
d4f3924a
JJ
2362@item scan-hidden @var{symbol} [@{ target/xfail @var{selector} @}]
2363Passes if @var{symbol} is defined as a hidden symbol in the test's
2364assembly output.
2365
2366@item scan-not-hidden @var{symbol} [@{ target/xfail @var{selector} @}]
2367Passes if @var{symbol} is not defined as a hidden symbol in the test's
2368assembly output.
2369@end table
2370
2371@subsubsection Scan optimization dump files
35fdf04e 2372
d4f3924a
JJ
2373These commands are available for @var{kind} of @code{tree}, @code{rtl},
2374and @code{ipa}.
2375
2376@table @code
2377@item scan-@var{kind}-dump @var{regex} @var{suffix} [@{ target/xfail @var{selector} @}]
35fdf04e
JJ
2378Passes if @var{regex} matches text in the dump file with suffix @var{suffix}.
2379
d4f3924a 2380@item scan-@var{kind}-dump-not @var{regex} @var{suffix} [@{ target/xfail @var{selector} @}]
35fdf04e
JJ
2381Passes if @var{regex} does not match text in the dump file with suffix
2382@var{suffix}.
2383
d4f3924a
JJ
2384@item scan-@var{kind}-dump-times @var{regex} @var{num} @var{suffix} [@{ target/xfail @var{selector} @}]
2385Passes if @var{regex} is found exactly @var{num} times in the dump file
2386with suffix @var{suffix}.
2387
2388@item scan-@var{kind}-dump-dem @var{regex} @var{suffix} [@{ target/xfail @var{selector} @}]
35fdf04e
JJ
2389Passes if @var{regex} matches demangled text in the dump file with
2390suffix @var{suffix}.
2391
d4f3924a 2392@item scan-@var{kind}-dump-dem-not @var{regex} @var{suffix} [@{ target/xfail @var{selector} @}]
35fdf04e
JJ
2393Passes if @var{regex} does not match demangled text in the dump file with
2394suffix @var{suffix}.
d4f3924a
JJ
2395@end table
2396
2397@subsubsection Verify that an output files exists or not
35fdf04e 2398
d4f3924a 2399@table @code
d6682e21
JJ
2400@item output-exists [@{ target/xfail @var{selector} @}]
2401Passes if compiler output file exists.
2402
2403@item output-exists-not [@{ target/xfail @var{selector} @}]
2404Passes if compiler output file does not exist.
d4f3924a
JJ
2405@end table
2406
2407@subsubsection Check for LTO tests
2408
2409@table @code
2410@item scan-symbol @var{regexp} [@{ target/xfail @var{selector} @}]
2411Passes if the pattern is present in the final executable.
2412@end table
d6682e21 2413
d4f3924a
JJ
2414@subsubsection Checks for @command{gcov} tests
2415
2416@table @code
35fdf04e
JJ
2417@item run-gcov @var{sourcefile}
2418Check line counts in @command{gcov} tests.
2419
2420@item run-gcov [branches] [calls] @{ @var{opts} @var{sourcefile} @}
2421Check branch and/or call counts, in addition to line counts, in
2422@command{gcov} tests.
2423@end table
d4f3924a
JJ
2424
2425@subsubsection Clean up generated test files
2426
c469078d
BRF
2427Usually the test-framework removes files that were generated during
2428testing. If a testcase, for example, uses any dumping mechanism to
2429inspect a passes dump file, the testsuite recognized the dump option
2430passed to the tool and schedules a final cleanup to remove these files.
2431
2432There are, however, following additional cleanup directives that can be
2433used to annotate a testcase "manually".
d4f3924a
JJ
2434@table @code
2435@item cleanup-coverage-files
2436Removes coverage data files generated for this test.
2437
b3781fcb
BRF
2438@item cleanup-modules "@var{list-of-extra-modules}"
2439Removes Fortran module files generated for this test, excluding the
2440module names listed in keep-modules.
2441Cleaning up module files is usually done automatically by the testsuite
2442by looking at the source files and removing the modules after the test
2443has been executed.
2444@smallexample
2445module MoD1
2446end module MoD1
2447module Mod2
2448end module Mod2
2449module moD3
2450end module moD3
2451module mod4
2452end module mod4
2453! @{ dg-final @{ cleanup-modules "mod1 mod2" @} @} ! redundant
2454! @{ dg-final @{ keep-modules "mod3 mod4" @} @}
2455@end smallexample
2456
2457@item keep-modules "@var{list-of-modules-not-to-delete}"
2458Whitespace separated list of module names that should not be deleted by
2459cleanup-modules.
2460If the list of modules is empty, all modules defined in this file are kept.
2461@smallexample
2462module maybe_unneeded
2463end module maybe_unneeded
2464module keep1
2465end module keep1
2466module keep2
2467end module keep2
2468! @{ dg-final @{ keep-modules "keep1 keep2" @} @} ! just keep these two
2469! @{ dg-final @{ keep-modules "" @} @} ! keep all
2470@end smallexample
d4f3924a 2471
c469078d
BRF
2472@item dg-keep-saved-temps "@var{list-of-suffixes-not-to-delete}"
2473Whitespace separated list of suffixes that should not be deleted
2474automatically in a testcase that uses @option{-save-temps}.
2475@smallexample
2476// @{ dg-options "-save-temps -fpch-preprocess -I." @}
2477int main() @{ return 0; @}
2478// @{ dg-keep-saved-temps ".s" @} ! just keep assembler file
2479// @{ dg-keep-saved-temps ".s" ".i" @} ! ... and .i
2480// @{ dg-keep-saved-temps ".ii" ".o" @} ! or just .ii and .o
2481@end smallexample
2482
d4f3924a
JJ
2483@item cleanup-profile-file
2484Removes profiling files generated for this test.
2485
2486@item cleanup-repo-files
2487Removes files generated for this test for @option{-frepo}.
2488
35fdf04e
JJ
2489@end table
2490
d0a74d7e 2491@node Ada Tests
500cdcb0 2492@section Ada Language Testsuites
d0a74d7e 2493
bebd5f99 2494The Ada testsuite includes executable tests from the ACATS
2eac577f 2495testsuite, publicly available at
bebd5f99 2496@uref{http://www.ada-auth.org/acats.html}.
d0a74d7e 2497
2eac577f 2498These tests are integrated in the GCC testsuite in the
d4f3924a 2499@file{ada/acats} directory, and
d0a74d7e 2500enabled automatically when running @code{make check}, assuming
8a36672b 2501the Ada language has been enabled when configuring GCC@.
d0a74d7e 2502
2eac577f 2503You can also run the Ada testsuite independently, using
d0a74d7e 2504@code{make check-ada}, or run a subset of the tests by specifying which
8a36672b 2505chapter to run, e.g.:
d0a74d7e
AC
2506
2507@smallexample
2508$ make check-ada CHAPTERS="c3 c9"
2509@end smallexample
2510
2511The tests are organized by directory, each directory corresponding to
17a7cb4e 2512a chapter of the Ada Reference Manual. So for example, @file{c9} corresponds
d0a74d7e
AC
2513to chapter 9, which deals with tasking features of the language.
2514
78466c0e
JM
2515The tests are run using two @command{sh} scripts: @file{run_acats} and
2516@file{run_all.sh}. To run the tests using a simulator or a cross
2517target, see the small
2518customization section at the top of @file{run_all.sh}.
d0a74d7e
AC
2519
2520These tests are run using the build tree: they can be run without doing
2521a @code{make install}.
2522
0a553c7e 2523@node C Tests
500cdcb0 2524@section C Language Testsuites
0a553c7e 2525
2eac577f 2526GCC contains the following C language testsuites, in the
0a553c7e
JM
2527@file{gcc/testsuite} directory:
2528
2529@table @file
4b2ece8f 2530@item gcc.dg
daf2f129 2531This contains tests of particular features of the C compiler, using the
4b2ece8f
NN
2532more modern @samp{dg} harness. Correctness tests for various compiler
2533features should go here if possible.
2534
daf2f129
JM
2535Magic comments determine whether the file
2536is preprocessed, compiled, linked or run. In these tests, error and warning
2537message texts are compared against expected texts or regular expressions
4b2ece8f
NN
2538given in comments. These tests are run with the options @samp{-ansi -pedantic}
2539unless other options are given in the test. Except as noted below they
2540are not run with multiple optimization options.
6ccfe27c
JJ
2541@item gcc.dg/compat
2542This subdirectory contains tests for binary compatibility using
17a7cb4e 2543@file{lib/compat.exp}, which in turn uses the language-independent support
6ccfe27c 2544(@pxref{compat Testing, , Support for testing binary compatibility}).
4b2ece8f
NN
2545@item gcc.dg/cpp
2546This subdirectory contains tests of the preprocessor.
2547@item gcc.dg/debug
2548This subdirectory contains tests for debug formats. Tests in this
2549subdirectory are run for each debug format that the compiler supports.
2550@item gcc.dg/format
2551This subdirectory contains tests of the @option{-Wformat} format
2552checking. Tests in this directory are run with and without
2553@option{-DWIDE}.
2554@item gcc.dg/noncompile
2555This subdirectory contains tests of code that should not compile and
2556does not need any special compilation options. They are run with
2557multiple optimization options, since sometimes invalid code crashes
2558the compiler with optimization.
2559@item gcc.dg/special
2560FIXME: describe this.
2561
2562@item gcc.c-torture
c0478a66 2563This contains particular code fragments which have historically broken easily.
4b2ece8f
NN
2564These tests are run with multiple optimization options, so tests for features
2565which only break at some optimization levels belong here. This also contains
daf2f129 2566tests to check that certain optimizations occur. It might be worthwhile to
4b2ece8f
NN
2567separate the correctness tests cleanly from the code quality tests, but
2568it hasn't been done yet.
2569
0a553c7e
JM
2570@item gcc.c-torture/compat
2571FIXME: describe this.
2572
2573This directory should probably not be used for new tests.
2574@item gcc.c-torture/compile
2eac577f 2575This testsuite contains test cases that should compile, but do not
0a553c7e
JM
2576need to link or run. These test cases are compiled with several
2577different combinations of optimization options. All warnings are
2578disabled for these test cases, so this directory is not suitable if
2579you wish to test for the presence or absence of compiler warnings.
2580While special options can be set, and tests disabled on specific
2581platforms, by the use of @file{.x} files, mostly these test cases
2582should not contain platform dependencies. FIXME: discuss how defines
2583such as @code{NO_LABEL_VALUES} and @code{STACK_SIZE} are used.
2584@item gcc.c-torture/execute
2eac577f 2585This testsuite contains test cases that should compile, link and run;
0a553c7e 2586otherwise the same comments as for @file{gcc.c-torture/compile} apply.
4b2ece8f
NN
2587@item gcc.c-torture/execute/ieee
2588This contains tests which are specific to IEEE floating point.
0a553c7e
JM
2589@item gcc.c-torture/unsorted
2590FIXME: describe this.
2591
2592This directory should probably not be used for new tests.
17a7cb4e 2593@item gcc.misc-tests
138d4703
JJ
2594This directory contains C tests that require special handling. Some
2595of these tests have individual expect files, and others share
2596special-purpose expect files:
2597
2598@table @file
2599@item @code{bprob*.c}
17a7cb4e
RO
2600Test @option{-fbranch-probabilities} using
2601@file{gcc.misc-tests/bprob.exp}, which
138d4703
JJ
2602in turn uses the generic, language-independent framework
2603(@pxref{profopt Testing, , Support for testing profile-directed
2604optimizations}).
2605
138d4703
JJ
2606@item @code{gcov*.c}
2607Test @command{gcov} output using @file{gcov.exp}, which in turn uses the
2608language-independent support (@pxref{gcov Testing, , Support for testing gcov}).
2609
2610@item @code{i386-pf-*.c}
2611Test i386-specific support for data prefetch using @file{i386-prefetch.exp}.
2612@end table
2613
17a7cb4e
RO
2614@item gcc.test-framework
2615@table @file
2616@item @code{dg-*.c}
2617Test the testsuite itself using @file{gcc.test-framework/test-framework.exp}.
2618@end table
2619
0a553c7e
JM
2620@end table
2621
2622FIXME: merge in @file{testsuite/README.gcc} and discuss the format of
2623test cases and magic comments more.
f702e700 2624
d7f09764 2625@node LTO Testing
500cdcb0 2626@section Support for testing link-time optimizations
d7f09764
DN
2627
2628Tests for link-time optimizations usually require multiple source files
2629that are compiled separately, perhaps with different sets of options.
2630There are several special-purpose test directives used for these tests.
2631
2632@table @code
2633@item @{ dg-lto-do @var{do-what-keyword} @}
2634@var{do-what-keyword} specifies how the test is compiled and whether
2635it is executed. It is one of:
2636
2637@table @code
2638@item assemble
2639Compile with @option{-c} to produce a relocatable object file.
2640@item link
2641Compile, assemble, and link to produce an executable file.
2642@item run
2643Produce and run an executable file, which is expected to return
2644an exit code of 0.
2645@end table
2646
2647The default is @code{assemble}. That can be overridden for a set of
2648tests by redefining @code{dg-do-what-default} within the @code{.exp}
2649file for those tests.
2650
2651Unlike @code{dg-do}, @code{dg-lto-do} does not support an optional
2652@samp{target} or @samp{xfail} list. Use @code{dg-skip-if},
2653@code{dg-xfail-if}, or @code{dg-xfail-run-if}.
2654
2655@item @{ dg-lto-options @{ @{ @var{options} @} [@{ @var{options} @}] @} [@{ target @var{selector} @}]@}
2656This directive provides a list of one or more sets of compiler options
2657to override @var{LTO_OPTIONS}. Each test will be compiled and run with
2658each of these sets of options.
d4f3924a 2659
cf3e1041 2660@item @{ dg-extra-ld-options @var{options} [@{ target @var{selector} @}]@}
d4f3924a
JJ
2661This directive adds @var{options} to the linker options used.
2662
86de8875 2663@item @{ dg-suppress-ld-options @var{options} [@{ target @var{selector} @}]@}
d4f3924a 2664This directive removes @var{options} from the set of linker options used.
d7f09764
DN
2665@end table
2666
138d4703 2667@node gcov Testing
500cdcb0 2668@section Support for testing @command{gcov}
138d4703
JJ
2669
2670Language-independent support for testing @command{gcov}, and for checking
2671that branch profiling produces expected values, is provided by the
17a7cb4e
RO
2672expect file @file{lib/gcov.exp}. @command{gcov} tests also rely on procedures
2673in @file{lib/gcc-dg.exp} to compile and run the test program. A typical
c75095b2 2674@command{gcov} test contains the following DejaGnu commands within comments:
138d4703
JJ
2675
2676@smallexample
2677@{ dg-options "-fprofile-arcs -ftest-coverage" @}
2678@{ dg-do run @{ target native @} @}
2679@{ dg-final @{ run-gcov sourcefile @} @}
2680@end smallexample
2681
2682Checks of @command{gcov} output can include line counts, branch percentages,
2683and call return percentages. All of these checks are requested via
2684commands that appear in comments in the test's source file.
2685Commands to check line counts are processed by default.
2686Commands to check branch percentages and call return percentages are
7760d7f9
JJ
2687processed if the @command{run-gcov} command has arguments @code{branches}
2688or @code{calls}, respectively. For example, the following specifies
4ec7afd7 2689checking both, as well as passing @option{-b} to @command{gcov}:
7760d7f9
JJ
2690
2691@smallexample
2692@{ dg-final @{ run-gcov branches calls @{ -b sourcefile @} @} @}
2693@end smallexample
138d4703
JJ
2694
2695A line count command appears within a comment on the source line
2696that is expected to get the specified count and has the form
2697@code{count(@var{cnt})}. A test should only check line counts for
2698lines that will get the same count for any architecture.
2699
2700Commands to check branch percentages (@code{branch}) and call
2701return percentages (@code{returns}) are very similar to each other.
2702A beginning command appears on or before the first of a range of
2703lines that will report the percentage, and the ending command
2704follows that range of lines. The beginning command can include a
2705list of percentages, all of which are expected to be found within
2706the range. A range is terminated by the next command of the same
2707kind. A command @code{branch(end)} or @code{returns(end)} marks
2708the end of a range without starting a new one. For example:
2709
2710@smallexample
12bcfaa1
JM
2711if (i > 10 && j > i && j < 20) /* @r{branch(27 50 75)} */
2712 /* @r{branch(end)} */
138d4703
JJ
2713 foo (i, j);
2714@end smallexample
2715
2716For a call return percentage, the value specified is the
2717percentage of calls reported to return. For a branch percentage,
2718the value is either the expected percentage or 100 minus that
2719value, since the direction of a branch can differ depending on the
2720target or the optimization level.
2721
2722Not all branches and calls need to be checked. A test should not
2723check for branches that might be optimized away or replaced with
2724predicated instructions. Don't check for calls inserted by the
2725compiler or ones that might be inlined or optimized away.
2726
2727A single test can check for combinations of line counts, branch
2728percentages, and call return percentages. The command to check a
2729line count must appear on the line that will report that count, but
2730commands to check branch percentages and call return percentages can
2731bracket the lines that report them.
2732
2733@node profopt Testing
500cdcb0 2734@section Support for testing profile-directed optimizations
138d4703
JJ
2735
2736The file @file{profopt.exp} provides language-independent support for
2737checking correct execution of a test built with profile-directed
2738optimization. This testing requires that a test program be built and
2739executed twice. The first time it is compiled to generate profile
2740data, and the second time it is compiled to use the data that was
2741generated during the first execution. The second execution is to
2742verify that the test produces the expected results.
2743
2744To check that the optimization actually generated better code, a
2745test can be built and run a third time with normal optimizations to
2746verify that the performance is better with the profile-directed
2747optimizations. @file{profopt.exp} has the beginnings of this kind
2748of support.
2749
2750@file{profopt.exp} provides generic support for profile-directed
2751optimizations. Each set of tests that uses it provides information
2752about a specific optimization:
2753
2754@table @code
2755@item tool
2dd76960 2756tool being tested, e.g., @command{gcc}
138d4703
JJ
2757
2758@item profile_option
2759options used to generate profile data
2760
2761@item feedback_option
2762options used to optimize using that profile data
2763
2764@item prof_ext
2765suffix of profile data files
2766
2767@item PROFOPT_OPTIONS
2768list of options with which to run each test, similar to the lists for
2769torture tests
d4f3924a
JJ
2770
2771@item @{ dg-final-generate @{ @var{local-directive} @} @}
2772This directive is similar to @code{dg-final}, but the
2773@var{local-directive} is run after the generation of profile data.
2774
2775@item @{ dg-final-use @{ @var{local-directive} @} @}
2776The @var{local-directive} is run after the profile data have been
2777used.
138d4703 2778@end table
46b2356d
JJ
2779
2780@node compat Testing
500cdcb0 2781@section Support for testing binary compatibility
46b2356d
JJ
2782
2783The file @file{compat.exp} provides language-independent support for
2eac577f
JM
2784binary compatibility testing. It supports testing interoperability of
2785two compilers that follow the same ABI, or of multiple sets of
2786compiler options that should not affect binary compatibility. It is
2787intended to be used for testsuites that complement ABI testsuites.
46b2356d
JJ
2788
2789A test supported by this framework has three parts, each in a
2790separate source file: a main program and two pieces that interact
2791with each other to split up the functionality being tested.
2792
2793@table @file
2794@item @var{testname}_main.@var{suffix}
2795Contains the main program, which calls a function in file
2796@file{@var{testname}_x.@var{suffix}}.
2797
2798@item @var{testname}_x.@var{suffix}
2799Contains at least one call to a function in
2800@file{@var{testname}_y.@var{suffix}}.
2801
2802@item @var{testname}_y.@var{suffix}
2803Shares data with, or gets arguments from,
2804@file{@var{testname}_x.@var{suffix}}.
2805@end table
2806
2807Within each test, the main program and one functional piece are
2808compiled by the GCC under test. The other piece can be compiled by
2809an alternate compiler. If no alternate compiler is specified,
2810then all three source files are all compiled by the GCC under test.
c75095b2
JJ
2811You can specify pairs of sets of compiler options. The first element
2812of such a pair specifies options used with the GCC under test, and the
2813second element of the pair specifies options used with the alternate
2814compiler. Each test is compiled with each pair of options.
46b2356d
JJ
2815
2816@file{compat.exp} defines default pairs of compiler options.
2817These can be overridden by defining the environment variable
2818@env{COMPAT_OPTIONS} as:
2819
2820@smallexample
2821COMPAT_OPTIONS="[list [list @{@var{tst1}@} @{@var{alt1}@}]
923158be 2822 @dots{}[list @{@var{tstn}@} @{@var{altn}@}]]"
46b2356d
JJ
2823@end smallexample
2824
2825where @var{tsti} and @var{alti} are lists of options, with @var{tsti}
2826used by the compiler under test and @var{alti} used by the alternate
2827compiler. For example, with
2828@code{[list [list @{-g -O0@} @{-O3@}] [list @{-fpic@} @{-fPIC -O2@}]]},
4ec7afd7
KH
2829the test is first built with @option{-g -O0} by the compiler under
2830test and with @option{-O3} by the alternate compiler. The test is
2831built a second time using @option{-fpic} by the compiler under test
2832and @option{-fPIC -O2} by the alternate compiler.
46b2356d
JJ
2833
2834An alternate compiler is specified by defining an environment
c75095b2
JJ
2835variable to be the full pathname of an installed compiler; for C
2836define @env{ALT_CC_UNDER_TEST}, and for C++ define
2837@env{ALT_CXX_UNDER_TEST}. These will be written to the
2838@file{site.exp} file used by DejaGnu. The default is to build each
46b2356d
JJ
2839test with the compiler under test using the first of each pair of
2840compiler options from @env{COMPAT_OPTIONS}. When
c75095b2 2841@env{ALT_CC_UNDER_TEST} or
46b2356d
JJ
2842@env{ALT_CXX_UNDER_TEST} is @code{same}, each test is built using
2843the compiler under test but with combinations of the options from
2844@env{COMPAT_OPTIONS}.
2845
2846To run only the C++ compatibility suite using the compiler under test
2847and another version of GCC using specific compiler options, do the
2848following from @file{@var{objdir}/gcc}:
2849
2850@smallexample
2851rm site.exp
2852make -k \
2853 ALT_CXX_UNDER_TEST=$@{alt_prefix@}/bin/g++ \
17a7cb4e 2854 COMPAT_OPTIONS="@var{lists as shown above}" \
46b2356d
JJ
2855 check-c++ \
2856 RUNTESTFLAGS="compat.exp"
2857@end smallexample
2858
2859A test that fails when the source files are compiled with different
2860compilers, but passes when the files are compiled with the same
2861compiler, demonstrates incompatibility of the generated code or
2862runtime support. A test that fails for the alternate compiler but
2863passes for the compiler under test probably tests for a bug that was
2864fixed in the compiler under test but is present in the alternate
2865compiler.
c75095b2
JJ
2866
2867The binary compatibility tests support a small number of test framework
2868commands that appear within comments in a test file.
2869
2870@table @code
2871@item dg-require-*
2872These commands can be used in @file{@var{testname}_main.@var{suffix}}
2873to skip the test if specific support is not available on the target.
2874
2875@item dg-options
2876The specified options are used for compiling this particular source
2877file, appended to the options from @env{COMPAT_OPTIONS}. When this
2878command appears in @file{@var{testname}_main.@var{suffix}} the options
2879are also used to link the test program.
2880
2881@item dg-xfail-if
2882This command can be used in a secondary source file to specify that
2883compilation is expected to fail for particular options on particular
2884targets.
2885@end table
91a5b394
JJ
2886
2887@node Torture Tests
500cdcb0 2888@section Support for torture testing using multiple options
91a5b394
JJ
2889
2890Throughout the compiler testsuite there are several directories whose
2891tests are run multiple times, each with a different set of options.
2892These are known as torture tests.
17a7cb4e 2893@file{lib/torture-options.exp} defines procedures to
91a5b394
JJ
2894set up these lists:
2895
2896@table @code
2897@item torture-init
2898Initialize use of torture lists.
2899@item set-torture-options
2900Set lists of torture options to use for tests with and without loops.
2901Optionally combine a set of torture options with a set of other
2902options, as is done with Objective-C runtime options.
2903@item torture-finish
2904Finalize use of torture lists.
2905@end table
2906
2907The @file{.exp} file for a set of tests that use torture options must
a640c13b 2908include calls to these three procedures if:
91a5b394 2909
6f03c42c 2910@itemize @bullet
91a5b394
JJ
2911@item It calls @code{gcc-dg-runtest} and overrides @var{DG_TORTURE_OPTIONS}.
2912
2913@item It calls @var{$@{tool@}}@code{-torture} or
2914@var{$@{tool@}}@code{-torture-execute}, where @var{tool} is @code{c},
2915@code{fortran}, or @code{objc}.
2916
2917@item It calls @code{dg-pch}.
2918@end itemize
2919
2920It is not necessary for a @file{.exp} file that calls @code{gcc-dg-runtest}
2921to call the torture procedures if the tests should use the list in
2922@var{DG_TORTURE_OPTIONS} defined in @file{gcc-dg.exp}.
2923
2924Most uses of torture options can override the default lists by defining
52ebab2b
JJ
2925@var{TORTURE_OPTIONS} or add to the default list by defining
2926@var{ADDITIONAL_TORTURE_OPTIONS}. Define these in a @file{.dejagnurc}
2927file or add them to the @file{site.exp} file; for example
2928
2929@smallexample
07e5b056
JJ
2930set ADDITIONAL_TORTURE_OPTIONS [list \
2931 @{ -O2 -ftree-loop-linear @} \
52ebab2b
JJ
2932 @{ -O2 -fpeel-loops @} ]
2933@end smallexample