RISC-V: avoid LUI based const mat in alloca epilogue expansion
[official-gcc.git] / gcc / doc / sourcebuild.texi
blob8e4e59ac44c74277b63ee4d5016e15af01792e86
1 @c Copyright (C) 2002-2024 Free Software Foundation, Inc.
2 @c This is part of the GCC manual.
3 @c For copying conditions, see the file gcc.texi.
5 @node Source Tree
6 @chapter Source Tree Structure and Build System
8 This chapter describes the structure of the GCC source tree, and how
9 GCC is built.  The user documentation for building and installing GCC
10 is in a separate manual (@uref{https://gcc.gnu.org/install/}), with
11 which it is presumed that you are familiar.
13 @menu
14 * Configure Terms:: Configuration terminology and history.
15 * Top Level::       The top level source directory.
16 * gcc Directory::   The @file{gcc} subdirectory.
17 @end menu
19 @include configterms.texi
21 @node Top Level
22 @section Top Level Source Directory
24 The top level source directory in a GCC distribution contains several
25 files and directories that are shared with other software
26 distributions such as that of GNU Binutils.  It also contains several
27 subdirectories that contain parts of GCC and its runtime libraries:
29 @table @file
30 @item c++tools
31 Contains the sources for the g++-mapper-server, a tool used with
32 C++ modules.
34 @item config
35 Autoconf macros and Makefile fragments used throughout the tree.
37 @item contrib
38 Contributed scripts that may be found useful in conjunction with GCC@.
39 One of these, @file{contrib/texi2pod.pl}, is used to generate man
40 pages from Texinfo manuals as part of the GCC build process.
42 @item fixincludes
43 The support for fixing system headers to work with GCC@.  See
44 @file{fixincludes/README} for more information.  The headers fixed by
45 this mechanism are installed in @file{@var{libsubdir}/include-fixed}.
46 Along with those headers, @file{README-fixinc} is also installed, as
47 @file{@var{libsubdir}/include-fixed/README}.
49 @item gcc
50 The main sources of GCC itself (except for runtime libraries),
51 including optimizers, support for different target architectures,
52 language front ends, and testsuites.  @xref{gcc Directory, , The
53 @file{gcc} Subdirectory}, for details.
55 @item gnattools
56 Support tools for GNAT.
58 @item gotools
59 Support tools for Go.
61 @item include
62 Headers for the @code{libiberty} library.
64 @item intl
65 GNU @code{libintl}, from GNU @code{gettext}, for systems which do not
66 include it in @code{libc}.
68 @item libada
69 The Ada runtime library.
71 @item libatomic
72 The runtime support library for atomic operations (e.g.@: for @code{__sync}
73 and @code{__atomic}).
75 @item libbacktrace
76 A library that allows GCC to produce backtraces when it crashes.
78 @item libcc1
79 A library that allows GDB to make use of the compiler.
81 @item libcody
82 A compiler dynamism library to allow communication between compilers and
83 build systems, for purposes such as C++ modules.
85 @item libcpp
86 The C preprocessor library.
88 @item libdecnumber
89 The Decimal Float support library.
91 @item libffi
92 The @code{libffi} library, used as part of the Go runtime library.
94 @item libgcc
95 The GCC runtime library.
97 @item libgfortran
98 The Fortran runtime library.
100 @item libgm2
101 The Modula-2 runtime library.
103 @item libgo
104 The Go runtime library.  The bulk of this library is mirrored from the
105 @uref{https://github.com/@/golang/go, master Go repository}.
107 @item libgomp
108 The GNU Offloading and Multi Processing Runtime Library.
110 @item libiberty
111 The @code{libiberty} library, used for portability and for some
112 generally useful data structures and algorithms.  @xref{Top, ,
113 Introduction, libiberty, @sc{gnu} libiberty}, for more information
114 about this library.
116 @item libitm
117 The runtime support library for transactional memory.
119 @item libobjc
120 The Objective-C and Objective-C++ runtime library.
122 @item libphobos
123 The D standard and runtime library.  The bulk of this library is mirrored
124 from the @uref{https://github.com/@/dlang, master D repositories}.
126 @item libquadmath
127 The runtime support library for quad-precision math operations.
129 @item libsanitizer
130 Libraries for various sanitizers.  The bulk of this directory is mirrored
131 from the @uref{https://github.com/google/sanitizers, Google sanitizers
132 repositories}.
134 @item libssp
135 The Stack protector runtime library.
137 @item libstdc++-v3
138 The C++ runtime library.
140 @item libvtv
141 The vtable verification library.
143 @item lto-plugin
144 Plugin used by the linker if link-time optimizations are enabled.
146 @item maintainer-scripts
147 Scripts used by the @code{gccadmin} account on @code{gcc.gnu.org}.
149 @item zlib
150 The @code{zlib} compression library, used for compressing and
151 uncompressing GCC's intermediate language in LTO object files.
152 @end table
154 The build system in the top level directory, including how recursion
155 into subdirectories works and how building runtime libraries for
156 multilibs is handled, is documented in a separate manual, included
157 with GNU Binutils.
159 @node gcc Directory
160 @section The @file{gcc} Subdirectory
162 The @file{gcc} directory contains many files that are part of the C
163 sources of GCC, other files used as part of the configuration and
164 build process, and subdirectories including documentation and a
165 testsuite.  The files that are sources of GCC are documented in a
166 separate chapter.  @xref{Passes, , Passes and Files of the Compiler}.
168 @menu
169 * Subdirectories:: Subdirectories of @file{gcc}.
170 * Configuration::  The configuration process, and the files it uses.
171 * Build::          The build system in the @file{gcc} directory.
172 * Makefile::       Targets in @file{gcc/Makefile}.
173 * Library Files::  Library source files and headers under @file{gcc/}.
174 * Headers::        Headers installed by GCC.
175 * Documentation::  Building documentation in GCC.
176 * Front End::      Anatomy of a language front end.
177 * Back End::       Anatomy of a target back end.
178 @end menu
180 @node Subdirectories
181 @subsection Subdirectories of @file{gcc}
183 The @file{gcc} directory contains the following subdirectories:
185 @table @file
186 @item @var{language}
187 Subdirectories for various languages.  Directories containing a file
188 @file{config-lang.in} are language subdirectories.  The contents of
189 the subdirectories @file{c} (for C), @file{cp} (for C++), @file{m2}
190 (for Modula-2),
191 @file{objc} (for Objective-C), @file{objcp} (for Objective-C++),
192 and @file{lto} (for LTO) are documented in this
193 manual (@pxref{Passes, , Passes and Files of the Compiler});
194 those for other languages are not.  @xref{Front End, ,
195 Anatomy of a Language Front End}, for details of the files in these
196 directories.
198 @item common
199 Source files shared between the compiler drivers (such as
200 @command{gcc}) and the compilers proper (such as @file{cc1}).  If an
201 architecture defines target hooks shared between those places, it also
202 has a subdirectory in @file{common/config}.  @xref{Target Structure}.
204 @item config
205 Configuration files for supported architectures and operating
206 systems.  @xref{Back End, , Anatomy of a Target Back End}, for
207 details of the files in this directory.
209 @item doc
210 Texinfo documentation for GCC, together with automatically generated
211 man pages and support for converting the installation manual to
212 HTML@.  @xref{Documentation}.
214 @item ginclude
215 System headers installed by GCC, mainly those required by the C
216 standard of freestanding implementations.  @xref{Headers, , Headers
217 Installed by GCC}, for details of when these and other headers are
218 installed.
220 @item po
221 Message catalogs with translations of messages produced by GCC into
222 various languages, @file{@var{language}.po}.  This directory also
223 contains @file{gcc.pot}, the template for these message catalogues,
224 @file{exgettext}, a wrapper around @command{gettext} to extract the
225 messages from the GCC sources and create @file{gcc.pot}, which is run
226 by @samp{make gcc.pot}, and @file{EXCLUDES}, a list of files from
227 which messages should not be extracted.
229 @item testsuite
230 The GCC testsuites (except for those for runtime libraries).
231 @xref{Testsuites}.
232 @end table
234 @node Configuration
235 @subsection Configuration in the @file{gcc} Directory
237 The @file{gcc} directory is configured with an Autoconf-generated
238 script @file{configure}.  The @file{configure} script is generated
239 from @file{configure.ac} and @file{aclocal.m4}.  From the files
240 @file{configure.ac} and @file{acconfig.h}, Autoheader generates the
241 file @file{config.in}.  The file @file{cstamp-h.in} is used as a
242 timestamp.
244 @menu
245 * Config Fragments::     Scripts used by @file{configure}.
246 * System Config::        The @file{config.build}, @file{config.host}, and
247                          @file{config.gcc} files.
248 * Configuration Files::  Files created by running @file{configure}.
249 @end menu
251 @node Config Fragments
252 @subsubsection Scripts Used by @file{configure}
254 @file{configure} uses some other scripts to help in its work:
256 @itemize @bullet
257 @item The standard GNU @file{config.sub} and @file{config.guess}
258 files, kept in the top level directory, are used.
260 @item The file @file{config.gcc} is used to handle configuration
261 specific to the particular target machine.  The file
262 @file{config.build} is used to handle configuration specific to the
263 particular build machine.  The file @file{config.host} is used to handle
264 configuration specific to the particular host machine.  (In general,
265 these should only be used for features that cannot reasonably be tested in
266 Autoconf feature tests.)
267 @xref{System Config, , The @file{config.build}; @file{config.host};
268 and @file{config.gcc} Files}, for details of the contents of these files.
270 @item Each language subdirectory has a file
271 @file{@var{language}/config-lang.in} that is used for
272 front-end-specific configuration.  @xref{Front End Config, , The Front
273 End @file{config-lang.in} File}, for details of this file.
275 @item A helper script @file{configure.frag} is used as part of
276 creating the output of @file{configure}.
277 @end itemize
279 @node System Config
280 @subsubsection The @file{config.build}; @file{config.host}; and @file{config.gcc} Files
282 The @file{config.build} file contains specific rules for particular systems
283 which GCC is built on.  This should be used as rarely as possible, as the
284 behavior of the build system can always be detected by autoconf.
286 The @file{config.host} file contains specific rules for particular systems
287 which GCC will run on.  This is rarely needed.
289 The @file{config.gcc} file contains specific rules for particular systems
290 which GCC will generate code for.  This is usually needed.
292 Each file has a list of the shell variables it sets, with descriptions, at the
293 top of the file.
295 FIXME: document the contents of these files, and what variables should
296 be set to control build, host and target configuration.
298 @include configfiles.texi
300 @node Build
301 @subsection Build System in the @file{gcc} Directory
303 FIXME: describe the build system, including what is built in what
304 stages.  Also list the various source files that are used in the build
305 process but aren't source files of GCC itself and so aren't documented
306 below (@pxref{Passes}).
308 @include makefile.texi
310 @node Library Files
311 @subsection Library Source Files and Headers under the @file{gcc} Directory
313 FIXME: list here, with explanation, all the C source files and headers
314 under the @file{gcc} directory that aren't built into the GCC
315 executable but rather are part of runtime libraries and object files,
316 such as @file{crtstuff.c} and @file{unwind-dw2.c}.  @xref{Headers, ,
317 Headers Installed by GCC}, for more information about the
318 @file{ginclude} directory.
320 @node Headers
321 @subsection Headers Installed by GCC
323 In general, GCC expects the system C library to provide most of the
324 headers to be used with it.  However, GCC will fix those headers if
325 necessary to make them work with GCC, and will install some headers
326 required of freestanding implementations.  These headers are installed
327 in @file{@var{libsubdir}/include}.  Headers for non-C runtime
328 libraries are also installed by GCC; these are not documented here.
329 (FIXME: document them somewhere.)
331 Several of the headers GCC installs are in the @file{ginclude}
332 directory.  These headers, @file{iso646.h},
333 @file{stdarg.h}, @file{stdbool.h}, and @file{stddef.h},
334 are installed in @file{@var{libsubdir}/include},
335 unless the target Makefile fragment (@pxref{Target Fragment})
336 overrides this by setting @code{USER_H}.
338 In addition to these headers and those generated by fixing system
339 headers to work with GCC, some other headers may also be installed in
340 @file{@var{libsubdir}/include}.  @file{config.gcc} may set
341 @code{extra_headers}; this specifies additional headers under
342 @file{config} to be installed on some systems.
344 GCC installs its own version of @code{<float.h>}, from @file{ginclude/float.h}.
345 This is done to cope with command-line options that change the
346 representation of floating point numbers.
348 GCC also installs its own version of @code{<limits.h>}; this is generated
349 from @file{glimits.h}, together with @file{limitx.h} and
350 @file{limity.h} if the system also has its own version of
351 @code{<limits.h>}.  (GCC provides its own header because it is
352 required of ISO C freestanding implementations, but needs to include
353 the system header from its own header as well because other standards
354 such as POSIX specify additional values to be defined in
355 @code{<limits.h>}.)  The system's @code{<limits.h>} header is used via
356 @file{@var{libsubdir}/include/syslimits.h}, which is copied from
357 @file{gsyslimits.h} if it does not need fixing to work with GCC; if it
358 needs fixing, @file{syslimits.h} is the fixed copy.
360 GCC can also install @code{<tgmath.h>}.  It will do this when
361 @file{config.gcc} sets @code{use_gcc_tgmath} to @code{yes}.
363 @node Documentation
364 @subsection Building Documentation
366 The main GCC documentation is in the form of manuals in Texinfo
367 format.  These are installed in Info format; DVI versions may be
368 generated by @samp{make dvi}, PDF versions by @samp{make pdf}, and
369 HTML versions by @samp{make html}.  In addition, some man pages are
370 generated from the Texinfo manuals, there are some other text files
371 with miscellaneous documentation, and runtime libraries have their own
372 documentation outside the @file{gcc} directory.  FIXME: document the
373 documentation for runtime libraries somewhere.
375 @menu
376 * Texinfo Manuals::      GCC manuals in Texinfo format.
377 * Man Page Generation::  Generating man pages from Texinfo manuals.
378 * Miscellaneous Docs::   Miscellaneous text files with documentation.
379 @end menu
381 @node Texinfo Manuals
382 @subsubsection Texinfo Manuals
384 The manuals for GCC as a whole, and the C and C++ front ends, are in
385 files @file{doc/*.texi}.  Other front ends have their own manuals in
386 files @file{@var{language}/*.texi}.  Common files
387 @file{doc/include/*.texi} are provided which may be included in
388 multiple manuals; the following files are in @file{doc/include}:
390 @table @file
391 @item fdl.texi
392 The GNU Free Documentation License.
393 @item funding.texi
394 The section ``Funding Free Software''.
395 @item gcc-common.texi
396 Common definitions for manuals.
397 @item gpl_v3.texi
398 The GNU General Public License.
399 @item texinfo.tex
400 A copy of @file{texinfo.tex} known to work with the GCC manuals.
401 @end table
403 DVI-formatted manuals are generated by @samp{make dvi}, which uses
404 @command{texi2dvi} (via the Makefile macro @code{$(TEXI2DVI)}).
405 PDF-formatted manuals are generated by @samp{make pdf}, which uses
406 @command{texi2pdf} (via the Makefile macro @code{$(TEXI2PDF)}).  HTML
407 formatted manuals are generated by @samp{make html}.  Info
408 manuals are generated by @samp{make info} (which is run as part of
409 a bootstrap); this generates the manuals in the source directory,
410 using @command{makeinfo} via the Makefile macro @code{$(MAKEINFO)},
411 and they are included in release distributions.
413 Manuals are also provided on the GCC web site, in both HTML and
414 PostScript forms.  This is done via the script
415 @file{maintainer-scripts/update_web_docs_git}.  Each manual to be
416 provided online must be listed in the definition of @code{MANUALS} in
417 that file; a file @file{@var{name}.texi} must only appear once in the
418 source tree, and the output manual must have the same name as the
419 source file.  (However, other Texinfo files, included in manuals but
420 not themselves the root files of manuals, may have names that appear
421 more than once in the source tree.)  The manual file
422 @file{@var{name}.texi} should only include other files in its own
423 directory or in @file{doc/include}.  HTML manuals will be generated by
424 @samp{makeinfo --html}, PostScript manuals by @command{texi2dvi}
425 and @command{dvips}, and PDF manuals by @command{texi2pdf}.
426 All Texinfo files that are parts of manuals must
427 be version-controlled, even if they are generated files, for the
428 generation of online manuals to work.
430 The installation manual, @file{doc/install.texi}, is also provided on
431 the GCC web site.  The HTML version is generated by the script
432 @file{doc/install.texi2html}.
434 @node Man Page Generation
435 @subsubsection Man Page Generation
437 Because of user demand, in addition to full Texinfo manuals, man pages
438 are provided which contain extracts from those manuals.  These man
439 pages are generated from the Texinfo manuals using
440 @file{contrib/texi2pod.pl} and @command{pod2man}.  (The man page for
441 @command{g++}, @file{cp/g++.1}, just contains a @samp{.so} reference
442 to @file{gcc.1}, but all the other man pages are generated from
443 Texinfo manuals.)
445 Because many systems may not have the necessary tools installed to
446 generate the man pages, they are only generated if the
447 @file{configure} script detects that recent enough tools are
448 installed, and the Makefiles allow generating man pages to fail
449 without aborting the build.  Man pages are also included in release
450 distributions.  They are generated in the source directory.
452 Magic comments in Texinfo files starting @samp{@@c man} control what
453 parts of a Texinfo file go into a man page.  Only a subset of Texinfo
454 is supported by @file{texi2pod.pl}, and it may be necessary to add
455 support for more Texinfo features to this script when generating new
456 man pages.  To improve the man page output, some special Texinfo
457 macros are provided in @file{doc/include/gcc-common.texi} which
458 @file{texi2pod.pl} understands:
460 @table @code
461 @item @@gcctabopt
462 Use in the form @samp{@@table @@gcctabopt} for tables of options,
463 where for printed output the effect of @samp{@@code} is better than
464 that of @samp{@@option} but for man page output a different effect is
465 wanted.
466 @item @@gccoptlist
467 Use for summary lists of options in manuals.
468 @end table
470 FIXME: describe the @file{texi2pod.pl} input language and magic
471 comments in more detail.
473 @node Miscellaneous Docs
474 @subsubsection Miscellaneous Documentation
476 In addition to the formal documentation that is installed by GCC,
477 there are several other text files in the @file{gcc} subdirectory
478 with miscellaneous documentation:
480 @table @file
481 @item ABOUT-GCC-NLS
482 Notes on GCC's Native Language Support.  FIXME: this should be part of
483 this manual rather than a separate file.
484 @item ABOUT-NLS
485 Notes on the Free Translation Project.
486 @item COPYING
487 @itemx COPYING3
488 The GNU General Public License, Versions 2 and 3.
489 @item COPYING.LIB
490 @itemx COPYING3.LIB
491 The GNU Lesser General Public License, Versions 2.1 and 3.
492 @item *ChangeLog*
493 @itemx */ChangeLog*
494 Change log files for various parts of GCC@.
495 @item LANGUAGES
496 Details of a few changes to the GCC front-end interface.  FIXME: the
497 information in this file should be part of general documentation of
498 the front-end interface in this manual.
499 @item ONEWS
500 Information about new features in old versions of GCC@.  (For recent
501 versions, the information is on the GCC web site.)
502 @item README.Portability
503 Information about portability issues when writing code in GCC@.  FIXME:
504 why isn't this part of this manual or of the GCC Coding Conventions?
505 @end table
507 FIXME: document such files in subdirectories, at least @file{config},
508 @file{c}, @file{cp}, @file{objc}, @file{testsuite}.
510 @node Front End
511 @subsection Anatomy of a Language Front End
513 A front end for a language in GCC has the following parts:
515 @itemize @bullet
516 @item
517 A directory @file{@var{language}} under @file{gcc} containing source
518 files for that front end.  @xref{Front End Directory, , The Front End
519 @file{@var{language}} Directory}, for details.
520 @item
521 A mention of the language in the list of supported languages in
522 @file{gcc/doc/install.texi}.
523 @item
524 A mention of the name under which the language's runtime library is
525 recognized by @option{--enable-shared=@var{package}} in the
526 documentation of that option in @file{gcc/doc/install.texi}.
527 @item
528 A mention of any special prerequisites for building the front end in
529 the documentation of prerequisites in @file{gcc/doc/install.texi}.
530 @item
531 Details of contributors to that front end in
532 @file{gcc/doc/contrib.texi}.  If the details are in that front end's
533 own manual then there should be a link to that manual's list in
534 @file{contrib.texi}.
535 @item
536 Information about support for that language in
537 @file{gcc/doc/frontends.texi}.
538 @item
539 Information about standards for that language, and the front end's
540 support for them, in @file{gcc/doc/standards.texi}.  This may be a
541 link to such information in the front end's own manual.
542 @item
543 Details of source file suffixes for that language and @option{-x
544 @var{lang}} options supported, in @file{gcc/doc/invoke.texi}.
545 @item
546 Entries in @code{default_compilers} in @file{gcc.cc} for source file
547 suffixes for that language.
548 @item
549 Preferably testsuites, which may be under @file{gcc/testsuite} or
550 runtime library directories.  FIXME: document somewhere how to write
551 testsuite harnesses.
552 @item
553 Probably a runtime library for the language, outside the @file{gcc}
554 directory.  FIXME: document this further.
555 @item
556 Details of the directories of any runtime libraries in
557 @file{gcc/doc/sourcebuild.texi}.
558 @item
559 Check targets in @file{Makefile.def} for the top-level @file{Makefile}
560 to check just the compiler or the compiler and runtime library for the
561 language.
562 @end itemize
564 If the front end is added to the official GCC source repository, the
565 following are also necessary:
567 @itemize @bullet
568 @item
569 At least one Bugzilla component for bugs in that front end and runtime
570 libraries.  This category needs to be added to the Bugzilla database.
571 @item
572 Normally, one or more maintainers of that front end listed in
573 @file{MAINTAINERS}.
574 @item
575 Mentions on the GCC web site in @file{index.html} and
576 @file{frontends.html}, with any relevant links on
577 @file{readings.html}.  (Front ends that are not an official part of
578 GCC may also be listed on @file{frontends.html}, with relevant links.)
579 @item
580 A news item on @file{index.html}, and possibly an announcement on the
581 @email{gcc-announce@@gcc.gnu.org} mailing list.
582 @item
583 The front end's manuals should be mentioned in
584 @file{maintainer-scripts/update_web_docs_git} (@pxref{Texinfo Manuals})
585 and the online manuals should be linked to from
586 @file{onlinedocs/index.html}.
587 @item
588 If the front end has its own manual with its own index of options, the
589 generated @file{Option-Index.html} should be added to
590 @code{PER_LANGUAGE_OPTION_INDEXES} in @file{gcc/regenerate-opt-urls.py}
591 and to @code{OPT_URLS_HTML_DEPS} in @file{gcc/Makefile.in}.
592 @item
593 Any old releases or CVS repositories of the front end, before its
594 inclusion in GCC, should be made available on the GCC web site at
595 @uref{https://gcc.gnu.org/pub/gcc/old-releases/}.
596 @item
597 The release and snapshot script @file{maintainer-scripts/gcc_release}
598 should be updated to generate appropriate tarballs for this front end.
599 @item
600 If this front end includes its own version files that include the
601 current date, @file{maintainer-scripts/update_version} should be
602 updated accordingly.
603 @end itemize
605 @menu
606 * Front End Directory::  The front end @file{@var{language}} directory.
607 * Front End Config::     The front end @file{config-lang.in} file.
608 * Front End Makefile::   The front end @file{Make-lang.in} file.
609 @end menu
611 @node Front End Directory
612 @subsubsection The Front End @file{@var{language}} Directory
614 A front end @file{@var{language}} directory contains the source files
615 of that front end (but not of any runtime libraries, which should be
616 outside the @file{gcc} directory).  This includes documentation, and
617 possibly some subsidiary programs built alongside the front end.
618 Certain files are special and other parts of the compiler depend on
619 their names:
621 @table @file
622 @item config-lang.in
623 This file is required in all language subdirectories.  @xref{Front End
624 Config, , The Front End @file{config-lang.in} File}, for details of
625 its contents
626 @item Make-lang.in
627 This file is required in all language subdirectories.  @xref{Front End
628 Makefile, , The Front End @file{Make-lang.in} File}, for details of its
629 contents.
630 @item lang.opt
631 This file registers the set of switches that the front end accepts on
632 the command line, and their @option{--help} text.  @xref{Options}.
633 @item lang-specs.h
634 This file provides entries for @code{default_compilers} in
635 @file{gcc.cc} which override the default of giving an error that a
636 compiler for that language is not installed.
637 @item @var{language}-tree.def
638 This file, which need not exist, defines any language-specific tree
639 codes.
640 @end table
642 @node Front End Config
643 @subsubsection The Front End @file{config-lang.in} File
645 Each language subdirectory contains a @file{config-lang.in} file.
646 This file is a shell script that may define some variables describing
647 the language:
649 @table @code
650 @item language
651 This definition must be present, and gives the name of the language
652 for some purposes such as arguments to @option{--enable-languages}.
653 @item lang_requires
654 If defined, this variable lists (space-separated) language front ends
655 other than C that this front end requires to be enabled (with the
656 names given being their @code{language} settings).  For example, the
657 Obj-C++ front end depends on the C++ and ObjC front ends, so sets
658 @samp{lang_requires="objc c++"}.
659 @item subdir_requires
660 If defined, this variable lists (space-separated) front end directories
661 other than C that this front end requires to be present.  For example,
662 the Objective-C++ front end uses source files from the C++ and
663 Objective-C front ends, so sets @samp{subdir_requires="cp objc"}.
664 @item target_libs
665 If defined, this variable lists (space-separated) targets in the top
666 level @file{Makefile} to build the runtime libraries for this
667 language, such as @code{target-libobjc}.
668 @item lang_dirs
669 If defined, this variable lists (space-separated) top level
670 directories (parallel to @file{gcc}), apart from the runtime libraries,
671 that should not be configured if this front end is not built.
672 @item build_by_default
673 If defined to @samp{no}, this language front end is not built unless
674 enabled in a @option{--enable-languages} argument.  Otherwise, front
675 ends are built by default, subject to any special logic in
676 @file{configure.ac} (as is present to disable the Ada front end if the
677 Ada compiler is not already installed).
678 @item boot_language
679 If defined to @samp{yes}, this front end is built in stage1 of the
680 bootstrap.  This is only relevant to front ends written in their own
681 languages.
682 @item compilers
683 If defined, a space-separated list of compiler executables that will
684 be run by the driver.  The names here will each end
685 with @samp{\$(exeext)}.
686 @item outputs
687 If defined, a space-separated list of files that should be generated
688 by @file{configure} substituting values in them.  This mechanism can
689 be used to create a file @file{@var{language}/Makefile} from
690 @file{@var{language}/Makefile.in}, but this is deprecated, building
691 everything from the single @file{gcc/Makefile} is preferred.
692 @item gtfiles
693 If defined, a space-separated list of files that should be scanned by
694 @file{gengtype.cc} to generate the garbage collection tables and routines for
695 this language.  This excludes the files that are common to all front
696 ends.  @xref{Type Information}.
698 @end table
700 @node Front End Makefile
701 @subsubsection The Front End @file{Make-lang.in} File
703 Each language subdirectory contains a @file{Make-lang.in} file.  It contains
704 targets @code{@var{lang}.@var{hook}} (where @code{@var{lang}} is the
705 setting of @code{language} in @file{config-lang.in}) for the following
706 values of @code{@var{hook}}, and any other Makefile rules required to
707 build those targets (which may if necessary use other Makefiles
708 specified in @code{outputs} in @file{config-lang.in}, although this is
709 deprecated).  It also adds any testsuite targets that can use the
710 standard rule in @file{gcc/Makefile.in} to the variable
711 @code{lang_checks}.
713 @table @code
714 @item all.cross
715 @itemx start.encap
716 @itemx rest.encap
717 FIXME: exactly what goes in each of these targets?
718 @item tags
719 Build an @command{etags} @file{TAGS} file in the language subdirectory
720 in the source tree.
721 @item info
722 Build info documentation for the front end, in the build directory.
723 This target is only called by @samp{make bootstrap} if a suitable
724 version of @command{makeinfo} is available, so does not need to check
725 for this, and should fail if an error occurs.
726 @item dvi
727 Build DVI documentation for the front end, in the build directory.
728 This should be done using @code{$(TEXI2DVI)}, with appropriate
729 @option{-I} arguments pointing to directories of included files.
730 @item pdf
731 Build PDF documentation for the front end, in the build directory.
732 This should be done using @code{$(TEXI2PDF)}, with appropriate
733 @option{-I} arguments pointing to directories of included files.
734 @item html
735 Build HTML documentation for the front end, in the build directory.
736 @item man
737 Build generated man pages for the front end from Texinfo manuals
738 (@pxref{Man Page Generation}), in the build directory.  This target
739 is only called if the necessary tools are available, but should ignore
740 errors so as not to stop the build if errors occur; man pages are
741 optional and the tools involved may be installed in a broken way.
742 @item install-common
743 Install everything that is part of the front end, apart from the
744 compiler executables listed in @code{compilers} in
745 @file{config-lang.in}.
746 @item install-info
747 Install info documentation for the front end, if it is present in the
748 source directory.  This target should have dependencies on info files
749 that should be installed.
750 @item install-man
751 Install man pages for the front end.  This target should ignore
752 errors.
753 @item install-plugin
754 Install headers needed for plugins.
755 @item srcextra
756 Copies its dependencies into the source directory.  This generally should
757 be used for generated files such as Bison output files which are not
758 version-controlled, but should be included in any release tarballs.  This
759 target will be executed during a bootstrap if
760 @samp{--enable-generated-files-in-srcdir} was specified as a
761 @file{configure} option.
762 @item srcinfo
763 @itemx srcman
764 Copies its dependencies into the source directory.  These targets will be
765 executed during a bootstrap if @samp{--enable-generated-files-in-srcdir}
766 was specified as a @file{configure} option.
767 @item uninstall
768 Uninstall files installed by installing the compiler.  This is
769 currently documented not to be supported, so the hook need not do
770 anything.
771 @item mostlyclean
772 @itemx clean
773 @itemx distclean
774 @itemx maintainer-clean
775 The language parts of the standard GNU
776 @samp{*clean} targets.  @xref{Standard Targets, , Standard Targets for
777 Users, standards, GNU Coding Standards}, for details of the standard
778 targets.  For GCC, @code{maintainer-clean} should delete
779 all generated files in the source directory that are not version-controlled,
780 but should not delete anything that is.
781 @end table
783 @file{Make-lang.in} must also define a variable @code{@var{lang}_OBJS}
784 to a list of host object files that are used by that language.
786 @node Back End
787 @subsection Anatomy of a Target Back End
789 A back end for a target architecture in GCC has the following parts:
791 @itemize @bullet
792 @item
793 A directory @file{@var{machine}} under @file{gcc/config}, containing a
794 machine description @file{@var{machine}.md} file (@pxref{Machine Desc,
795 , Machine Descriptions}), header files @file{@var{machine}.h} and
796 @file{@var{machine}-protos.h} and a source file @file{@var{machine}.c}
797 (@pxref{Target Macros, , Target Description Macros and Functions}),
798 possibly a target Makefile fragment @file{t-@var{machine}}
799 (@pxref{Target Fragment, , The Target Makefile Fragment}), and maybe
800 some other files.  The names of these files may be changed from the
801 defaults given by explicit specifications in @file{config.gcc}.
802 @item
803 If necessary, a file @file{@var{machine}-modes.def} in the
804 @file{@var{machine}} directory, containing additional machine modes to
805 represent condition codes.  @xref{Condition Code}, for further details.
806 @item
807 An optional @file{@var{machine}.opt} file in the @file{@var{machine}}
808 directory, containing a list of target-specific options.  You can also
809 add other option files using the @code{extra_options} variable in
810 @file{config.gcc}.  @xref{Options}.
811 @item
812 Entries in @file{config.gcc} (@pxref{System Config, , The
813 @file{config.gcc} File}) for the systems with this target
814 architecture.
815 @item
816 Documentation in @file{gcc/doc/invoke.texi} for any command-line
817 options supported by this target (@pxref{Run-time Target, , Run-time
818 Target Specification}).  This means both entries in the summary table
819 of options and details of the individual options.
820 @item
821 An entry in @file{gcc/regenerate-opt-urls.py}'s TARGET_SPECIFIC_PAGES
822 dictionary mapping from target-specific HTML documentation pages
823 to the target specific source directory.
824 @item
825 Documentation in @file{gcc/doc/extend.texi} for any target-specific
826 attributes supported (@pxref{Target Attributes, , Defining
827 target-specific uses of @code{__attribute__}}), including where the
828 same attribute is already supported on some targets, which are
829 enumerated in the manual.
830 @item
831 Documentation in @file{gcc/doc/extend.texi} for any target-specific
832 pragmas supported.
833 @item
834 Documentation in @file{gcc/doc/extend.texi} of any target-specific
835 built-in functions supported.
836 @item
837 Documentation in @file{gcc/doc/extend.texi} of any target-specific
838 format checking styles supported.
839 @item
840 Documentation in @file{gcc/doc/md.texi} of any target-specific
841 constraint letters (@pxref{Machine Constraints, , Constraints for
842 Particular Machines}).
843 @item
844 A note in @file{gcc/doc/contrib.texi} under the person or people who
845 contributed the target support.
846 @item
847 Entries in @file{gcc/doc/install.texi} for all target triplets
848 supported with this target architecture, giving details of any special
849 notes about installation for this target, or saying that there are no
850 special notes if there are none.
851 @item
852 Possibly other support outside the @file{gcc} directory for runtime
853 libraries.  FIXME: reference docs for this.  The @code{libstdc++} porting
854 manual needs to be installed as info for this to work, or to be a
855 chapter of this manual.
856 @end itemize
858 The @file{@var{machine}.h} header is included very early in GCC's
859 standard sequence of header files, while @file{@var{machine}-protos.h}
860 is included late in the sequence.  Thus @file{@var{machine}-protos.h}
861 can include declarations referencing types that are not defined when
862 @file{@var{machine}.h} is included, specifically including those from
863 @file{rtl.h} and @file{tree.h}.  Since both RTL and tree types may not
864 be available in every context where @file{@var{machine}-protos.h} is
865 included, in this file you should guard declarations using these types
866 inside appropriate @code{#ifdef RTX_CODE} or @code{#ifdef TREE_CODE}
867 conditional code segments.
869 If the backend uses shared data structures that require @code{GTY} markers 
870 for garbage collection (@pxref{Type Information}), you must declare those
871 in @file{@var{machine}.h} rather than @file{@var{machine}-protos.h}.  
872 Any definitions required for building libgcc must also go in
873 @file{@var{machine}.h}.
875 GCC uses the macro @code{IN_TARGET_CODE} to distinguish between
876 machine-specific @file{.c} and @file{.cc} files and
877 machine-independent @file{.c} and @file{.cc} files.  Machine-specific
878 files should use the directive:
880 @example
881 #define IN_TARGET_CODE 1
882 @end example
884 before including @code{config.h}.
886 If the back end is added to the official GCC source repository, the
887 following are also necessary:
889 @itemize @bullet
890 @item
891 An entry for the target architecture in @file{readings.html} on the
892 GCC web site, with any relevant links.
893 @item
894 Details of the properties of the back end and target architecture in
895 @file{backends.html} on the GCC web site.
896 @item
897 A news item about the contribution of support for that target
898 architecture, in @file{index.html} on the GCC web site.
899 @item
900 Normally, one or more maintainers of that target listed in
901 @file{MAINTAINERS}.  Some existing architectures may be unmaintained,
902 but it would be unusual to add support for a target that does not have
903 a maintainer when support is added.
904 @item
905 Target triplets covering all @file{config.gcc} stanzas for the target,
906 in the list in @file{contrib/config-list.mk}.
907 @end itemize
909 @node Testsuites
910 @chapter Testsuites
912 GCC contains several testsuites to help maintain compiler quality.
913 Most of the runtime libraries and language front ends in GCC have
914 testsuites.  Currently only the C language testsuites are documented
915 here; FIXME: document the others.
917 @menu
918 * Test Idioms::     Idioms used in testsuite code.
919 * Test Directives:: Directives used within DejaGnu tests.
920 * Ada Tests::       The Ada language testsuites.
921 * C Tests::         The C language testsuites.
922 * LTO Testing::     Support for testing link-time optimizations.
923 * gcov Testing::    Support for testing gcov.
924 * profopt Testing:: Support for testing profile-directed optimizations.
925 * compat Testing::  Support for testing binary compatibility.
926 * Torture Tests::   Support for torture testing using multiple options.
927 * GIMPLE Tests::    Support for testing GIMPLE passes.
928 * RTL Tests::       Support for testing RTL passes.
929 @end menu
931 @node Test Idioms
932 @section Idioms Used in Testsuite Code
934 In general, C testcases have a trailing @file{-@var{n}.c}, starting
935 with @file{-1.c}, in case other testcases with similar names are added
936 later.  If the test is a test of some well-defined feature, it should
937 have a name referring to that feature such as
938 @file{@var{feature}-1.c}.  If it does not test a well-defined feature
939 but just happens to exercise a bug somewhere in the compiler, and a
940 bug report has been filed for this bug in the GCC bug database,
941 @file{pr@var{bug-number}-1.c} is the appropriate form of name.
942 Otherwise (for miscellaneous bugs not filed in the GCC bug database),
943 and previously more generally, test cases are named after the date on
944 which they were added.  This allows people to tell at a glance whether
945 a test failure is because of a recently found bug that has not yet
946 been fixed, or whether it may be a regression, but does not give any
947 other information about the bug or where discussion of it may be
948 found.  Some other language testsuites follow similar conventions.
950 In the @file{gcc.dg} testsuite, it is often necessary to test that an
951 error is indeed a hard error and not just a warning---for example,
952 where it is a constraint violation in the C standard, which must
953 become an error with @option{-pedantic-errors}.  The following idiom,
954 where the first line shown is line @var{line} of the file and the line
955 that generates the error, is used for this:
957 @smallexample
958 /* @{ dg-bogus "warning" "warning in place of error" @} */
959 /* @{ dg-error "@var{regexp}" "@var{message}" @{ target *-*-* @} @var{line} @} */
960 @end smallexample
962 It may be necessary to check that an expression is an integer constant
963 expression and has a certain value.  To check that @code{@var{E}} has
964 value @code{@var{V}}, an idiom similar to the following is used:
966 @smallexample
967 char x[((E) == (V) ? 1 : -1)];
968 @end smallexample
970 In @file{gcc.dg} tests, @code{__typeof__} is sometimes used to make
971 assertions about the types of expressions.  See, for example,
972 @file{gcc.dg/c99-condexpr-1.c}.  The more subtle uses depend on the
973 exact rules for the types of conditional expressions in the C
974 standard; see, for example, @file{gcc.dg/c99-intconst-1.c}.
976 It is useful to be able to test that optimizations are being made
977 properly.  This cannot be done in all cases, but it can be done where
978 the optimization will lead to code being optimized away (for example,
979 where flow analysis or alias analysis should show that certain code
980 cannot be called) or to functions not being called because they have
981 been expanded as built-in functions.  Such tests go in
982 @file{gcc.c-torture/execute}.  Where code should be optimized away, a
983 call to a nonexistent function such as @code{link_failure ()} may be
984 inserted; a definition
986 @smallexample
987 #ifndef __OPTIMIZE__
988 void
989 link_failure (void)
991   abort ();
993 #endif
994 @end smallexample
996 @noindent
997 will also be needed so that linking still succeeds when the test is
998 run without optimization.  When all calls to a built-in function
999 should have been optimized and no calls to the non-built-in version of
1000 the function should remain, that function may be defined as
1001 @code{static} to call @code{abort ()} (although redeclaring a function
1002 as static may not work on all targets).
1004 All testcases must be portable.  Target-specific testcases must have
1005 appropriate code to avoid causing failures on unsupported systems;
1006 unfortunately, the mechanisms for this differ by directory.
1008 FIXME: discuss non-C testsuites here.
1010 @node Test Directives
1011 @section Directives used within DejaGnu tests
1013 @menu
1014 * Directives::  Syntax and descriptions of test directives.
1015 * Selectors:: Selecting targets to which a test applies.
1016 * Effective-Target Keywords:: Keywords describing target attributes.
1017 * Add Options:: Features for @code{dg-add-options}
1018 * Require Support:: Variants of @code{dg-require-@var{support}}
1019 * Final Actions:: Commands for use in @code{dg-final}
1020 @end menu
1022 @node Directives
1023 @subsection Syntax and Descriptions of test directives
1025 Test directives appear within comments in a test source file and begin
1026 with @code{dg-}.  Some of these are defined within DejaGnu and others
1027 are local to the GCC testsuite.
1029 The order in which test directives appear in a test can be important:
1030 directives local to GCC sometimes override information used by the
1031 DejaGnu directives, which know nothing about the GCC directives, so the
1032 DejaGnu directives must precede GCC directives.
1034 Several test directives include selectors (@pxref{Selectors, , })
1035 which are usually preceded by the keyword @code{target} or @code{xfail}.
1037 @subsubsection Specify how to build the test
1039 @table @code
1040 @item @{ dg-do @var{do-what-keyword} [@{ target/xfail @var{selector} @}] @}
1041 @var{do-what-keyword} specifies how the test is compiled and whether
1042 it is executed.  It is one of:
1044 @table @code
1045 @item preprocess
1046 Compile with @option{-E} to run only the preprocessor.
1047 @item compile
1048 Compile with @option{-S} to produce an assembly code file.
1049 @item assemble
1050 Compile with @option{-c} to produce a relocatable object file.
1051 @item link
1052 Compile, assemble, and link to produce an executable file.
1053 @item run
1054 Produce and run an executable file, which is expected to return
1055 an exit code of 0.
1056 @end table
1058 The default is @code{compile}.  That can be overridden for a set of
1059 tests by redefining @code{dg-do-what-default} within the @code{.exp}
1060 file for those tests.
1062 If the directive includes the optional @samp{@{ target @var{selector} @}}
1063 then the test is skipped unless the target system matches the
1064 @var{selector}.
1066 If @var{do-what-keyword} is @code{run} and the directive includes
1067 the optional @samp{@{ xfail @var{selector} @}} and the selector is met
1068 then the test is expected to fail.  The @code{xfail} clause is ignored
1069 for other values of @var{do-what-keyword}; those tests can use
1070 directive @code{dg-xfail-if}.
1071 @end table
1073 @subsubsection Specify additional compiler options
1075 @table @code
1076 @item @{ dg-options @var{options} [@{ target @var{selector} @}] @}
1077 This DejaGnu directive provides a list of compiler options, to be used
1078 if the target system matches @var{selector}, that replace the default
1079 options used for this set of tests.
1081 @item @{ dg-add-options @var{feature} @dots{} @}
1082 Add any compiler options that are needed to access certain features.
1083 This directive does nothing on targets that enable the features by
1084 default, or that don't provide them at all.  It must come after
1085 all @code{dg-options} directives.
1086 For supported values of @var{feature} see @ref{Add Options, ,}.
1088 @item @{ dg-additional-options @var{options} [@{ target @var{selector} @}] @}
1089 This directive provides a list of compiler options, to be used
1090 if the target system matches @var{selector}, that are added to the default
1091 options used for this set of tests.
1092 @end table
1094 @subsubsection Modify the test timeout value
1096 The normal timeout limit, in seconds, is found by searching the
1097 following in order:
1099 @itemize @bullet
1100 @item the value defined by an earlier @code{dg-timeout} directive in
1101 the test
1103 @item variable @var{tool_timeout} defined by the set of tests
1105 @item @var{gcc},@var{timeout} set in the target board
1107 @item 300
1108 @end itemize
1110 @table @code
1111 @item @{ dg-timeout @var{n} [@{target @var{selector} @}] @}
1112 Set the time limit for the compilation and for the execution of the test
1113 to the specified number of seconds.
1115 @item @{ dg-timeout-factor @var{x} [@{ target @var{selector} @}] @}
1116 Multiply the normal time limit for compilation and execution of the test
1117 by the specified floating-point factor.
1118 @end table
1120 @subsubsection Skip a test for some targets
1122 @table @code
1123 @item @{ dg-skip-if @var{comment} @{ @var{selector} @} [@{ @var{include-opts} @} [@{ @var{exclude-opts} @}]] @}
1124 Arguments @var{include-opts} and @var{exclude-opts} are lists in which
1125 each element is a string of zero or more GCC options.
1126 Skip the test if all of the following conditions are met:
1127 @itemize @bullet
1128 @item the test system is included in @var{selector}
1130 @item for at least one of the option strings in @var{include-opts},
1131 every option from that string is in the set of options with which
1132 the test would be compiled; use @samp{"*"} for an @var{include-opts} list
1133 that matches any options; that is the default if @var{include-opts} is
1134 not specified
1136 @item for each of the option strings in @var{exclude-opts}, at least one
1137 option from that string is not in the set of options with which the test
1138 would be compiled; use @samp{""} for an empty @var{exclude-opts} list;
1139 that is the default if @var{exclude-opts} is not specified
1140 @end itemize
1142 For example, to skip a test if option @code{-Os} is present:
1144 @smallexample
1145 /* @{ dg-skip-if "" @{ *-*-* @}  @{ "-Os" @} @{ "" @} @} */
1146 @end smallexample
1148 To skip a test if both options @code{-O2} and @code{-g} are present:
1150 @smallexample
1151 /* @{ dg-skip-if "" @{ *-*-* @}  @{ "-O2 -g" @} @{ "" @} @} */
1152 @end smallexample
1154 To skip a test if either @code{-O2} or @code{-O3} is present:
1156 @smallexample
1157 /* @{ dg-skip-if "" @{ *-*-* @}  @{ "-O2" "-O3" @} @{ "" @} @} */
1158 @end smallexample
1160 To skip a test unless option @code{-Os} is present:
1162 @smallexample
1163 /* @{ dg-skip-if "" @{ *-*-* @}  @{ "*" @} @{ "-Os" @} @} */
1164 @end smallexample
1166 To skip a test if either @code{-O2} or @code{-O3} is used with @code{-g}
1167 but not if @code{-fpic} is also present:
1169 @smallexample
1170 /* @{ dg-skip-if "" @{ *-*-* @}  @{ "-O2 -g" "-O3 -g" @} @{ "-fpic" @} @} */
1171 @end smallexample
1173 @item @{ dg-require-effective-target @var{keyword} [@{ target @var{selector} @}] @}
1174 Skip the test if the test target, including current multilib flags,
1175 is not covered by the effective-target keyword.
1176 If the directive includes the optional @samp{@{ @var{selector} @}}
1177 then the effective-target test is only performed if the target system
1178 matches the @var{selector}.
1179 This directive must appear after any @code{dg-do} directive in the test
1180 and before any @code{dg-additional-sources} directive.
1181 @xref{Effective-Target Keywords, , }.
1183 @item @{ dg-require-@var{support} args @}
1184 Skip the test if the target does not provide the required support.
1185 These directives must appear after any @code{dg-do} directive in the test
1186 and before any @code{dg-additional-sources} directive.
1187 They require at least one argument, which can be an empty string if the
1188 specific procedure does not examine the argument.
1189 @xref{Require Support, , }, for a complete list of these directives.
1190 @end table
1192 @subsubsection Expect a test to fail for some targets
1194 @table @code
1195 @item  @{ dg-xfail-if @var{comment} @{ @var{selector} @} [@{ @var{include-opts} @} [@{ @var{exclude-opts} @}]] @}
1196 Expect the test to fail if the conditions (which are the same as for
1197 @code{dg-skip-if}) are met.  This does not affect the execute step.
1199 @item  @{ dg-xfail-run-if @var{comment} @{ @var{selector} @} [@{ @var{include-opts} @} [@{ @var{exclude-opts} @}]] @}
1200 Expect the execute step of a test to fail if the conditions (which are
1201 the same as for @code{dg-skip-if}) are met.
1202 @end table
1204 @subsubsection Expect the compiler to crash
1206 @table @code
1207 @item  @{ dg-ice @var{comment} [@{ @var{selector} @} [@{ @var{include-opts} @} [@{ @var{exclude-opts} @}]]] @}
1208 Expect the compiler to crash with an internal compiler error and return
1209 a nonzero exit status if the conditions (which are the same as for
1210 @code{dg-skip-if}) are met.  Used for tests that test bugs that have not been
1211 fixed yet.
1212 @end table
1214 @subsubsection Expect the test executable to fail
1216 @table @code
1217 @item  @{ dg-shouldfail @var{comment} [@{ @var{selector} @} [@{ @var{include-opts} @} [@{ @var{exclude-opts} @}]]] @}
1218 Expect the test executable to return a nonzero exit status if the
1219 conditions (which are the same as for @code{dg-skip-if}) are met.
1220 @end table
1222 @subsubsection Verify compiler messages
1223 Where @var{line} is an accepted argument for these commands, a value of @samp{0}
1224 can be used if there is no line associated with the message.
1226 @table @code
1227 @item @{ dg-error @var{regexp} [@var{comment} [@{ target/xfail @var{selector} @} [@var{line}] ]] @}
1228 This DejaGnu directive appears on a source line that is expected to get
1229 an error message, or else specifies the source line associated with the
1230 message.  If there is no message for that line or if the text of that
1231 message is not matched by @var{regexp} then the check fails and
1232 @var{comment} is included in the @code{FAIL} message.  The check does
1233 not look for the string @samp{error} unless it is part of @var{regexp}.
1235 @item @{ dg-warning @var{regexp} [@var{comment} [@{ target/xfail @var{selector} @} [@var{line}] ]] @}
1236 This DejaGnu directive appears on a source line that is expected to get
1237 a warning message, or else specifies the source line associated with the
1238 message.  If there is no message for that line or if the text of that
1239 message is not matched by @var{regexp} then the check fails and
1240 @var{comment} is included in the @code{FAIL} message.  The check does
1241 not look for the string @samp{warning} unless it is part of @var{regexp}.
1243 @item @{ dg-message @var{regexp} [@var{comment} [@{ target/xfail @var{selector} @} [@var{line}] ]] @}
1244 The line is expected to get a message other than an error or warning.
1245 If there is no message for that line or if the text of that message is
1246 not matched by @var{regexp} then the check fails and @var{comment} is
1247 included in the @code{FAIL} message.
1249 @item @{ dg-note @var{regexp} [@var{comment} [@{ target/xfail @var{selector} @} [@var{line}] ]] @}
1250 The line is expected to get a @samp{note} message.
1251 If there is no message for that line or if the text of that message is
1252 not matched by @var{regexp} then the check fails and @var{comment} is
1253 included in the @code{FAIL} message.
1255 By default, any @emph{excess} @samp{note} messages are pruned, meaning
1256 their appearance doesn't trigger @emph{excess errors}.
1257 However, if @samp{dg-note} is used at least once in a testcase,
1258 they're not pruned and instead must @emph{all} be handled explicitly.
1259 Thus, if looking for just single instances of messages with
1260 @samp{note: } prefixes without caring for all of them, use
1261 @samp{dg-message "note: [@dots{}]"} instead of @samp{dg-note}, or use
1262 @samp{dg-note} together with @samp{dg-prune-output "note: "}.
1264 @item @{ dg-bogus @var{regexp} [@var{comment} [@{ target/xfail @var{selector} @} [@var{line}] ]] @}
1265 This DejaGnu directive appears on a source line that should not get a
1266 message matching @var{regexp}, or else specifies the source line
1267 associated with the bogus message.  It is usually used with @samp{xfail}
1268 to indicate that the message is a known problem for a particular set of
1269 targets.
1271 @item @{ dg-line @var{linenumvar} @}
1272 This DejaGnu directive sets the variable @var{linenumvar} to the line number of
1273 the source line.  The variable @var{linenumvar} can then be used in subsequent
1274 @code{dg-error}, @code{dg-warning}, @code{dg-message}, @code{dg-note}
1275 and @code{dg-bogus}
1276 directives.  For example:
1278 @smallexample
1279 int a;   /* @{ dg-line first_def_a @} */
1280 float a; /* @{ dg-error "conflicting types of" @} */
1281 /* @{ dg-message "previous declaration of" "" @{ target *-*-* @} first_def_a @} */
1282 @end smallexample
1284 @item @{ dg-excess-errors @var{comment} [@{ target/xfail @var{selector} @}] @}
1285 This DejaGnu directive indicates that the test is expected to fail due
1286 to compiler messages that are not handled by @samp{dg-error},
1287 @samp{dg-warning}, @code{dg-message}, @samp{dg-note} or
1288 @samp{dg-bogus}.
1289 For this directive @samp{xfail}
1290 has the same effect as @samp{target}.
1292 @item @{ dg-prune-output @var{regexp} @}
1293 Prune messages matching @var{regexp} from the test output.
1294 @end table
1296 @subsubsection Verify output of the test executable
1298 @table @code
1299 @item @{ dg-output @var{regexp} [@{ target/xfail @var{selector} @}] @}
1300 This DejaGnu directive compares @var{regexp} to the combined output
1301 that the test executable writes to @file{stdout} and @file{stderr}.
1302 @end table
1304 @subsubsection Specify environment variables for a test
1306 @table @code
1307 @item @{ dg-set-compiler-env-var @var{var_name} "@var{var_value}" @}
1308 Specify that the environment variable @var{var_name} needs to be set
1309 to @var{var_value} before invoking the compiler on the test file.
1311 @item @{ dg-set-target-env-var @var{var_name} "@var{var_value}" @}
1312 Specify that the environment variable @var{var_name} needs to be set
1313 to @var{var_value} before execution of the program created by the test.
1314 @end table
1316 @subsubsection Specify additional files for a test
1318 @table @code
1319 @item @{ dg-additional-files "@var{filelist}" @}
1320 Specify additional files, other than source files, that must be copied
1321 to the system where the compiler runs.
1323 @item @{ dg-additional-sources "@var{filelist}" @}
1324 Specify additional source files to appear in the compile line
1325 following the main test file.
1326 @end table
1328 @subsubsection Add checks at the end of a test
1330 @table @code
1331 @item @{ dg-final @{ @var{local-directive} @} @}
1332 This DejaGnu directive is placed within a comment anywhere in the
1333 source file and is processed after the test has been compiled and run.
1334 Multiple @samp{dg-final} commands are processed in the order in which
1335 they appear in the source file.  @xref{Final Actions, , }, for a list
1336 of directives that can be used within @code{dg-final}.
1337 @end table
1339 @node Selectors
1340 @subsection Selecting targets to which a test applies
1342 Several test directives include @var{selector}s to limit the targets
1343 for which a test is run or to declare that a test is expected to fail
1344 on particular targets.
1346 A selector is:
1347 @itemize @bullet
1348 @item one or more target triplets, possibly including wildcard characters;
1349 use @samp{*-*-*} to match any target
1350 @item a single effective-target keyword (@pxref{Effective-Target Keywords})
1351 @item a list of compiler options that should be included or excluded
1352 (as described in more detail below)
1353 @item a logical expression
1354 @end itemize
1356 Depending on the context, the selector specifies whether a test is
1357 skipped and reported as unsupported or is expected to fail.  A context
1358 that allows either @samp{target} or @samp{xfail} also allows
1359 @samp{@{ target @var{selector1} xfail @var{selector2} @}}
1360 to skip the test for targets that don't match @var{selector1} and the
1361 test to fail for targets that match @var{selector2}.
1363 A selector expression appears within curly braces and uses a single
1364 logical operator: one of @samp{!}, @samp{&&}, or @samp{||}.  An
1365 operand is one of the following:
1367 @itemize @bullet
1368 @item
1369 another selector expression, in curly braces
1371 @item
1372 an effective-target keyword, such as @code{lp64}
1374 @item
1375 a single target triplet
1377 @item
1378 a list of target triplets within quotes or curly braces
1380 @item
1381 one of the following:
1383 @table @samp
1384 @item @{ any-opts @var{opt1} @dots{} @var{optn} @}
1385 Each of @var{opt1} to @var{optn} is a space-separated list of option globs.
1386 The selector expression evaluates to true if, for one of these strings,
1387 every glob in the string matches an option that was passed to the compiler.
1388 For example:
1390 @smallexample
1391 @{ any-opts "-O3 -flto" "-O[2g]" @}
1392 @end smallexample
1394 is true if any of the following are true:
1396 @itemize @bullet
1397 @item
1398 @option{-O2} was passed to the compiler
1400 @item
1401 @option{-Og} was passed to the compiler
1403 @item
1404 both @option{-O3} and @option{-flto} were passed to the compiler
1405 @end itemize
1407 This kind of selector can only be used within @code{dg-final} directives.
1408 Use @code{dg-skip-if}, @code{dg-xfail-if} or @code{dg-xfail-run-if} to
1409 skip whole tests based on options, or to mark them as expected to fail
1410 with certain options.
1412 @item @{ no-opts @var{opt1} @dots{} @var{optn} @}
1413 As for @code{any-opts} above, each of @var{opt1} to @var{optn} is a
1414 space-separated list of option globs.  The selector expression
1415 evaluates to true if, for all of these strings, there is at least
1416 one glob that does not match an option that was passed to the compiler.
1417 It is shorthand for:
1419 @smallexample
1420 @{ ! @{ any-opts @var{opt1} @dots{} @var{optn} @} @}
1421 @end smallexample
1423 For example:
1425 @smallexample
1426 @{ no-opts "-O3 -flto" "-O[2g]" @}
1427 @end smallexample
1429 is true if all of the following are true:
1431 @itemize @bullet
1432 @item
1433 @option{-O2} was not passed to the compiler
1435 @item
1436 @option{-Og} was not passed to the compiler
1438 @item
1439 at least one of @option{-O3} or @option{-flto} was not passed to the compiler
1440 @end itemize
1442 Like @code{any-opts}, this kind of selector can only be used within
1443 @code{dg-final} directives.
1445 @end table
1446 @end itemize
1448 Here are some examples of full target selectors:
1450 @smallexample
1451 @{ target @{ ! "hppa*-*-* ia64*-*-*" @} @}
1452 @{ target @{ powerpc*-*-* && lp64 @} @}
1453 @{ xfail @{ lp64 || vect_no_align @} @}
1454 @{ xfail @{ aarch64*-*-* && @{ any-opts "-O2" @} @} @}
1455 @end smallexample
1457 @node Effective-Target Keywords
1458 @subsection Keywords describing target attributes
1460 Effective-target keywords identify sets of targets that support
1461 particular functionality.  They are used to limit tests to be run only
1462 for particular targets, or to specify that particular sets of targets
1463 are expected to fail some tests.
1465 Effective-target keywords are defined in @file{lib/target-supports.exp} in
1466 the GCC testsuite, with the exception of those that are documented as
1467 being local to a particular test directory.
1469 The @samp{effective target} takes into account all of the compiler options
1470 with which the test will be compiled, including the multilib options.
1471 By convention, keywords ending in @code{_nocache} can also include options
1472 specified for the particular test in an earlier @code{dg-options} or
1473 @code{dg-add-options} directive.
1475 @subsubsection Endianness
1477 @table @code
1478 @item be
1479 Target uses big-endian memory order for multi-byte and multi-word data.
1481 @item le
1482 Target uses little-endian memory order for multi-byte and multi-word data.
1483 @end table
1485 @subsubsection Data type sizes
1487 @table @code
1488 @item ilp32
1489 Target has 32-bit @code{int}, @code{long}, and pointers.
1491 @item lp64
1492 Target has 32-bit @code{int}, 64-bit @code{long} and pointers.
1494 @item llp64
1495 Target has 32-bit @code{int} and @code{long}, 64-bit @code{long long}
1496 and pointers.
1498 @item double64
1499 Target has 64-bit @code{double}.
1501 @item double64plus
1502 Target has @code{double} that is 64 bits or longer.
1504 @item longdouble128
1505 Target has 128-bit @code{long double}.
1507 @item int32plus
1508 Target has @code{int} that is at 32 bits or longer.
1510 @item int16
1511 Target has @code{int} that is 16 bits or shorter.
1513 @item longlong64
1514 Target has 64-bit @code{long long}.
1516 @item long_neq_int
1517 Target has @code{int} and @code{long} with different sizes.
1519 @item short_eq_int
1520 Target has @code{short} and @code{int} with the same size.
1522 @item ptr_eq_short
1523 Target has pointers (@code{void *}) and @code{short} with the same size.
1525 @item int_eq_float
1526 Target has @code{int} and @code{float} with the same size.
1528 @item ptr_eq_long
1529 Target has pointers (@code{void *}) and @code{long} with the same size.
1531 @item large_double
1532 Target supports @code{double} that is longer than @code{float}.
1534 @item large_long_double
1535 Target supports @code{long double} that is longer than @code{double}.
1537 @item ptr32plus
1538 Target has pointers that are 32 bits or longer.
1540 @item size20plus
1541 Target has a 20-bit or larger address space, so supports at least
1542 16-bit array and structure sizes.
1544 @item size24plus
1545 Target has a 24-bit or larger address space, so supports at least
1546 20-bit array and structure sizes.
1548 @item size32plus
1549 Target has a 32-bit or larger address space, so supports at least
1550 24-bit array and structure sizes.
1552 @item 4byte_wchar_t
1553 Target has @code{wchar_t} that is at least 4 bytes.
1555 @item float@var{n}
1556 Target has the @code{_Float@var{n}} type.
1558 @item float@var{n}x
1559 Target has the @code{_Float@var{n}x} type.
1561 @item float@var{n}_runtime
1562 Target has the @code{_Float@var{n}} type, including runtime support
1563 for any options added with @code{dg-add-options}.
1565 @item float@var{n}x_runtime
1566 Target has the @code{_Float@var{n}x} type, including runtime support
1567 for any options added with @code{dg-add-options}.
1569 @item floatn_nx_runtime
1570 Target has runtime support for any options added with
1571 @code{dg-add-options} for any @code{_Float@var{n}} or
1572 @code{_Float@var{n}x} type.
1574 @item inf
1575 Target supports floating point infinite (@code{inf}) for type
1576 @code{double}.
1578 @item inff
1579 Target supports floating point infinite (@code{inf}) for type
1580 @code{float}.
1581 @end table
1582 @subsubsection Fortran-specific attributes
1584 @table @code
1585 @item fortran_integer_16
1586 Target supports Fortran @code{integer} that is 16 bytes or longer.
1588 @item fortran_real_10
1589 Target supports Fortran @code{real} that is 10 bytes or longer.
1591 @item fortran_real_16
1592 Target supports Fortran @code{real} that is 16 bytes or longer.
1594 @item fortran_large_int
1595 Target supports Fortran @code{integer} kinds larger than @code{integer(8)}.
1597 @item fortran_large_real
1598 Target supports Fortran @code{real} kinds larger than @code{real(8)}.
1599 @end table
1601 @subsubsection Vector-specific attributes
1603 @table @code
1604 @item vect_align_stack_vars
1605 The target's ABI allows stack variables to be aligned to the preferred
1606 vector alignment.
1608 @item vect_avg_qi
1609 Target supports both signed and unsigned averaging operations on vectors
1610 of bytes.
1612 @item vect_mulhrs_hi
1613 Target supports both signed and unsigned multiply-high-with-round-and-scale
1614 operations on vectors of half-words.
1616 @item vect_sdiv_pow2_si
1617 Target supports signed division by constant power-of-2 operations
1618 on vectors of 4-byte integers.
1620 @item vect_condition
1621 Target supports vector conditional operations.
1623 @item vect_cond_mixed
1624 Target supports vector conditional operations where comparison operands
1625 have different type from the value operands.
1627 @item vect_double
1628 Target supports hardware vectors of @code{double}.
1630 @item vect_double_cond_arith
1631 Target supports conditional addition, subtraction, multiplication,
1632 division, minimum and maximum on vectors of @code{double}, via the
1633 @code{cond_} optabs.
1635 @item vect_element_align_preferred
1636 The target's preferred vector alignment is the same as the element
1637 alignment.
1639 @item vect_float
1640 Target supports hardware vectors of @code{float} when
1641 @option{-funsafe-math-optimizations} is in effect.
1643 @item vect_float_strict
1644 Target supports hardware vectors of @code{float} when
1645 @option{-funsafe-math-optimizations} is not in effect.
1646 This implies @code{vect_float}.
1648 @item vect_early_break
1649 Target supports vectorization codegen of loops with early breaks.
1650 This requires an implementation of the cbranch optab for vectors.
1652 @item vect_early_break_hw
1653 Target supports hardware vectorization and running of loops with early breaks.
1654 This requires an implementation of the cbranch optab for vectors.
1656 @item vect_int
1657 Target supports hardware vectors of @code{int}.
1659 @item vect_long
1660 Target supports hardware vectors of @code{long}.
1662 @item vect_long_long
1663 Target supports hardware vectors of @code{long long}.
1665 @item vect_check_ptrs
1666 Target supports the @code{check_raw_ptrs} and @code{check_war_ptrs}
1667 optabs on vectors.
1669 @item vect_fully_masked
1670 Target supports fully-masked (also known as fully-predicated) loops,
1671 so that vector loops can handle partial as well as full vectors.
1673 @item vect_masked_load
1674 Target supports vector masked loads.
1676 @item vect_masked_store
1677 Target supports vector masked stores.
1679 @item vect_gather_load_ifn
1680 Target supports vector gather loads using internal functions
1681 (rather than via built-in functions or emulation).
1683 @item vect_scatter_store
1684 Target supports vector scatter stores.
1686 @item vect_aligned_arrays
1687 Target aligns arrays to vector alignment boundary.
1689 @item vect_hw_misalign
1690 Target supports a vector misalign access.
1692 @item vect_no_align
1693 Target does not support a vector alignment mechanism.
1695 @item vect_peeling_profitable
1696 Target might require to peel loops for alignment purposes.
1698 @item vect_no_int_min_max
1699 Target does not support a vector min and max instruction on @code{int}.
1701 @item vect_no_int_add
1702 Target does not support a vector add instruction on @code{int}.
1704 @item vect_no_bitwise
1705 Target does not support vector bitwise instructions.
1707 @item vect_bool_cmp
1708 Target supports comparison of @code{bool} vectors for at least one
1709 vector length.
1711 @item vect_char_add
1712 Target supports addition of @code{char} vectors for at least one
1713 vector length.
1715 @item vect_char_mult
1716 Target supports @code{vector char} multiplication.
1718 @item vect_short_mult
1719 Target supports @code{vector short} multiplication.
1721 @item vect_int_mult
1722 Target supports @code{vector int} multiplication.
1724 @item vect_long_mult
1725 Target supports 64 bit @code{vector long} multiplication.
1727 @item vect_extract_even_odd
1728 Target supports vector even/odd element extraction.
1730 @item vect_extract_even_odd_wide
1731 Target supports vector even/odd element extraction of vectors with elements
1732 @code{SImode} or larger.
1734 @item vect_interleave
1735 Target supports vector interleaving.
1737 @item vect_strided
1738 Target supports vector interleaving and extract even/odd.
1740 @item vect_strided_wide
1741 Target supports vector interleaving and extract even/odd for wide
1742 element types.
1744 @item vect_perm
1745 Target supports vector permutation.
1747 @item vect_perm_byte
1748 Target supports permutation of vectors with 8-bit elements.
1750 @item vect_perm_short
1751 Target supports permutation of vectors with 16-bit elements.
1753 @item vect_perm3_byte
1754 Target supports permutation of vectors with 8-bit elements, and for the
1755 default vector length it is possible to permute:
1756 @example
1757 @{ a0, a1, a2, b0, b1, b2, @dots{} @}
1758 @end example
1760 @example
1761 @{ a0, a0, a0, b0, b0, b0, @dots{} @}
1762 @{ a1, a1, a1, b1, b1, b1, @dots{} @}
1763 @{ a2, a2, a2, b2, b2, b2, @dots{} @}
1764 @end example
1765 using only two-vector permutes, regardless of how long the sequence is.
1767 @item vect_perm3_int
1768 Like @code{vect_perm3_byte}, but for 32-bit elements.
1770 @item vect_perm3_short
1771 Like @code{vect_perm3_byte}, but for 16-bit elements.
1773 @item vect_shift
1774 Target supports a hardware vector shift operation.
1776 @item vect_unaligned_possible
1777 Target prefers vectors to have an alignment greater than element
1778 alignment, but also allows unaligned vector accesses in some
1779 circumstances.
1781 @item vect_variable_length
1782 Target has variable-length vectors.
1784 @item vect64
1785 Target supports vectors of 64 bits.
1787 @item vect32
1788 Target supports vectors of 32 bits.
1790 @item vect_widen_sum_hi_to_si
1791 Target supports a vector widening summation of @code{short} operands
1792 into @code{int} results, or can promote (unpack) from @code{short}
1793 to @code{int}.
1795 @item vect_widen_sum_qi_to_hi
1796 Target supports a vector widening summation of @code{char} operands
1797 into @code{short} results, or can promote (unpack) from @code{char}
1798 to @code{short}.
1800 @item vect_widen_sum_qi_to_si
1801 Target supports a vector widening summation of @code{char} operands
1802 into @code{int} results.
1804 @item vect_widen_mult_qi_to_hi
1805 Target supports a vector widening multiplication of @code{char} operands
1806 into @code{short} results, or can promote (unpack) from @code{char} to
1807 @code{short} and perform non-widening multiplication of @code{short}.
1809 @item vect_widen_mult_hi_to_si
1810 Target supports a vector widening multiplication of @code{short} operands
1811 into @code{int} results, or can promote (unpack) from @code{short} to
1812 @code{int} and perform non-widening multiplication of @code{int}.
1814 @item vect_widen_mult_si_to_di_pattern
1815 Target supports a vector widening multiplication of @code{int} operands
1816 into @code{long} results.
1818 @item vect_sdot_qi
1819 Target supports a vector dot-product of @code{signed char}.
1821 @item vect_udot_qi
1822 Target supports a vector dot-product of @code{unsigned char}.
1824 @item vect_usdot_qi
1825 Target supports a vector dot-product where one operand of the multiply is
1826 @code{signed char} and the other of @code{unsigned char}.
1828 @item vect_sdot_hi
1829 Target supports a vector dot-product of @code{signed short}.
1831 @item vect_udot_hi
1832 Target supports a vector dot-product of @code{unsigned short}.
1834 @item vect_pack_trunc
1835 Target supports a vector demotion (packing) of @code{short} to @code{char}
1836 and from @code{int} to @code{short} using modulo arithmetic.
1838 @item vect_unpack
1839 Target supports a vector promotion (unpacking) of @code{char} to @code{short}
1840 and from @code{char} to @code{int}.
1842 @item vect_intfloat_cvt
1843 Target supports conversion from @code{signed int} to @code{float}.
1845 @item vect_uintfloat_cvt
1846 Target supports conversion from @code{unsigned int} to @code{float}.
1848 @item vect_floatint_cvt
1849 Target supports conversion from @code{float} to @code{signed int}.
1851 @item vect_floatuint_cvt
1852 Target supports conversion from @code{float} to @code{unsigned int}.
1854 @item vect_intdouble_cvt
1855 Target supports conversion from @code{signed int} to @code{double}.
1857 @item vect_doubleint_cvt
1858 Target supports conversion from @code{double} to @code{signed int}.
1860 @item vect_max_reduc
1861 Target supports max reduction for vectors.
1863 @item vect_sizes_16B_8B
1864 Target supports 16- and 8-bytes vectors.
1866 @item vect_sizes_32B_16B
1867 Target supports 32- and 16-bytes vectors.
1869 @item vect_logical_reduc
1870 Target supports AND, IOR and XOR reduction on vectors.
1872 @item vect_fold_extract_last
1873 Target supports the @code{fold_extract_last} optab.
1875 @item vect_len_load_store
1876 Target supports the @code{len_load} and @code{len_store} optabs.
1878 @item vect_partial_vectors_usage_1
1879 Target supports loop vectorization with partial vectors and
1880 @code{vect-partial-vector-usage} is set to 1.
1882 @item vect_partial_vectors_usage_2
1883 Target supports loop vectorization with partial vectors and
1884 @code{vect-partial-vector-usage} is set to 2.
1886 @item vect_partial_vectors
1887 Target supports loop vectorization with partial vectors and
1888 @code{vect-partial-vector-usage} is nonzero.
1890 @item vect_slp_v2qi_store_align
1891 Target supports vectorization of 2-byte char stores with 2-byte aligned
1892 address at plain @option{-O2}.
1894 @item vect_slp_v4qi_store_align
1895 Target supports vectorization of 4-byte char stores with 4-byte aligned
1896 address at plain @option{-O2}.
1898 @item vect_slp_v4qi_store_unalign
1899 Target supports vectorization of 4-byte char stores with unaligned address
1900 at plain @option{-O2}.
1902 @item struct_4char_block_move
1903 Target supports block move for 8-byte aligned 4-byte size struct initialization.
1905 @item vect_slp_v4qi_store_unalign_1
1906 Target supports vectorization of 4-byte char stores with unaligned address
1907 or store them with constant pool at plain @option{-O2}.
1909 @item struct_8char_block_move
1910 Target supports block move for 8-byte aligned 8-byte size struct initialization.
1912 @item vect_slp_v8qi_store_unalign_1
1913 Target supports vectorization of 8-byte char stores with unaligned address
1914 or store them with constant pool at plain @option{-O2}.
1916 @item struct_16char_block_move
1917 Target supports block move for 8-byte aligned 16-byte size struct
1918 initialization.
1920 @item vect_slp_v16qi_store_unalign_1
1921 Target supports vectorization of 16-byte char stores with unaligned address
1922 or store them with constant pool at plain @option{-O2}.
1924 @item vect_slp_v2hi_store_align
1925 Target supports vectorization of 4-byte short stores with 4-byte aligned
1926 addressat plain @option{-O2}.
1928 @item vect_slp_v2hi_store_unalign
1929 Target supports vectorization of 4-byte short stores with unaligned address
1930 at plain @option{-O2}.
1932 @item vect_slp_v4hi_store_unalign
1933 Target supports vectorization of 8-byte short stores with unaligned address
1934 at plain @option{-O2}.
1936 @item vect_slp_v2si_store_align
1937 Target supports vectorization of 8-byte int stores with 8-byte aligned address
1938 at plain @option{-O2}.
1940 @item vect_slp_v4si_store_unalign
1941 Target supports vectorization of 16-byte int stores with unaligned address
1942 at plain @option{-O2}.
1943 @end table
1945 @subsubsection Thread Local Storage attributes
1947 @table @code
1948 @item tls
1949 Target supports thread-local storage.
1951 @item tls_native
1952 Target supports native (rather than emulated) thread-local storage.
1954 @item tls_runtime
1955 Test system supports executing TLS executables.
1956 @end table
1958 @subsubsection Decimal floating point attributes
1960 @table @code
1961 @item dfp
1962 Targets supports compiling decimal floating point extension to C.
1964 @item dfp_nocache
1965 Including the options used to compile this particular test, the
1966 target supports compiling decimal floating point extension to C.
1968 @item dfprt
1969 Test system can execute decimal floating point tests.
1971 @item dfprt_nocache
1972 Including the options used to compile this particular test, the
1973 test system can execute decimal floating point tests.
1975 @item hard_dfp
1976 Target generates decimal floating point instructions with current options.
1978 @item dfp_bid
1979 Target uses the BID format for decimal floating point.
1980 @end table
1982 @subsubsection ARM-specific attributes
1984 @table @code
1985 @item arm32
1986 ARM target generates 32-bit code.
1988 @item arm_little_endian
1989 ARM target that generates little-endian code.
1991 @item arm_eabi
1992 ARM target adheres to the ABI for the ARM Architecture.
1994 @item arm_fp_ok
1995 @anchor{arm_fp_ok}
1996 ARM target defines @code{__ARM_FP} using @code{-mfloat-abi=softfp} or
1997 equivalent options.  Some multilibs may be incompatible with these
1998 options.
2000 @item arm_fp_dp_ok
2001 @anchor{arm_fp_dp_ok}
2002 ARM target defines @code{__ARM_FP} with double-precision support using
2003 @code{-mfloat-abi=softfp} or equivalent options.  Some multilibs may
2004 be incompatible with these options.
2006 @item arm_hf_eabi
2007 ARM target adheres to the VFP and Advanced SIMD Register Arguments
2008 variant of the ABI for the ARM Architecture (as selected with
2009 @code{-mfloat-abi=hard}).
2011 @item arm_softfloat
2012 ARM target uses emulated floating point operations.
2014 @item arm_hard_vfp_ok
2015 ARM target supports @code{-mfpu=vfp -mfloat-abi=hard}.
2016 Some multilibs may be incompatible with these options.
2018 @item arm_iwmmxt_ok
2019 ARM target supports @code{-mcpu=iwmmxt}.
2020 Some multilibs may be incompatible with this option.
2022 @item arm_neon
2023 ARM target supports generating NEON instructions.
2025 @item arm_tune_string_ops_prefer_neon
2026 Test CPU tune supports inlining string operations with NEON instructions.
2028 @item arm_neon_hw
2029 Test system supports executing NEON instructions.
2031 @item arm_neonv2_hw
2032 Test system supports executing NEON v2 instructions.
2034 @item arm_neon_ok
2035 @anchor{arm_neon_ok}
2036 ARM Target supports @code{-mfpu=neon -mfloat-abi=softfp} or compatible
2037 options.  Some multilibs may be incompatible with these options.
2039 @item arm_neon_ok_no_float_abi
2040 @anchor{arm_neon_ok_no_float_abi}
2041 ARM Target supports NEON with @code{-mfpu=neon}, but without any
2042 -mfloat-abi= option.  Some multilibs may be incompatible with this
2043 option.
2045 @item arm_neonv2_ok
2046 @anchor{arm_neonv2_ok}
2047 ARM Target supports @code{-mfpu=neon-vfpv4 -mfloat-abi=softfp} or compatible
2048 options.  Some multilibs may be incompatible with these options.
2050 @item arm_fp16_ok
2051 @anchor{arm_fp16_ok}
2052 Target supports options to generate VFP half-precision floating-point
2053 instructions.  Some multilibs may be incompatible with these
2054 options.  This test is valid for ARM only.
2056 @item arm_fp16_hw
2057 Target supports executing VFP half-precision floating-point
2058 instructions.  This test is valid for ARM only.
2060 @item arm_neon_fp16_ok
2061 @anchor{arm_neon_fp16_ok}
2062 ARM Target supports @code{-mfpu=neon-fp16 -mfloat-abi=softfp} or compatible
2063 options, including @code{-mfp16-format=ieee} if necessary to obtain the
2064 @code{__fp16} type.  Some multilibs may be incompatible with these options.
2066 @item arm_neon_fp16_hw
2067 Test system supports executing Neon half-precision float instructions.
2068 (Implies previous.)
2070 @item arm_fp16_alternative_ok
2071 ARM target supports the ARM FP16 alternative format.  Some multilibs
2072 may be incompatible with the options needed.
2074 @item arm_fp16_none_ok
2075 ARM target supports specifying none as the ARM FP16 format.
2077 @item arm_thumb1_ok
2078 ARM target generates Thumb-1 code for @code{-mthumb}.
2080 @item arm_thumb2_ok
2081 ARM target generates Thumb-2 code for @code{-mthumb}.
2083 @item arm_nothumb
2084 ARM target that is not using Thumb.
2086 @item arm_vfp_ok
2087 ARM target supports @code{-mfpu=vfp -mfloat-abi=softfp}.
2088 Some multilibs may be incompatible with these options.
2090 @item arm_vfp3_ok
2091 @anchor{arm_vfp3_ok}
2092 ARM target supports @code{-mfpu=vfp3 -mfloat-abi=softfp}.
2093 Some multilibs may be incompatible with these options.
2095 @item arm_arch_v8a_hard_ok
2096 @anchor{arm_arch_v8a_hard_ok}
2097 The compiler is targeting @code{arm*-*-*} and can compile and assemble code
2098 using the options @code{-march=armv8-a -mfpu=neon-fp-armv8 -mfloat-abi=hard}.
2099 This is not enough to guarantee that linking works.
2101 @item arm_arch_v8a_hard_multilib
2102 The compiler is targeting @code{arm*-*-*} and can build programs using
2103 the options @code{-march=armv8-a -mfpu=neon-fp-armv8 -mfloat-abi=hard}.
2104 The target can also run the resulting binaries.
2106 @item arm_v8_vfp_ok
2107 ARM target supports @code{-mfpu=fp-armv8 -mfloat-abi=softfp}.
2108 Some multilibs may be incompatible with these options.
2110 @item arm_v8_neon_ok
2111 ARM target supports @code{-mfpu=neon-fp-armv8 -mfloat-abi=softfp}.
2112 Some multilibs may be incompatible with these options.
2114 @item arm_v8_1a_neon_ok
2115 @anchor{arm_v8_1a_neon_ok}
2116 ARM target supports options to generate ARMv8.1-A Adv.SIMD instructions.
2117 Some multilibs may be incompatible with these options.
2119 @item arm_v8_1a_neon_hw
2120 ARM target supports executing ARMv8.1-A Adv.SIMD instructions.  Some
2121 multilibs may be incompatible with the options needed.  Implies
2122 arm_v8_1a_neon_ok.
2124 @item arm_acq_rel
2125 ARM target supports acquire-release instructions.
2127 @item arm_v8_2a_fp16_scalar_ok
2128 @anchor{arm_v8_2a_fp16_scalar_ok}
2129 ARM target supports options to generate instructions for ARMv8.2-A and
2130 scalar instructions from the FP16 extension.  Some multilibs may be
2131 incompatible with these options.
2133 @item arm_v8_2a_fp16_scalar_hw
2134 ARM target supports executing instructions for ARMv8.2-A and scalar
2135 instructions from the FP16 extension.  Some multilibs may be
2136 incompatible with these options.  Implies arm_v8_2a_fp16_neon_ok.
2138 @item arm_v8_2a_fp16_neon_ok
2139 @anchor{arm_v8_2a_fp16_neon_ok}
2140 ARM target supports options to generate instructions from ARMv8.2-A with
2141 the FP16 extension.  Some multilibs may be incompatible with these
2142 options.  Implies arm_v8_2a_fp16_scalar_ok.
2144 @item arm_v8_2a_fp16_neon_hw
2145 ARM target supports executing instructions from ARMv8.2-A with the FP16
2146 extension.  Some multilibs may be incompatible with these options.
2147 Implies arm_v8_2a_fp16_neon_ok and arm_v8_2a_fp16_scalar_hw.
2149 @item arm_v8_2a_dotprod_neon_ok
2150 @anchor{arm_v8_2a_dotprod_neon_ok}
2151 ARM target supports options to generate instructions from ARMv8.2-A with
2152 the Dot Product extension. Some multilibs may be incompatible with these
2153 options.
2155 @item arm_v8_2a_dotprod_neon_hw
2156 ARM target supports executing instructions from ARMv8.2-A with the Dot
2157 Product extension. Some multilibs may be incompatible with these options.
2158 Implies arm_v8_2a_dotprod_neon_ok.
2160 @item arm_v8_2a_i8mm_neon_hw
2161 ARM target supports executing instructions from ARMv8.2-A with the 8-bit
2162 Matrix Multiply extension.  Some multilibs may be incompatible with these
2163 options.  Implies arm_v8_2a_i8mm_ok.
2165 @item arm_fp16fml_neon_ok
2166 @anchor{arm_fp16fml_neon_ok}
2167 ARM target supports extensions to generate the @code{VFMAL} and @code{VFMLS}
2168 half-precision floating-point instructions available from ARMv8.2-A and
2169 onwards.  Some multilibs may be incompatible with these options.
2171 @item arm_v8_2a_bf16_neon_ok
2172 ARM target supports options to generate instructions from ARMv8.2-A with
2173 the BFloat16 extension (bf16). Some multilibs may be incompatible with these
2174 options.
2176 @item arm_v8_2a_i8mm_ok
2177 ARM target supports options to generate instructions from ARMv8.2-A with
2178 the 8-Bit Integer Matrix Multiply extension (i8mm). Some multilibs may be
2179 incompatible with these options.
2181 @item arm_v8_1m_mve_ok
2182 ARM target supports options to generate instructions from ARMv8.1-M with
2183 the M-Profile Vector Extension (MVE). Some multilibs may be incompatible
2184 with these options.
2186 @item arm_v8_1m_mve_fp_ok
2187 ARM target supports options to generate instructions from ARMv8.1-M with
2188 the Half-precision floating-point instructions (HP), Floating-point Extension
2189 (FP) along with M-Profile Vector Extension (MVE). Some multilibs may be
2190 incompatible with these options.
2192 @item arm_mve_hw
2193 Test system supports executing MVE instructions.
2195 @item arm_v8m_main_cde
2196 ARM target supports options to generate instructions from ARMv8-M with
2197 the Custom Datapath Extension (CDE). Some multilibs may be incompatible
2198 with these options.
2200 @item arm_v8m_main_cde_fp
2201 ARM target supports options to generate instructions from ARMv8-M with
2202 the Custom Datapath Extension (CDE) and floating-point (VFP).
2203 Some multilibs may be incompatible with these options.
2205 @item arm_v8_1m_main_cde_mve
2206 Arm target supports options to generate instructions from Armv8.1-M with
2207 the Custom Datapath Extension (CDE) and M-Profile Vector Extension (MVE).
2208 Some multilibs may be incompatible with these options.
2210 @item arm_v8_1m_main_cde_mve_fp
2211 Arm target supports options to generate instructions from Armv8.1-M
2212 with the Custom Datapath Extension (CDE) and M-Profile Vector
2213 Extension (MVE) with floating-point support.  Some multilibs may be
2214 incompatible with these options.
2216 @item arm_pacbti_hw
2217 Test system supports executing Pointer Authentication and Branch Target
2218 Identification instructions.
2220 @item arm_prefer_ldrd_strd
2221 ARM target prefers @code{LDRD} and @code{STRD} instructions over
2222 @code{LDM} and @code{STM} instructions.
2224 @item arm_thumb1_movt_ok
2225 ARM target generates Thumb-1 code for @code{-mthumb} with @code{MOVW}
2226 and @code{MOVT} instructions available.
2228 @item arm_thumb1_cbz_ok
2229 ARM target generates Thumb-1 code for @code{-mthumb} with
2230 @code{CBZ} and @code{CBNZ} instructions available.
2232 @item arm_divmod_simode
2233 ARM target for which divmod transform is disabled, if it supports hardware
2234 div instruction.
2236 @item arm_cmse_ok
2237 ARM target supports ARMv8-M Security Extensions, enabled by the @code{-mcmse}
2238 option.
2240 @item arm_cmse_hw
2241 Test system supports executing CMSE instructions.
2243 @item arm_coproc1_ok
2244 @anchor{arm_coproc1_ok}
2245 ARM target supports the following coprocessor instructions: @code{CDP},
2246 @code{LDC}, @code{STC}, @code{MCR} and @code{MRC}.
2248 @item arm_coproc2_ok
2249 @anchor{arm_coproc2_ok}
2250 ARM target supports all the coprocessor instructions also listed as supported
2251 in @ref{arm_coproc1_ok} in addition to the following: @code{CDP2}, @code{LDC2},
2252 @code{LDC2l}, @code{STC2}, @code{STC2l}, @code{MCR2} and @code{MRC2}.
2254 @item arm_coproc3_ok
2255 @anchor{arm_coproc3_ok}
2256 ARM target supports all the coprocessor instructions also listed as supported
2257 in @ref{arm_coproc2_ok} in addition the following: @code{MCRR} and @code{MRRC}.
2259 @item arm_coproc4_ok
2260 ARM target supports all the coprocessor instructions also listed as supported
2261 in @ref{arm_coproc3_ok} in addition the following: @code{MCRR2} and @code{MRRC2}.
2263 @item arm_simd32_ok
2264 @anchor{arm_simd32_ok}
2265 ARM Target supports options suitable for accessing the SIMD32 intrinsics from
2266 @code{arm_acle.h}.
2267 Some multilibs may be incompatible with these options.
2269 @item arm_sat_ok
2270 @anchor{arm_sat_ok}
2271 ARM Target supports options suitable for accessing the saturation
2272 intrinsics from @code{arm_acle.h}.
2273 Some multilibs may be incompatible with these options.
2275 @item arm_dsp_ok
2276 @anchor{arm_dsp_ok}
2277 ARM Target supports options suitable for accessing the DSP intrinsics
2278 from @code{arm_acle.h}.
2279 Some multilibs may be incompatible with these options.
2281 @item arm_softfp_ok
2282 @anchor{arm_softfp_ok}
2283 ARM target supports the @code{-mfloat-abi=softfp} option.
2285 @item arm_hard_ok
2286 @anchor{arm_hard_ok}
2287 ARM target supports the @code{-mfloat-abi=hard} option.
2289 @item arm_mve
2290 @anchor{arm_mve}
2291 ARM target supports generating MVE instructions.
2293 @item arm_v8_1_lob_ok
2294 @anchor{arm_v8_1_lob_ok}
2295 ARM Target supports executing the Armv8.1-M Mainline Low Overhead Loop
2296 instructions @code{DLS} and @code{LE}.
2297 Some multilibs may be incompatible with these options.
2299 @item arm_thumb2_no_arm_v8_1_lob
2300 ARM target where Thumb-2 is used without options but does not support
2301 executing the Armv8.1-M Mainline Low Overhead Loop instructions
2302 @code{DLS} and @code{LE}.
2304 @item arm_thumb2_ok_no_arm_v8_1_lob
2305 ARM target generates Thumb-2 code for @code{-mthumb} but does not
2306 support executing the Armv8.1-M Mainline Low Overhead Loop
2307 instructions @code{DLS} and @code{LE}.
2309 @item mbranch_protection_ok
2310 ARM target supporting @code{-mbranch-protection=standard}.
2312 @item arm_pacbti_hw
2313 Test system supports for executing non nop pacbti instructions.
2315 @end table
2317 @subsubsection AArch64-specific attributes
2319 @table @code
2320 @item aarch64_asm_<ext>_ok
2321 AArch64 assembler supports the architecture extension @code{ext} via the
2322 @code{.arch_extension} pseudo-op.
2323 @item aarch64_tiny
2324 AArch64 target which generates instruction sequences for tiny memory model.
2325 @item aarch64_small
2326 AArch64 target which generates instruction sequences for small memory model.
2327 @item aarch64_large
2328 AArch64 target which generates instruction sequences for large memory model.
2329 @item aarch64_little_endian
2330 AArch64 target which generates instruction sequences for little endian.
2331 @item aarch64_big_endian
2332 AArch64 target which generates instruction sequences for big endian.
2333 @item aarch64_small_fpic
2334 Binutils installed on test system supports relocation types required by -fpic
2335 for AArch64 small memory model.
2336 @item aarch64_sme
2337 AArch64 target that generates instructions for SME.
2338 @item aarch64_sme2
2339 AArch64 target that generates instructions for SME2.
2340 @item aarch64_sve_hw
2341 AArch64 target that is able to generate and execute SVE code (regardless of
2342 whether it does so by default).
2343 @item aarch64_sve128_hw
2344 @itemx aarch64_sve256_hw
2345 @itemx aarch64_sve512_hw
2346 @itemx aarch64_sve1024_hw
2347 @itemx aarch64_sve2048_hw
2348 Like @code{aarch64_sve_hw}, but also test for an exact hardware vector length.
2350 @item aarch64_fjcvtzs_hw
2351 AArch64 target that is able to generate and execute armv8.3-a FJCVTZS
2352 instruction.
2353 @end table
2355 @subsubsection LoongArch specific attributes
2357 @table @code
2358 @item loongarch_sx
2359 LoongArch target that generates instructions for SX.
2361 @item loongarch_asx
2362 LoongArch target that generates instructions for ASX.
2364 @item loongarch_sx_hw
2365 LoongArch target that is able to generate and execute SX code.
2367 @item loongarch_asx_hw
2368 LoongArch target that is able to generate and execute ASX code.
2370 @item loongarch_call36_support
2371 LoongArch binutils supports call36 relocation.
2373 @end table
2375 @subsubsection MIPS-specific attributes
2377 @table @code
2378 @item mips64
2379 MIPS target supports 64-bit instructions.
2381 @item nomips16
2382 MIPS target does not produce MIPS16 code.
2384 @item mips16_attribute
2385 MIPS target can generate MIPS16 code.
2387 @item mips_loongson
2388 MIPS target is a Loongson-2E or -2F target using an ABI that supports
2389 the Loongson vector modes.
2391 @item mips_msa
2392 MIPS target supports @code{-mmsa}, MIPS SIMD Architecture (MSA).
2394 @item mips_newabi_large_long_double
2395 MIPS target supports @code{long double} larger than @code{double}
2396 when using the new ABI.
2398 @item mpaired_single
2399 MIPS target supports @code{-mpaired-single}.
2400 @end table
2402 @subsubsection MSP430-specific attributes
2404 @table @code
2405 @item msp430_small
2406 MSP430 target has the small memory model enabled (@code{-msmall}).
2408 @item msp430_large
2409 MSP430 target has the large memory model enabled (@code{-mlarge}).
2410 @end table
2412 @subsubsection PowerPC-specific attributes
2414 @table @code
2416 @item dfp_hw
2417 PowerPC target supports executing hardware DFP instructions.
2419 @item p8vector_hw
2420 PowerPC target supports executing VSX instructions (ISA 2.07).
2422 @item powerpc64
2423 Test system supports executing 64-bit instructions.
2425 @item powerpc_altivec
2426 PowerPC target supports AltiVec.
2428 @item powerpc_altivec_ok
2429 PowerPC target supports @code{-maltivec}.
2431 @item powerpc_eabi_ok
2432 PowerPC target supports @code{-meabi}.
2434 @item powerpc_elfv2
2435 PowerPC target supports @code{-mabi=elfv2}.
2437 @item powerpc_fprs
2438 PowerPC target supports floating-point registers.
2440 @item powerpc_hard_double
2441 PowerPC target supports hardware double-precision floating-point.
2443 @item powerpc_htm_ok
2444 PowerPC target supports @code{-mhtm}
2446 @item powerpc_popcntb_ok
2447 PowerPC target supports the @code{popcntb} instruction, indicating
2448 that this target supports @code{-mcpu=power5}.
2450 @item powerpc_ppu_ok
2451 PowerPC target supports @code{-mcpu=cell}.
2453 @item powerpc_spe
2454 PowerPC target supports PowerPC SPE.
2456 @item powerpc_spe_nocache
2457 Including the options used to compile this particular test, the
2458 PowerPC target supports PowerPC SPE.
2460 @item powerpc_spu
2461 PowerPC target supports PowerPC SPU.
2463 @item powerpc_vsx_ok
2464 PowerPC target supports @code{-mvsx}.
2466 @item powerpc_405_nocache
2467 Including the options used to compile this particular test, the
2468 PowerPC target supports PowerPC 405.
2470 @item ppc_recip_hw
2471 PowerPC target supports executing reciprocal estimate instructions.
2473 @item vmx_hw
2474 PowerPC target supports executing AltiVec instructions.
2476 @item vsx_hw
2477 PowerPC target supports executing VSX instructions (ISA 2.06).
2479 @item has_arch_pwr5
2480 PowerPC target pre-defines macro _ARCH_PWR5 which means the @code{-mcpu}
2481 setting is Power5 or later.
2483 @item has_arch_pwr6
2484 PowerPC target pre-defines macro _ARCH_PWR6 which means the @code{-mcpu}
2485 setting is Power6 or later.
2487 @item has_arch_pwr7
2488 PowerPC target pre-defines macro _ARCH_PWR7 which means the @code{-mcpu}
2489 setting is Power7 or later.
2491 @item has_arch_pwr8
2492 PowerPC target pre-defines macro _ARCH_PWR8 which means the @code{-mcpu}
2493 setting is Power8 or later.
2495 @item has_arch_pwr9
2496 PowerPC target pre-defines macro _ARCH_PWR9 which means the @code{-mcpu}
2497 setting is Power9 or later.
2498 @end table
2500 @subsubsection RISC-V specific attributes
2502 @table @code
2504 @item rv32
2505 Test system has an integer register width of 32 bits.
2507 @item rv64
2508 Test system has an integer register width of 64 bits.
2510 @item cv_bi
2511 Test system has support for the CORE-V BI extension.
2513 @end table
2515 @subsubsection CORE-V specific attributes
2517 @table @code
2519 @item cv_mac
2520 Test system has support for the CORE-V MAC extension.
2522 @item cv_alu
2523 Test system has support for the CORE-V ALU extension.
2525 @item cv_elw
2526 Test system has support for the CORE-V ELW extension.
2528 @item cv_simd
2529 Test system has support for the CORE-V SIMD extension.
2531 @end table
2533 @subsubsection Other hardware attributes
2535 @c Please keep this table sorted alphabetically.
2536 @table @code
2537 @item autoincdec
2538 Target supports autoincrement/decrement addressing.
2540 @item avx
2541 Target supports compiling @code{avx} instructions.
2543 @item avx_runtime
2544 Target supports the execution of @code{avx} instructions.
2546 @item avx10.1
2547 Target supports the execution of @code{avx10.1} instructions.
2549 @item avx10.1-256
2550 Target supports the execution of @code{avx10.1} instructions.
2552 @item avx10.1-512
2553 Target supports the execution of @code{avx10.1-512} instructions.
2555 @item avx2
2556 Target supports compiling @code{avx2} instructions.
2558 @item avx2_runtime
2559 Target supports the execution of @code{avx2} instructions.
2561 @item avxvnni
2562 Target supports the execution of @code{avxvnni} instructions.
2564 @item avx512f
2565 Target supports compiling @code{avx512f} instructions.
2567 @item avx512f_runtime
2568 Target supports the execution of @code{avx512f} instructions.
2570 @item avx512vp2intersect
2571 Target supports the execution of @code{avx512vp2intersect} instructions.
2573 @item avxifma
2574 Target supports the execution of @code{avxifma} instructions.
2576 @item avxneconvert
2577 Target supports the execution of @code{avxneconvert} instructions.
2579 @item avxvnniint8
2580 Target supports the execution of @code{avxvnniint8} instructions.
2582 @item avxvnniint16
2583 Target supports the execution of @code{avxvnniint16} instructions.
2585 @item amx_tile
2586 Target supports the execution of @code{amx-tile} instructions.
2588 @item amx_int8
2589 Target supports the execution of @code{amx-int8} instructions.
2591 @item amx_bf16
2592 Target supports the execution of @code{amx-bf16} instructions.
2594 @item amx_complex
2595 Target supports the execution of @code{amx-complex} instructions.
2597 @item amx_fp16
2598 Target supports the execution of @code{amx-fp16} instructions.
2600 @item cell_hw
2601 Test system can execute AltiVec and Cell PPU instructions.
2603 @item clz
2604 Target supports a clz optab on int.
2606 @item clzl
2607 Target supports a clz optab on long.
2609 @item clzll
2610 Target supports a clz optab on long long.
2612 @item ctz
2613 Target supports a ctz optab on int.
2615 @item ctzl
2616 Target supports a ctz optab on long.
2618 @item ctzll
2619 Target supports a ctz optab on long long.
2621 @item cmpccxadd
2622 Target supports the execution of @code{cmpccxadd} instructions.
2624 @item coldfire_fpu
2625 Target uses a ColdFire FPU.
2627 @item divmod
2628 Target supporting hardware divmod insn or divmod libcall.
2630 @item divmod_simode
2631 Target supporting hardware divmod insn or divmod libcall for SImode.
2633 @item hard_float
2634 Target supports FPU instructions.
2636 @item non_strict_align
2637 Target does not require strict alignment.
2639 @item opt_mstrict_align
2640 Target supports @option{-mstrict-align} and @option{-mno-strict-align}.
2642 @item pie_copyreloc
2643 The x86-64 target linker supports PIE with copy reloc.
2645 @item popcount
2646 Target supports a popcount optab on int.
2648 @item popcountl
2649 Target supports a popcount optab on long.
2651 @item popcountll
2652 Target supports a popcount optab on long long.
2654 @item prefetchi
2655 Target supports the execution of @code{prefetchi} instructions.
2657 @item raoint
2658 Target supports the execution of @code{raoint} instructions.
2660 @item rdrand
2661 Target supports x86 @code{rdrand} instruction.
2663 @item sha512
2664 Target supports the execution of @code{sha512} instructions.
2666 @item sm3
2667 Target supports the execution of @code{sm3} instructions.
2669 @item sm4
2670 Target supports the execution of @code{sm4} instructions.
2672 @item sqrt_insn
2673 Target has a square root instruction that the compiler can generate.
2675 @item sse
2676 Target supports compiling @code{sse} instructions.
2678 @item sse_runtime
2679 Target supports the execution of @code{sse} instructions.
2681 @item sse2
2682 Target supports compiling @code{sse2} instructions.
2684 @item sse2_runtime
2685 Target supports the execution of @code{sse2} instructions.
2687 @item sync_char_short
2688 Target supports atomic operations on @code{char} and @code{short}.
2690 @item sync_int_long
2691 Target supports atomic operations on @code{int} and @code{long}.
2693 @item ultrasparc_hw
2694 Test environment appears to run executables on a simulator that
2695 accepts only @code{EM_SPARC} executables and chokes on @code{EM_SPARC32PLUS}
2696 or @code{EM_SPARCV9} executables.
2698 @item user_msr
2699 Target supports the execution of @code{user_msr} instructions.
2701 @item vect_cmdline_needed
2702 Target requires a command line argument to enable a SIMD instruction set.
2704 @item xorsign
2705 Target supports the xorsign optab expansion.
2707 @item ifn_copysign
2708 Target supports the copysign optab expansion of float and double for
2709 both scalar and vector modes.
2711 @end table
2713 @subsubsection Environment attributes
2715 @table @code
2716 @item c
2717 The language for the compiler under test is C.
2719 @item c++
2720 The language for the compiler under test is C++.
2722 @item c99_runtime
2723 Target provides a full C99 runtime.
2725 @item cfi
2726 Target supports DWARF CFI directives.
2728 @item correct_iso_cpp_string_wchar_protos
2729 Target @code{string.h} and @code{wchar.h} headers provide C++ required
2730 overloads for @code{strchr} etc. functions.
2732 @item d_runtime
2733 Target provides the D runtime.
2735 @item d_runtime_has_std_library
2736 Target provides the D standard library (Phobos).
2738 @item dummy_wcsftime
2739 Target uses a dummy @code{wcsftime} function that always returns zero.
2741 @item fd_truncate
2742 Target can truncate a file from a file descriptor, as used by
2743 @file{libgfortran/io/unix.c:fd_truncate}; i.e.@: @code{ftruncate} or
2744 @code{chsize}.
2746 @item fenv
2747 Target provides @file{fenv.h} include file.
2749 @item fenv_exceptions
2750 Target supports @file{fenv.h} with all the standard IEEE exceptions
2751 and floating-point exceptions are raised by arithmetic operations.
2753 @item fenv_exceptions_dfp
2754 Target supports @file{fenv.h} with all the standard IEEE exceptions
2755 and floating-point exceptions are raised by arithmetic operations for
2756 decimal floating point.
2758 @item fileio
2759 Target offers such file I/O library functions as @code{fopen},
2760 @code{fclose}, @code{tmpnam}, and @code{remove}.  This is a link-time
2761 requirement for the presence of the functions in the library; even if
2762 they fail at runtime, the requirement is still regarded as satisfied.
2764 @item freestanding
2765 Target is @samp{freestanding} as defined in section 4 of the C99 standard.
2766 Effectively, it is a target which supports no extra headers or libraries
2767 other than what is considered essential.
2769 @item gettimeofday
2770 Target supports @code{gettimeofday}.
2772 @item init_priority
2773 Target supports constructors with initialization priority arguments.
2775 @item inttypes_types
2776 Target has the basic signed and unsigned types in @code{inttypes.h}.
2777 This is for tests that GCC's notions of these types agree with those
2778 in the header, as some systems have only @code{inttypes.h}.
2780 @item lax_strtofp
2781 Target might have errors of a few ULP in string to floating-point
2782 conversion functions and overflow is not always detected correctly by
2783 those functions.
2785 @item mempcpy
2786 Target provides @code{mempcpy} function.
2788 @item mmap
2789 Target supports @code{mmap}.
2791 @item newlib
2792 Target supports Newlib.
2794 @item newlib_nano_io
2795 GCC was configured with @code{--enable-newlib-nano-formatted-io}, which reduces
2796 the code size of Newlib formatted I/O functions.
2798 @item posix_memalign
2799 Target supports @code{posix_memalign}.
2801 @item pow10
2802 Target provides @code{pow10} function.
2804 @item pthread
2805 Target can compile using @code{pthread.h} with no errors or warnings.
2807 @item pthread_h
2808 Target has @code{pthread.h}.
2810 @item sockets
2811 Target can compile using @code{sys/socket.h} with no errors or warnings.
2813 @item run_expensive_tests
2814 Expensive testcases (usually those that consume excessive amounts of CPU
2815 time) should be run on this target.  This can be enabled by setting the
2816 @env{GCC_TEST_RUN_EXPENSIVE} environment variable to a non-empty string.
2818 @item simulator
2819 Test system runs executables on a simulator (i.e.@: slowly) rather than
2820 hardware (i.e.@: fast).
2822 @item signal
2823 Target has @code{signal.h}.
2825 @item stabs
2826 Target supports the stabs debugging format.
2828 @item stdint_types
2829 Target has the basic signed and unsigned C types in @code{stdint.h}.
2830 This will be obsolete when GCC ensures a working @code{stdint.h} for
2831 all targets.
2833 @item stdint_types_mbig_endian
2834 Target accepts the option @option{-mbig-endian} and @code{stdint.h}
2835 can be included without error when @option{-mbig-endian} is passed.
2837 @item stpcpy
2838 Target provides @code{stpcpy} function.
2840 @item strndup
2841 Target provides @code{strndup} function.
2843 @item sysconf
2844 Target supports @code{sysconf}.
2846 @item trampolines
2847 Target supports trampolines.
2849 @item two_plus_gigs
2850 Target supports linking programs with 2+GiB of data.
2852 @item uclibc
2853 Target supports uClibc.
2855 @item unwrapped
2856 Target does not use a status wrapper.
2858 @item vxworks_kernel
2859 Target is a VxWorks kernel.
2861 @item vxworks_rtp
2862 Target is a VxWorks RTP.
2864 @item wchar
2865 Target supports wide characters.
2867 @item weak_undefined
2868 Target supports weak undefined symbols
2869 @end table
2871 @subsubsection Other attributes
2873 @table @code
2874 @item R_flag_in_section
2875 Target supports the 'R' flag in .section directive in assembly inputs.
2877 @item asm_goto_with_outputs
2878 Target supports 'asm goto' with outputs.
2880 @item automatic_stack_alignment
2881 Target supports automatic stack alignment.
2883 @item branch_cost
2884 Target supports @option{-branch-cost=N}.
2886 @item const_volatile_readonly_section
2887 Target places const volatile variables in readonly sections.
2889 @item cxa_atexit
2890 Target uses @code{__cxa_atexit}.
2892 @item default_packed
2893 @anchor{default_packed}
2894 Target has packed layout of structure members by default.
2896 @item exceptions
2897 Target supports exceptions.
2899 @item exceptions_enabled
2900 Target supports exceptions and they are enabled in the current
2901 testing configuration.
2903 @item fgraphite
2904 Target supports Graphite optimizations.
2906 @item fixed_point
2907 Target supports fixed-point extension to C.
2909 @item bitint
2910 Target supports _BitInt(N).
2912 @item bitint128
2913 Target supports _BitInt(128).
2915 @item bitint575
2916 Target supports _BitInt(575).
2918 @item bitint65535
2919 Target supports _BitInt(65535).
2921 @item fopenacc
2922 Target supports OpenACC via @option{-fopenacc}.
2924 @item fopenmp
2925 Target supports OpenMP via @option{-fopenmp}.
2927 @item fpic
2928 Target supports @option{-fpic} and @option{-fPIC}.
2930 @item freorder
2931 Target supports @option{-freorder-blocks-and-partition}.
2933 @item fstack_protector
2934 Target supports @option{-fstack-protector}.
2936 @item gas
2937 Target uses GNU @command{as}.
2939 @item gc_sections
2940 Target supports @option{--gc-sections}.
2942 @item gld
2943 Target uses GNU @command{ld}.
2945 @item keeps_null_pointer_checks
2946 Target keeps null pointer checks, either due to the use of
2947 @option{-fno-delete-null-pointer-checks} or hardwired into the target.
2949 @item llvm_binutils
2950 Target is using an LLVM assembler and/or linker, instead of GNU Binutils.
2952 @item lra
2953 Target supports local register allocator (LRA).
2954 This must not be called (results in @code{ERROR}) for targets that
2955 don't do register allocation, and therefore neither use nor don't use
2956 LRA.
2958 @item lto
2959 Compiler has been configured to support link-time optimization (LTO).
2961 @item lto_incremental
2962 Compiler and linker support link-time optimization relocatable linking
2963 with @option{-r} and @option{-flto} options.
2965 @item thread_fence
2966 Target implements @code{__atomic_thread_fence} without relying on
2967 non-implemented @code{__sync_synchronize()}.
2969 @item naked_functions
2970 Target supports the @code{naked} function attribute.
2972 @item named_sections
2973 Target supports named sections.
2975 @item natural_alignment_32
2976 Target uses natural alignment (aligned to type size) for types of
2977 32 bits or less.
2979 @item tail_call
2980 Target supports tail-call optimizations.
2982 @item target_natural_alignment_64
2983 Target uses natural alignment (aligned to type size) for types of
2984 64 bits or less.
2986 @item no_alignment_constraints
2987 Target defines __BIGGEST_ALIGNMENT__=1.  Hence target imposes
2988 no alignment constraints.  This is similar, but not necessarily
2989 the same as @ref{default_packed}.  Although @code{BIGGEST_FIELD_ALIGNMENT}
2990 defaults to @code{BIGGEST_ALIGNMENT} for most targets, it is possible
2991 for a target to set those two with different values and have different
2992 alignment constraints for aggregate and non-aggregate types.
2994 @item noinit
2995 Target supports the @code{noinit} variable attribute.
2997 @item nonpic
2998 Target does not generate PIC by default.
3000 @item o_flag_in_section
3001 Target supports the 'o' flag in .section directive in assembly inputs.
3003 @item offload_gcn
3004 Target has been configured for OpenACC/OpenMP offloading on AMD GCN.
3006 @item persistent
3007 Target supports the @code{persistent} variable attribute.
3009 @item pie_enabled
3010 Target generates PIE by default.
3012 @item pcc_bitfield_type_matters
3013 Target defines @code{PCC_BITFIELD_TYPE_MATTERS}.
3015 @item pe_aligned_commons
3016 Target supports @option{-mpe-aligned-commons}.
3018 @item pie
3019 Target supports @option{-pie}, @option{-fpie} and @option{-fPIE}.
3021 @item linker_plugin
3022 Target supports the linker plugin.
3024 @item rdynamic
3025 Target supports @option{-rdynamic}.
3027 @item scalar_all_fma
3028 Target supports all four fused multiply-add optabs for both @code{float}
3029 and @code{double}.  These optabs are: @code{fma_optab}, @code{fms_optab},
3030 @code{fnma_optab} and @code{fnms_optab}.
3032 @item section_anchors
3033 Target supports section anchors.
3035 @item short_enums
3036 Target defaults to short enums.
3038 @item stack_size
3039 @anchor{stack_size_et}
3040 Target has limited stack size.  The stack size limit can be obtained using the
3041 STACK_SIZE macro defined by @ref{stack_size_ao,,@code{dg-add-options} feature
3042 @code{stack_size}}.
3044 Note that for certain targets, stack size limits are relevant for
3045 execution only, and therefore considered only if @code{dg-do run} is
3046 in effect, otherwise unlimited.
3048 @item static
3049 Target supports @option{-static}.
3051 @item static_libgfortran
3052 Target supports statically linking @samp{libgfortran}.
3054 @item string_merging
3055 Target supports merging string constants at link time.
3057 @item strub
3058 Target supports attribute @code{strub} for stack scrubbing.
3060 @item ucn
3061 Target supports compiling and assembling UCN.
3063 @item ucn_nocache
3064 Including the options used to compile this particular test, the
3065 target supports compiling and assembling UCN.
3067 @item unaligned_stack
3068 Target does not guarantee that its @code{STACK_BOUNDARY} is greater than
3069 or equal to the required vector alignment.
3071 @item vector_alignment_reachable
3072 Vector alignment is reachable for types of 32 bits or less.
3074 @item vector_alignment_reachable_for_64bit
3075 Vector alignment is reachable for types of 64 bits or less.
3077 @item vma_equals_lma
3078 Target generates executable with VMA equal to LMA for .data section.
3080 @item wchar_t_char16_t_compatible
3081 Target supports @code{wchar_t} that is compatible with @code{char16_t}.
3083 @item wchar_t_char32_t_compatible
3084 Target supports @code{wchar_t} that is compatible with @code{char32_t}.
3086 @item comdat_group
3087 Target uses comdat groups.
3089 @item indirect_calls
3090 Target supports indirect calls, i.e. calls where the target is not
3091 constant.
3093 @item lgccjit
3094 Target supports -lgccjit, i.e. libgccjit.so can be linked into jit tests.
3096 @item __OPTIMIZE__
3097 Optimizations are enabled (@code{__OPTIMIZE__}) per the current
3098 compiler flags.
3099 @end table
3101 @subsubsection Local to tests in @code{gcc.target/i386}
3103 @table @code
3104 @item 3dnow
3105 Target supports compiling @code{3dnow} instructions.
3107 @item aes
3108 Target supports compiling @code{aes} instructions.
3110 @item fma4
3111 Target supports compiling @code{fma4} instructions.
3113 @item mfentry
3114 Target supports the @code{-mfentry} option that alters the
3115 position of profiling calls such that they precede the prologue.
3117 @item ms_hook_prologue
3118 Target supports attribute @code{ms_hook_prologue}.
3120 @item pclmul
3121 Target supports compiling @code{pclmul} instructions.
3123 @item sse3
3124 Target supports compiling @code{sse3} instructions.
3126 @item sse4
3127 Target supports compiling @code{sse4} instructions.
3129 @item sse4a
3130 Target supports compiling @code{sse4a} instructions.
3132 @item ssse3
3133 Target supports compiling @code{ssse3} instructions.
3135 @item vaes
3136 Target supports compiling @code{vaes} instructions.
3138 @item vpclmul
3139 Target supports compiling @code{vpclmul} instructions.
3141 @item xop
3142 Target supports compiling @code{xop} instructions.
3143 @end table
3145 @subsubsection Local to tests in @code{gcc.test-framework}
3147 @table @code
3148 @item no
3149 Always returns 0.
3151 @item yes
3152 Always returns 1.
3153 @end table
3155 @node Add Options
3156 @subsection Features for @code{dg-add-options}
3158 The supported values of @var{feature} for directive @code{dg-add-options}
3159 are:
3161 @table @code
3162 @item arm_fp
3163 @code{__ARM_FP} definition.  Only ARM targets support this feature, and only then
3164 in certain modes; see the @ref{arm_fp_ok,,arm_fp_ok effective target
3165 keyword}.
3167 @item arm_fp_dp
3168 @code{__ARM_FP} definition with double-precision support.  Only ARM
3169 targets support this feature, and only then in certain modes; see the
3170 @ref{arm_fp_dp_ok,,arm_fp_dp_ok effective target keyword}.
3172 @item arm_neon
3173 NEON support.  Only ARM targets support this feature, and only then
3174 in certain modes; see the @ref{arm_neon_ok,,arm_neon_ok effective target
3175 keyword}.
3177 @item arm_fp16
3178 VFP half-precision floating point support.  This does not select the
3179 FP16 format; for that, use @ref{arm_fp16_ieee,,arm_fp16_ieee} or
3180 @ref{arm_fp16_alternative,,arm_fp16_alternative} instead.  This
3181 feature is only supported by ARM targets and then only in certain
3182 modes; see the @ref{arm_fp16_ok,,arm_fp16_ok effective target
3183 keyword}.
3185 @item arm_fp16_ieee
3186 @anchor{arm_fp16_ieee}
3187 ARM IEEE 754-2008 format VFP half-precision floating point support.
3188 This feature is only supported by ARM targets and then only in certain
3189 modes; see the @ref{arm_fp16_ok,,arm_fp16_ok effective target
3190 keyword}.
3192 @item arm_fp16_alternative
3193 @anchor{arm_fp16_alternative}
3194 ARM Alternative format VFP half-precision floating point support.
3195 This feature is only supported by ARM targets and then only in certain
3196 modes; see the @ref{arm_fp16_ok,,arm_fp16_ok effective target
3197 keyword}.
3199 @item arm_neon_fp16
3200 NEON and half-precision floating point support.  Only ARM targets
3201 support this feature, and only then in certain modes; see
3202 the @ref{arm_neon_fp16_ok,,arm_neon_fp16_ok effective target keyword}.
3204 @item arm_vfp3
3205 arm vfp3 floating point support; see
3206 the @ref{arm_vfp3_ok,,arm_vfp3_ok effective target keyword}.
3208 @item arm_arch_v8a_hard
3209 Add options for ARMv8-A and the hard-float variant of the AAPCS,
3210 if this is supported by the compiler; see the
3211 @ref{arm_arch_v8a_hard_ok,,arm_arch_v8a_hard_ok} effective target keyword.
3213 @item arm_v8_1a_neon
3214 Add options for ARMv8.1-A with Adv.SIMD support, if this is supported
3215 by the target; see the @ref{arm_v8_1a_neon_ok,,arm_v8_1a_neon_ok}
3216 effective target keyword.
3218 @item arm_v8_2a_fp16_scalar
3219 Add options for ARMv8.2-A with scalar FP16 support, if this is
3220 supported by the target; see the
3221 @ref{arm_v8_2a_fp16_scalar_ok,,arm_v8_2a_fp16_scalar_ok} effective
3222 target keyword.
3224 @item arm_v8_2a_fp16_neon
3225 Add options for ARMv8.2-A with Adv.SIMD FP16 support, if this is
3226 supported by the target; see the
3227 @ref{arm_v8_2a_fp16_neon_ok,,arm_v8_2a_fp16_neon_ok} effective target
3228 keyword.
3230 @item arm_v8_2a_dotprod_neon
3231 Add options for ARMv8.2-A with Adv.SIMD Dot Product support, if this is
3232 supported by the target; see the
3233 @ref{arm_v8_2a_dotprod_neon_ok} effective target keyword.
3235 @item arm_fp16fml_neon
3236 Add options to enable generation of the @code{VFMAL} and @code{VFMSL}
3237 instructions, if this is supported by the target; see the
3238 @ref{arm_fp16fml_neon_ok} effective target keyword.
3240 @item arm_dsp
3241 Add options for ARM DSP intrinsics support, if this is supported by
3242 the target; see the @ref{arm_dsp_ok,,arm_dsp_ok effective target
3243 keyword}.
3245 @item bind_pic_locally
3246 Add the target-specific flags needed to enable functions to bind
3247 locally when using pic/PIC passes in the testsuite.
3249 @item float@var{n}
3250 Add the target-specific flags needed to use the @code{_Float@var{n}} type.
3252 @item float@var{n}x
3253 Add the target-specific flags needed to use the @code{_Float@var{n}x} type.
3255 @item ieee
3256 Add the target-specific flags needed to enable full IEEE
3257 compliance mode.
3259 @item mips16_attribute
3260 @code{mips16} function attributes.
3261 Only MIPS targets support this feature, and only then in certain modes.
3263 @item stack_size
3264 @anchor{stack_size_ao}
3265 Add the flags needed to define macro STACK_SIZE and set it to the stack size
3266 limit associated with the @ref{stack_size_et,,@code{stack_size} effective
3267 target}.
3269 @item sqrt_insn
3270 Add the target-specific flags needed to enable hardware square root
3271 instructions, if any.
3273 @item tls
3274 Add the target-specific flags needed to use thread-local storage.
3276 @item vect_early_break
3277 Add the target-specific flags needed to enable early break vectorization for
3278 a target, if any.  This requires the target to have an implementation of the
3279 @code{cbranch} optab.
3281 @item weak_undefined
3282 Add the flags needed to enable support for weak undefined symbols.
3283 @end table
3285 @node Require Support
3286 @subsection Variants of @code{dg-require-@var{support}}
3288 A few of the @code{dg-require} directives take arguments.
3290 @table @code
3291 @item dg-require-iconv @var{codeset}
3292 Skip the test if the target does not support iconv.  @var{codeset} is
3293 the codeset to convert to.
3295 @item dg-require-profiling @var{profopt}
3296 Skip the test if the target does not support profiling with option
3297 @var{profopt}.
3299 @item dg-require-stack-check @var{check}
3300 Skip the test if the target does not support the @code{-fstack-check}
3301 option.  If @var{check} is @code{""}, support for @code{-fstack-check}
3302 is checked, for @code{-fstack-check=("@var{check}")} otherwise.
3304 @item dg-require-stack-size @var{size}
3305 Skip the test if the target does not support a stack size of @var{size}.
3307 @item dg-require-visibility @var{vis}
3308 Skip the test if the target does not support the @code{visibility} attribute.
3309 If @var{vis} is @code{""}, support for @code{visibility("hidden")} is
3310 checked, for @code{visibility("@var{vis}")} otherwise.
3311 @end table
3313 The original @code{dg-require} directives were defined before there
3314 was support for effective-target keywords.  The directives that do not
3315 take arguments could be replaced with effective-target keywords.
3317 @table @code
3318 @item dg-require-alias ""
3319 Skip the test if the target does not support the @samp{alias} attribute.
3321 @item dg-require-ascii-locale ""
3322 Skip the test if the host does not support an ASCII locale.
3324 @item dg-require-compat-dfp ""
3325 Skip this test unless both compilers in a @file{compat} testsuite
3326 support decimal floating point.
3328 @item dg-require-cxa-atexit ""
3329 Skip the test if the target does not support @code{__cxa_atexit}.
3330 This is equivalent to @code{dg-require-effective-target cxa_atexit}.
3332 @item dg-require-dll ""
3333 Skip the test if the target does not support DLL attributes.
3335 @item dg-require-dot ""
3336 Skip the test if the host does not have @command{dot}.
3338 @item dg-require-fork ""
3339 Skip the test if the target does not support @code{fork}.
3341 @item dg-require-gc-sections ""
3342 Skip the test if the target's linker does not support the
3343 @code{--gc-sections} flags.
3344 This is equivalent to @code{dg-require-effective-target gc-sections}.
3346 @item dg-require-host-local ""
3347 Skip the test if the host is remote, rather than the same as the build
3348 system.  Some tests are incompatible with DejaGnu's handling of remote
3349 hosts, which involves copying the source file to the host and compiling
3350 it with a relative path and "@code{-o a.out}".
3352 @item dg-require-linker-plugin ""
3353 Skip the test is the target does not support the linker plugin.
3354 This is equivalent to @code{dg-require-effective-target linker_plugin}.
3356 @item dg-require-mkfifo ""
3357 Skip the test if the target does not support @code{mkfifo}.
3359 @item dg-require-named-sections ""
3360 Skip the test is the target does not support named sections.
3361 This is equivalent to @code{dg-require-effective-target named_sections}.
3363 @item dg-require-weak ""
3364 Skip the test if the target does not support weak symbols.
3366 @item dg-require-weak-override ""
3367 Skip the test if the target does not support overriding weak symbols.
3368 @end table
3370 @node Final Actions
3371 @subsection Commands for use in @code{dg-final}
3373 The GCC testsuite defines the following directives to be used within
3374 @code{dg-final}.
3376 @subsubsection Scan a particular file
3378 @table @code
3379 @item scan-file @var{filename} @var{regexp} [@{ target/xfail @var{selector} @}]
3380 Passes if @var{regexp} matches text in @var{filename}.
3381 @item scan-file-not @var{filename} @var{regexp} [@{ target/xfail @var{selector} @}]
3382 Passes if @var{regexp} does not match text in @var{filename}.
3383 @item scan-module @var{module} @var{regexp} [@{ target/xfail @var{selector} @}]
3384 Passes if @var{regexp} matches in Fortran module @var{module}.
3385 @item dg-check-dot @var{filename}
3386 Passes if @var{filename} is a valid @file{.dot} file (by running
3387 @code{dot -Tpng} on it, and verifying the exit code is 0).
3388 @item scan-sarif-file @var{regexp} [@{ target/xfail @var{selector} @}]
3389 Passes if @var{regexp} matches text in the file generated by
3390 @option{-fdiagnostics-format=sarif-file}.
3391 @item scan-sarif-file-not @var{regexp} [@{ target/xfail @var{selector} @}]
3392 Passes if @var{regexp} does not match text in the file generated by
3393 @option{-fdiagnostics-format=sarif-file}.
3394 @end table
3396 @subsubsection Scan the assembly output
3398 @table @code
3399 @item scan-assembler @var{regex} [@{ target/xfail @var{selector} @}]
3400 Passes if @var{regex} matches text in the test's assembler output,
3401 excluding LTO sections.
3403 @item scan-raw-assembler @var{regex} [@{ target/xfail @var{selector} @}]
3404 Passes if @var{regex} matches text in the test's assembler output,
3405 including LTO sections.
3407 @item scan-assembler-not @var{regex} [@{ target/xfail @var{selector} @}]
3408 Passes if @var{regex} does not match text in the test's assembler output,
3409 excluding LTO sections.
3411 @item scan-assembler-times @var{regex} @var{num} [@{ target/xfail @var{selector} @}]
3412 Passes if @var{regex} is matched exactly @var{num} times in the test's
3413 assembler output, excluding LTO sections.
3415 @item scan-assembler-bound @var{regex} @var{cmp} @var{num} [@{ target/xfail @var{selector} @}]
3416 Passes if @var{regex} is matched @var{cmp} @var{num} times in the test's
3417 assembler output, excluding LTO sections. @var{cmp} is a comparitor.
3419 @item scan-assembler-dem @var{regex} [@{ target/xfail @var{selector} @}]
3420 Passes if @var{regex} matches text in the test's demangled assembler output,
3421 excluding LTO sections.
3423 @item scan-assembler-dem-not @var{regex} [@{ target/xfail @var{selector} @}]
3424 Passes if @var{regex} does not match text in the test's demangled assembler
3425 output, excluding LTO sections.
3427 @item scan-assembler-symbol-section @var{functions} @var{section} [@{ target/xfail @var{selector} @}]
3428 Passes if @var{functions} are all in @var{section}.  The caller needs to
3429 allow for @code{USER_LABEL_PREFIX} and different section name conventions.
3431 @item scan-symbol-section @var{filename} @var{functions} @var{section} [@{ target/xfail @var{selector} @}]
3432 Passes if @var{functions} are all in @var{section}in @var{filename}.
3433 The same caveats as for @code{scan-assembler-symbol-section} apply.
3435 @item scan-hidden @var{symbol} [@{ target/xfail @var{selector} @}]
3436 Passes if @var{symbol} is defined as a hidden symbol in the test's
3437 assembly output.
3439 @item scan-not-hidden @var{symbol} [@{ target/xfail @var{selector} @}]
3440 Passes if @var{symbol} is not defined as a hidden symbol in the test's
3441 assembly output.
3443 @item check-function-bodies @var{prefix} @var{terminator} [@var{options} [@{ target/xfail @var{selector} @}]]
3444 Looks through the source file for comments that give the expected assembly
3445 output for selected functions.  Each line of expected output starts with the
3446 prefix string @var{prefix} and the expected output for a function as a whole
3447 is followed by a line that starts with the string @var{terminator}.
3448 Specifying an empty terminator is equivalent to specifying @samp{"*/"}.
3450 @var{options}, if specified, is a list of regular expressions, each of
3451 which matches a full command-line option.  A non-empty list prevents
3452 the test from running unless all of the given options are present on the
3453 command line.  This can help if a source file is compiled both with
3454 and without optimization, since it is rarely useful to check the full
3455 function body for unoptimized code.
3457 The first line of the expected output for a function @var{fn} has the form:
3459 @smallexample
3460 @var{prefix} @var{fn}:  [@{ target/xfail @var{selector} @}]
3461 @end smallexample
3463 Subsequent lines of the expected output also start with @var{prefix}.
3464 In both cases, whitespace after @var{prefix} is not significant.
3466 Depending on the configuration (see
3467 @code{configure_check-function-bodies} in
3468 @file{gcc/testsuite/lib/scanasm.exp}), the test may discard from the
3469 compiler's assembly output directives such as @code{.cfi_startproc},
3470 local label definitions such as @code{.LFB0}, and more.
3471 It then matches the result against the expected
3472 output for a function as a single regular expression.  This means that
3473 later lines can use backslashes to refer back to @samp{(@dots{})}
3474 captures on earlier lines.  For example:
3476 @smallexample
3477 /* @{ dg-final @{ check-function-bodies "**" "" "-DCHECK_ASM" @} @} */
3478 @dots{}
3480 ** add_w0_s8_m:
3481 **      mov     (z[0-9]+\.b), w0
3482 **      add     z0\.b, p0/m, z0\.b, \1
3483 **      ret
3485 svint8_t add_w0_s8_m (@dots{}) @{ @dots{} @}
3486 @dots{}
3488 ** add_b0_s8_m:
3489 **      mov     (z[0-9]+\.b), b0
3490 **      add     z1\.b, p0/m, z1\.b, \1
3491 **      ret
3493 svint8_t add_b0_s8_m (@dots{}) @{ @dots{} @}
3494 @end smallexample
3496 checks whether the implementations of @code{add_w0_s8_m} and
3497 @code{add_b0_s8_m} match the regular expressions given.  The test only
3498 runs when @samp{-DCHECK_ASM} is passed on the command line.
3500 It is possible to create non-capturing multi-line regular expression
3501 groups of the form @samp{(@var{a}|@var{b}|@dots{})} by putting the
3502 @samp{(}, @samp{|} and @samp{)} on separate lines (each still using
3503 @var{prefix}).  For example:
3505 @smallexample
3507 ** cmple_f16_tied:
3508 ** (
3509 **      fcmge   p0\.h, p0/z, z1\.h, z0\.h
3510 ** |
3511 **      fcmle   p0\.h, p0/z, z0\.h, z1\.h
3512 ** )
3513 **      ret
3515 svbool_t cmple_f16_tied (@dots{}) @{ @dots{} @}
3516 @end smallexample
3518 checks whether @code{cmple_f16_tied} is implemented by the
3519 @code{fcmge} instruction followed by @code{ret} or by the
3520 @code{fcmle} instruction followed by @code{ret}.  The test is
3521 still a single regular rexpression.
3523 A line containing just:
3525 @smallexample
3526 @var{prefix} ...
3527 @end smallexample
3529 stands for zero or more unmatched lines; the whitespace after
3530 @var{prefix} is again not significant.
3532 @end table
3534 @subsubsection Scan optimization dump files
3536 These commands are available for @var{kind} of @code{tree}, @code{ltrans-tree},
3537 @code{offload-tree}, @code{rtl}, @code{offload-rtl}, @code{ipa},
3538 @code{offload-ipa}, and @code{wpa-ipa}.
3540 @table @code
3541 @item scan-@var{kind}-dump @var{regex} @var{suffix} [@{ target/xfail @var{selector} @}]
3542 Passes if @var{regex} matches text in the dump file with suffix @var{suffix}.
3544 @item scan-@var{kind}-dump-not @var{regex} @var{suffix} [@{ target/xfail @var{selector} @}]
3545 Passes if @var{regex} does not match text in the dump file with suffix
3546 @var{suffix}.
3548 @item scan-@var{kind}-dump-times @var{regex} @var{num} @var{suffix} [@{ target/xfail @var{selector} @}]
3549 Passes if @var{regex} is found exactly @var{num} times in the dump file
3550 with suffix @var{suffix}.
3552 @item scan-@var{kind}-dump-dem @var{regex} @var{suffix} [@{ target/xfail @var{selector} @}]
3553 Passes if @var{regex} matches demangled text in the dump file with
3554 suffix @var{suffix}.
3556 @item scan-@var{kind}-dump-dem-not @var{regex} @var{suffix} [@{ target/xfail @var{selector} @}]
3557 Passes if @var{regex} does not match demangled text in the dump file with
3558 suffix @var{suffix}.
3559 @end table
3561 The @var{suffix} argument which describes the dump file to be scanned
3562 may contain a glob pattern that must expand to exactly one file
3563 name. This is useful if, e.g., different pass instances are executed
3564 depending on torture testing command-line flags, producing dump files
3565 whose names differ only in their pass instance number suffix.  For
3566 example, to scan instances 1, 2, 3 of a tree pass ``mypass'' for
3567 occurrences of the string ``code has been optimized'', use:
3568 @smallexample
3569 /* @{ dg-options "-fdump-tree-mypass" @} */
3570 /* @{ dg-final @{ scan-tree-dump "code has been optimized" "mypass\[1-3\]" @} @} */
3571 @end smallexample
3573 The @code{offload-@dots{}} ones by default separately scan the dump
3574 file of each enabled offload target.
3575 You may use the @code{only_for_offload_target} wrapper to restrict the
3576 scanning to one specific offload target:
3578 @smallexample
3579 /* @{ dg-do link @{ target offload_target_amdgcn @} @} */
3580 /* @{ dg-additional-options -foffload-options=-fdump-ipa-simdclone-details @} */
3581 /* @{ dg-final @{ only_for_offload_target amdgcn-amdhsa scan-offload-ipa-dump @var{regex_amdgcn} simdclone @} @} */
3582 @end smallexample
3584 This test case is active if GCN offload compilation is enabled (but
3585 potentially also additional offload targets).
3586 The @code{simdclone} IPA dump file is (potentially) produced for all
3587 offload targets, but only the GCN offload one is scanned.
3589 If a test case doesn't have a @samp{@{ target @var{selector} @}}, and
3590 you need to scan, for example, for different @var{regex}es for each of
3591 host and potentially several offload targets, use a pattern like this:
3593 @smallexample
3594 /* @{ dg-final @{ scan-tree-dump @var{regex_host} optimized @} @}
3595    @{ dg-final @{ only_for_offload_target amdgcn-amdhsa scan-offload-tree-dump @var{regex_amdgcn} optimized @{ target offload_target_amdgcn @} @} @}
3596    @{ dg-final @{ only_for_offload_target nvptx-none scan-offload-tree-dump @var{regex_nvptx} optimized @{ target offload_target_nvptx @} @} @} */
3597 @end smallexample
3599 Here, unconditionally @var{regex_host} is scanned for in the host dump
3600 file.
3601 If GCN offloading compilation is actually enabled, @var{regex_amdgcn}
3602 is scanned for in the GCN offload compilation dump file.
3603 If nvptx offloading compilation is actually enabled, @var{regex_nvptx}
3604 is scanned for in the nvptx offload compilation dump file.
3607 @subsubsection Check for output files
3609 @table @code
3610 @item output-exists [@{ target/xfail @var{selector} @}]
3611 Passes if compiler output file exists.
3613 @item output-exists-not [@{ target/xfail @var{selector} @}]
3614 Passes if compiler output file does not exist.
3616 @item scan-symbol @var{regexp} [@{ target/xfail @var{selector} @}]
3617 Passes if the pattern is present in the final executable.
3619 @item scan-symbol-not @var{regexp} [@{ target/xfail @var{selector} @}]
3620 Passes if the pattern is absent from the final executable.
3621 @end table
3623 @subsubsection Checks for @command{gcov} tests
3625 @table @code
3626 @item run-gcov @var{sourcefile}
3627 Check line counts in @command{gcov} tests.
3629 @item run-gcov [branches] [calls] @{ @var{opts} @var{sourcefile} @}
3630 Check branch and/or call counts, in addition to line counts, in
3631 @command{gcov} tests.
3633 @item run-gcov-pytest @{ @var{sourcefile} @var{pytest_file} @}
3634 Check output of @command{gcov} intermediate format with a pytest
3635 script.
3636 @end table
3638 @subsubsection Clean up generated test files
3640 Usually the test-framework removes files that were generated during
3641 testing. If a testcase, for example, uses any dumping mechanism to
3642 inspect a passes dump file, the testsuite recognized the dump option
3643 passed to the tool and schedules a final cleanup to remove these files.
3645 There are, however, following additional cleanup directives that can be
3646 used to annotate a testcase "manually".
3647 @table @code
3648 @item cleanup-coverage-files
3649 Removes coverage data files generated for this test.
3651 @item cleanup-modules "@var{list-of-extra-modules}"
3652 Removes Fortran module files generated for this test, excluding the
3653 module names listed in keep-modules.
3654 Cleaning up module files is usually done automatically by the testsuite
3655 by looking at the source files and removing the modules after the test
3656 has been executed.
3657 @smallexample
3658 module MoD1
3659 end module MoD1
3660 module Mod2
3661 end module Mod2
3662 module moD3
3663 end module moD3
3664 module mod4
3665 end module mod4
3666 ! @{ dg-final @{ cleanup-modules "mod1 mod2" @} @} ! redundant
3667 ! @{ dg-final @{ keep-modules "mod3 mod4" @} @}
3668 @end smallexample
3670 @item keep-modules "@var{list-of-modules-not-to-delete}"
3671 Whitespace separated list of module names that should not be deleted by
3672 cleanup-modules.
3673 If the list of modules is empty, all modules defined in this file are kept.
3674 @smallexample
3675 module maybe_unneeded
3676 end module maybe_unneeded
3677 module keep1
3678 end module keep1
3679 module keep2
3680 end module keep2
3681 ! @{ dg-final @{ keep-modules "keep1 keep2" @} @} ! just keep these two
3682 ! @{ dg-final @{ keep-modules "" @} @} ! keep all
3683 @end smallexample
3685 @item dg-keep-saved-temps "@var{list-of-suffixes-not-to-delete}"
3686 Whitespace separated list of suffixes that should not be deleted
3687 automatically in a testcase that uses @option{-save-temps}.
3688 @smallexample
3689 // @{ dg-options "-save-temps -fpch-preprocess -I." @}
3690 int main() @{ return 0; @}
3691 // @{ dg-keep-saved-temps ".s" @} ! just keep assembler file
3692 // @{ dg-keep-saved-temps ".s" ".i" @} ! ... and .i
3693 // @{ dg-keep-saved-temps ".ii" ".o" @} ! or just .ii and .o
3694 @end smallexample
3696 @item cleanup-profile-file
3697 Removes profiling files generated for this test.
3699 @end table
3701 @node Ada Tests
3702 @section Ada Language Testsuites
3704 The Ada testsuite includes executable tests from the ACATS
3705 testsuite, publicly available at
3706 @uref{http://www.ada-auth.org/acats.html}.
3708 These tests are integrated in the GCC testsuite in the
3709 @file{ada/acats} directory, and
3710 enabled automatically when running @code{make check}, assuming
3711 the Ada language has been enabled when configuring GCC@.
3713 You can also run the Ada testsuite independently, using
3714 @code{make check-ada}, or run a subset of the tests by specifying which
3715 chapter to run, e.g.:
3717 @smallexample
3718 $ make check-ada CHAPTERS="c3 c9"
3719 @end smallexample
3721 The tests are organized by directory, each directory corresponding to
3722 a chapter of the Ada Reference Manual.  So for example, @file{c9} corresponds
3723 to chapter 9, which deals with tasking features of the language.
3725 The tests are run using two @command{sh} scripts: @file{run_acats} and
3726 @file{run_all.sh}.  To run the tests using a simulator or a cross
3727 target, see the small
3728 customization section at the top of @file{run_all.sh}.
3730 These tests are run using the build tree: they can be run without doing
3731 a @code{make install}.
3733 @node C Tests
3734 @section C Language Testsuites
3736 GCC contains the following C language testsuites, in the
3737 @file{gcc/testsuite} directory:
3739 @table @file
3740 @item gcc.dg
3741 This contains tests of particular features of the C compiler, using the
3742 more modern @samp{dg} harness.  Correctness tests for various compiler
3743 features should go here if possible.
3745 Magic comments determine whether the file
3746 is preprocessed, compiled, linked or run.  In these tests, error and warning
3747 message texts are compared against expected texts or regular expressions
3748 given in comments.  These tests are run with the options @samp{-ansi -pedantic}
3749 unless other options are given in the test.  Except as noted below they
3750 are not run with multiple optimization options.
3751 @item gcc.dg/compat
3752 This subdirectory contains tests for binary compatibility using
3753 @file{lib/compat.exp}, which in turn uses the language-independent support
3754 (@pxref{compat Testing, , Support for testing binary compatibility}).
3755 @item gcc.dg/cpp
3756 This subdirectory contains tests of the preprocessor.
3757 @item gcc.dg/debug
3758 This subdirectory contains tests for debug formats.  Tests in this
3759 subdirectory are run for each debug format that the compiler supports.
3760 @item gcc.dg/format
3761 This subdirectory contains tests of the @option{-Wformat} format
3762 checking.  Tests in this directory are run with and without
3763 @option{-DWIDE}.
3764 @item gcc.dg/noncompile
3765 This subdirectory contains tests of code that should not compile and
3766 does not need any special compilation options.  They are run with
3767 multiple optimization options, since sometimes invalid code crashes
3768 the compiler with optimization.
3769 @item gcc.dg/special
3770 FIXME: describe this.
3772 @item gcc.c-torture
3773 This contains particular code fragments which have historically broken easily.
3774 These tests are run with multiple optimization options, so tests for features
3775 which only break at some optimization levels belong here.  This also contains
3776 tests to check that certain optimizations occur.  It might be worthwhile to
3777 separate the correctness tests cleanly from the code quality tests, but
3778 it hasn't been done yet.
3780 @item gcc.c-torture/compat
3781 FIXME: describe this.
3783 This directory should probably not be used for new tests.
3784 @item gcc.c-torture/compile
3785 This testsuite contains test cases that should compile, but do not
3786 need to link or run.  These test cases are compiled with several
3787 different combinations of optimization options.  All warnings are
3788 disabled for these test cases, so this directory is not suitable if
3789 you wish to test for the presence or absence of compiler warnings.
3790 While special options can be set, and tests disabled on specific
3791 platforms, by the use of @file{.x} files, mostly these test cases
3792 should not contain platform dependencies.  FIXME: discuss how defines
3793 such as @code{STACK_SIZE} are used.
3794 @item gcc.c-torture/execute
3795 This testsuite contains test cases that should compile, link and run;
3796 otherwise the same comments as for @file{gcc.c-torture/compile} apply.
3797 @item gcc.c-torture/execute/ieee
3798 This contains tests which are specific to IEEE floating point.
3799 @item gcc.c-torture/unsorted
3800 FIXME: describe this.
3802 This directory should probably not be used for new tests.
3803 @item gcc.misc-tests
3804 This directory contains C tests that require special handling.  Some
3805 of these tests have individual expect files, and others share
3806 special-purpose expect files:
3808 @table @file
3809 @item @code{bprob*.c}
3810 Test @option{-fbranch-probabilities} using
3811 @file{gcc.misc-tests/bprob.exp}, which
3812 in turn uses the generic, language-independent framework
3813 (@pxref{profopt Testing, , Support for testing profile-directed
3814 optimizations}).
3816 @item @code{gcov*.c}
3817 Test @command{gcov} output using @file{gcov.exp}, which in turn uses the
3818 language-independent support (@pxref{gcov Testing, , Support for testing gcov}).
3820 @item @code{i386-pf-*.c}
3821 Test i386-specific support for data prefetch using @file{i386-prefetch.exp}.
3822 @end table
3824 @item gcc.test-framework
3825 @table @file
3826 @item @code{dg-*.c}
3827 Test the testsuite itself using @file{gcc.test-framework/test-framework.exp}.
3828 @end table
3830 @end table
3832 FIXME: merge in @file{testsuite/README.gcc} and discuss the format of
3833 test cases and magic comments more.
3835 @node LTO Testing
3836 @section Support for testing link-time optimizations
3838 Tests for link-time optimizations usually require multiple source files
3839 that are compiled separately, perhaps with different sets of options.
3840 There are several special-purpose test directives used for these tests.
3842 @table @code
3843 @item @{ dg-lto-do @var{do-what-keyword} @}
3844 @var{do-what-keyword} specifies how the test is compiled and whether
3845 it is executed.  It is one of:
3847 @table @code
3848 @item assemble
3849 Compile with @option{-c} to produce a relocatable object file.
3850 @item link
3851 Compile, assemble, and link to produce an executable file.
3852 @item run
3853 Produce and run an executable file, which is expected to return
3854 an exit code of 0.
3855 @end table
3857 The default is @code{assemble}.  That can be overridden for a set of
3858 tests by redefining @code{dg-do-what-default} within the @code{.exp}
3859 file for those tests.
3861 Unlike @code{dg-do}, @code{dg-lto-do} does not support an optional
3862 @samp{target} or @samp{xfail} list.  Use @code{dg-skip-if},
3863 @code{dg-xfail-if}, or @code{dg-xfail-run-if}.
3865 @item @{ dg-lto-options @{ @{ @var{options} @} [@{ @var{options} @}] @} [@{ target @var{selector} @}]@}
3866 This directive provides a list of one or more sets of compiler options
3867 to override @var{LTO_OPTIONS}.  Each test will be compiled and run with
3868 each of these sets of options.
3870 @item @{ dg-extra-ld-options @var{options} [@{ target @var{selector} @}]@}
3871 This directive adds @var{options} to the linker options used.
3873 @item @{ dg-suppress-ld-options @var{options} [@{ target @var{selector} @}]@}
3874 This directive removes @var{options} from the set of linker options used.
3875 @end table
3877 @node gcov Testing
3878 @section Support for testing @command{gcov}
3880 Language-independent support for testing @command{gcov}, and for checking
3881 that branch profiling produces expected values, is provided by the
3882 expect file @file{lib/gcov.exp}.  @command{gcov} tests also rely on procedures
3883 in @file{lib/gcc-dg.exp} to compile and run the test program.  A typical
3884 @command{gcov} test contains the following DejaGnu commands within comments:
3886 @smallexample
3887 @{ dg-options "--coverage" @}
3888 @{ dg-do run @{ target native @} @}
3889 @{ dg-final @{ run-gcov sourcefile @} @}
3890 @end smallexample
3892 Checks of @command{gcov} output can include line counts, branch percentages,
3893 and call return percentages.  All of these checks are requested via
3894 commands that appear in comments in the test's source file.
3895 Commands to check line counts are processed by default.
3896 Commands to check branch percentages and call return percentages are
3897 processed if the @command{run-gcov} command has arguments @code{branches}
3898 or @code{calls}, respectively.  For example, the following specifies
3899 checking both, as well as passing @option{-b} to @command{gcov}:
3901 @smallexample
3902 @{ dg-final @{ run-gcov branches calls @{ -b sourcefile @} @} @}
3903 @end smallexample
3905 A line count command appears within a comment on the source line
3906 that is expected to get the specified count and has the form
3907 @code{count(@var{cnt})}.  A test should only check line counts for
3908 lines that will get the same count for any architecture.
3910 Commands to check branch percentages (@code{branch}) and call
3911 return percentages (@code{returns}) are very similar to each other.
3912 A beginning command appears on or before the first of a range of
3913 lines that will report the percentage, and the ending command
3914 follows that range of lines.  The beginning command can include a
3915 list of percentages, all of which are expected to be found within
3916 the range.  A range is terminated by the next command of the same
3917 kind.  A command @code{branch(end)} or @code{returns(end)} marks
3918 the end of a range without starting a new one.  For example:
3920 @smallexample
3921 if (i > 10 && j > i && j < 20)  /* @r{branch(27 50 75)} */
3922                                 /* @r{branch(end)} */
3923   foo (i, j);
3924 @end smallexample
3926 For a call return percentage, the value specified is the
3927 percentage of calls reported to return.  For a branch percentage,
3928 the value is either the expected percentage or 100 minus that
3929 value, since the direction of a branch can differ depending on the
3930 target or the optimization level.
3932 Not all branches and calls need to be checked.  A test should not
3933 check for branches that might be optimized away or replaced with
3934 predicated instructions.  Don't check for calls inserted by the
3935 compiler or ones that might be inlined or optimized away.
3937 A single test can check for combinations of line counts, branch
3938 percentages, and call return percentages.  The command to check a
3939 line count must appear on the line that will report that count, but
3940 commands to check branch percentages and call return percentages can
3941 bracket the lines that report them.
3943 @node profopt Testing
3944 @section Support for testing profile-directed optimizations
3946 The file @file{profopt.exp} provides language-independent support for
3947 checking correct execution of a test built with profile-directed
3948 optimization.  This testing requires that a test program be built and
3949 executed twice.  The first time it is compiled to generate profile
3950 data, and the second time it is compiled to use the data that was
3951 generated during the first execution.  The second execution is to
3952 verify that the test produces the expected results.
3954 To check that the optimization actually generated better code, a
3955 test can be built and run a third time with normal optimizations to
3956 verify that the performance is better with the profile-directed
3957 optimizations.  @file{profopt.exp} has the beginnings of this kind
3958 of support.
3960 @file{profopt.exp} provides generic support for profile-directed
3961 optimizations.  Each set of tests that uses it provides information
3962 about a specific optimization:
3964 @table @code
3965 @item tool
3966 tool being tested, e.g., @command{gcc}
3968 @item profile_option
3969 options used to generate profile data
3971 @item feedback_option
3972 options used to optimize using that profile data
3974 @item prof_ext
3975 suffix of profile data files
3977 @item PROFOPT_OPTIONS
3978 list of options with which to run each test, similar to the lists for
3979 torture tests
3981 @item @{ dg-final-generate @{ @var{local-directive} @} @}
3982 This directive is similar to @code{dg-final}, but the
3983 @var{local-directive} is run after the generation of profile data.
3985 @item @{ dg-final-use @{ @var{local-directive} @} @}
3986 The @var{local-directive} is run after the profile data have been
3987 used.
3988 @end table
3990 @node compat Testing
3991 @section Support for testing binary compatibility
3993 The file @file{compat.exp} provides language-independent support for
3994 binary compatibility testing.  It supports testing interoperability of
3995 two compilers that follow the same ABI, or of multiple sets of
3996 compiler options that should not affect binary compatibility.  It is
3997 intended to be used for testsuites that complement ABI testsuites.
3999 A test supported by this framework has three parts, each in a
4000 separate source file: a main program and two pieces that interact
4001 with each other to split up the functionality being tested.
4003 @table @file
4004 @item @var{testname}_main.@var{suffix}
4005 Contains the main program, which calls a function in file
4006 @file{@var{testname}_x.@var{suffix}}.
4008 @item @var{testname}_x.@var{suffix}
4009 Contains at least one call to a function in
4010 @file{@var{testname}_y.@var{suffix}}.
4012 @item @var{testname}_y.@var{suffix}
4013 Shares data with, or gets arguments from,
4014 @file{@var{testname}_x.@var{suffix}}.
4015 @end table
4017 Within each test, the main program and one functional piece are
4018 compiled by the GCC under test.  The other piece can be compiled by
4019 an alternate compiler.  If no alternate compiler is specified,
4020 then all three source files are all compiled by the GCC under test.
4021 You can specify pairs of sets of compiler options.  The first element
4022 of such a pair specifies options used with the GCC under test, and the
4023 second element of the pair specifies options used with the alternate
4024 compiler.  Each test is compiled with each pair of options.
4026 @file{compat.exp} defines default pairs of compiler options.
4027 These can be overridden by defining the environment variable
4028 @env{COMPAT_OPTIONS} as:
4030 @smallexample
4031 COMPAT_OPTIONS="[list [list @{@var{tst1}@} @{@var{alt1}@}]
4032   @dots{}[list @{@var{tstn}@} @{@var{altn}@}]]"
4033 @end smallexample
4035 where @var{tsti} and @var{alti} are lists of options, with @var{tsti}
4036 used by the compiler under test and @var{alti} used by the alternate
4037 compiler.  For example, with
4038 @code{[list [list @{-g -O0@} @{-O3@}] [list @{-fpic@} @{-fPIC -O2@}]]},
4039 the test is first built with @option{-g -O0} by the compiler under
4040 test and with @option{-O3} by the alternate compiler.  The test is
4041 built a second time using @option{-fpic} by the compiler under test
4042 and @option{-fPIC -O2} by the alternate compiler.
4044 An alternate compiler is specified by defining an environment
4045 variable to be the full pathname of an installed compiler; for C
4046 define @env{ALT_CC_UNDER_TEST}, and for C++ define
4047 @env{ALT_CXX_UNDER_TEST}.  These will be written to the
4048 @file{site.exp} file used by DejaGnu.  The default is to build each
4049 test with the compiler under test using the first of each pair of
4050 compiler options from @env{COMPAT_OPTIONS}.  When
4051 @env{ALT_CC_UNDER_TEST} or
4052 @env{ALT_CXX_UNDER_TEST} is @code{same}, each test is built using
4053 the compiler under test but with combinations of the options from
4054 @env{COMPAT_OPTIONS}.
4056 To run only the C++ compatibility suite using the compiler under test
4057 and another version of GCC using specific compiler options, do the
4058 following from @file{@var{objdir}/gcc}:
4060 @smallexample
4061 rm site.exp
4062 make -k \
4063   ALT_CXX_UNDER_TEST=$@{alt_prefix@}/bin/g++ \
4064   COMPAT_OPTIONS="@var{lists as shown above}" \
4065   check-c++ \
4066   RUNTESTFLAGS="compat.exp"
4067 @end smallexample
4069 A test that fails when the source files are compiled with different
4070 compilers, but passes when the files are compiled with the same
4071 compiler, demonstrates incompatibility of the generated code or
4072 runtime support.  A test that fails for the alternate compiler but
4073 passes for the compiler under test probably tests for a bug that was
4074 fixed in the compiler under test but is present in the alternate
4075 compiler.
4077 The binary compatibility tests support a small number of test framework
4078 commands that appear within comments in a test file.
4080 @table @code
4081 @item dg-require-*
4082 These commands can be used in @file{@var{testname}_main.@var{suffix}}
4083 to skip the test if specific support is not available on the target.
4085 @item dg-options
4086 The specified options are used for compiling this particular source
4087 file, appended to the options from @env{COMPAT_OPTIONS}.  When this
4088 command appears in @file{@var{testname}_main.@var{suffix}} the options
4089 are also used to link the test program.
4091 @item dg-xfail-if
4092 This command can be used in a secondary source file to specify that
4093 compilation is expected to fail for particular options on particular
4094 targets.
4095 @end table
4097 @node Torture Tests
4098 @section Support for torture testing using multiple options
4100 Throughout the compiler testsuite there are several directories whose
4101 tests are run multiple times, each with a different set of options.
4102 These are known as torture tests.
4103 @file{lib/torture-options.exp} defines procedures to
4104 set up these lists:
4106 @table @code
4107 @item torture-init
4108 Initialize use of torture lists.
4109 @item set-torture-options
4110 Set lists of torture options to use for tests with and without loops.
4111 Optionally combine a set of torture options with a set of other
4112 options, as is done with Objective-C runtime options.
4113 @item torture-finish
4114 Finalize use of torture lists.
4115 @end table
4117 The @file{.exp} file for a set of tests that use torture options must
4118 include calls to these three procedures if:
4120 @itemize @bullet
4121 @item It calls @code{gcc-dg-runtest} and overrides @var{DG_TORTURE_OPTIONS}.
4123 @item It calls @var{$@{tool@}}@code{-torture} or
4124 @var{$@{tool@}}@code{-torture-execute}, where @var{tool} is @code{c},
4125 @code{fortran}, or @code{objc}.
4127 @item It calls @code{dg-pch}.
4128 @end itemize
4130 It is not necessary for a @file{.exp} file that calls @code{gcc-dg-runtest}
4131 to call the torture procedures if the tests should use the list in
4132 @var{DG_TORTURE_OPTIONS} defined in @file{gcc-dg.exp}.
4134 Most uses of torture options can override the default lists by defining
4135 @var{TORTURE_OPTIONS} or add to the default list by defining
4136 @var{ADDITIONAL_TORTURE_OPTIONS}.  Define these in a @file{.dejagnurc}
4137 file or add them to the @file{site.exp} file; for example
4139 @smallexample
4140 set ADDITIONAL_TORTURE_OPTIONS  [list \
4141   @{ -O2 -ftree-loop-linear @} \
4142   @{ -O2 -fpeel-loops @} ]
4143 @end smallexample
4145 @node GIMPLE Tests
4146 @section Support for testing GIMPLE passes
4148 As of gcc 7, C functions can be tagged with @code{__GIMPLE} to indicate
4149 that the function body will be GIMPLE, rather than C.  The compiler requires
4150 the option @option{-fgimple} to enable this functionality.  For example:
4152 @smallexample
4153 /* @{ dg-do compile @} */
4154 /* @{ dg-options "-O -fgimple" @} */
4156 void __GIMPLE (startwith ("dse2")) foo ()
4158   int a;
4160 bb_2:
4161   if (a > 4)
4162     goto bb_3;
4163   else
4164     goto bb_4;
4166 bb_3:
4167   a_2 = 10;
4168   goto bb_5;
4170 bb_4:
4171   a_3 = 20;
4173 bb_5:
4174   a_1 = __PHI (bb_3: a_2, bb_4: a_3);
4175   a_4 = a_1 + 4;
4177   return;
4179 @end smallexample
4181 The @code{startwith} argument indicates at which pass to begin.
4183 Use the dump modifier @code{-gimple} (e.g.@: @option{-fdump-tree-all-gimple})
4184 to make tree dumps more closely follow the format accepted by the GIMPLE
4185 parser.
4187 Example DejaGnu tests of GIMPLE can be seen in the source tree at
4188 @file{gcc/testsuite/gcc.dg/gimplefe-*.c}.
4190 The @code{__GIMPLE} parser is integrated with the C tokenizer and
4191 preprocessor, so it should be possible to use macros to build out
4192 test coverage.
4194 @node RTL Tests
4195 @section Support for testing RTL passes
4197 As of gcc 7, C functions can be tagged with @code{__RTL} to indicate that the
4198 function body will be RTL, rather than C.  For example:
4200 @smallexample
4201 double __RTL (startwith ("ira")) test (struct foo *f, const struct bar *b)
4203   (function "test"
4204      [...snip; various directives go in here...]
4205   ) ;; function "test"
4207 @end smallexample
4209 The @code{startwith} argument indicates at which pass to begin.
4211 The parser expects the RTL body to be in the format emitted by this
4212 dumping function:
4214 @smallexample
4215 DEBUG_FUNCTION void
4216 print_rtx_function (FILE *outfile, function *fn, bool compact);
4217 @end smallexample
4219 when "compact" is true.  So you can capture RTL in the correct format
4220 from the debugger using:
4222 @smallexample
4223 (gdb) print_rtx_function (stderr, cfun, true);
4224 @end smallexample
4226 and copy and paste the output into the body of the C function.
4228 Example DejaGnu tests of RTL can be seen in the source tree under
4229 @file{gcc/testsuite/gcc.dg/rtl}.
4231 The @code{__RTL} parser is not integrated with the C tokenizer or
4232 preprocessor, and works simply by reading the relevant lines within
4233 the braces.  In particular, the RTL body must be on separate lines from
4234 the enclosing braces, and the preprocessor is not usable within it.